

   CCoonnttiinnuuoouuss AARRMMAA ffoorr UUnneeqquuaallllyy SSppaacceedd RReeppeeaatteedd MMeeaassuurreemmeennttss

        carma(response, ccov=NULL, times=NULL, torder=0, interaction,
             transform="identity", arma=c(0,0,0), parma=NULL, pre=NULL,
             position=NULL, iopt=T, resid=T, delta=NULL, print.level=0,
             iterlim=100, typsiz=abs(p), ndigit=10, gradtol=0.00001,
             fscale=1, stepmax=10*sqrt(p%*%p), steptol=0.00001)

   AArrgguummeennttss::

   response: A list of two column matrices with response values
             and times for each individual, one matrix or
             dataframe of response values, or an object of
             either class, response (created by `restovec') or
             repeated (created by `rmna').

       ccov: A matrix of columns of baseline covariates with
             one row per individual, a model formula using vec-
             tors of the same size, or an object of class,
             tccov (created by `tcctomat'). If response has
             class, repeated, the covariates must be supplied
             as a Wilkinson and Rogers formula unless none are
             to be used.

      times: When response is a matrix, a vector of possibly
             unequally spaced times when they are the same for
             all individuals or a matrix of times. Not neces-
             sary if equally spaced. Ignored if response has
             class, response or repeated.

     torder: Order of the polynomial in time to be fitted.

   interaction: Vector indicating order of interactions of
             covariates with time.

   transform: Transformation of the response variable: `iden-
             tity', `exp', `square', `sqrt', or `log'.

       arma: Vector of three values: order of AR, order of MA,
             binary indicator for presence of measurement
             error. Not required for an AR(1) if an initial
             estimate is supplied. If only one value is sup-
             plied, it is assumed to be the order of the AR.

      parma: Initial estimates of ARMA parameters. For example,
             with `arma=c(1,0,0)', an AR(1), the parameter is
             `parma[1]=log(theta)', where `theta' is the posi-
             tive, continuous time autoregressive coefficient.
             The finite step autoregression coefficient for a
             step of length `delta' is then
             `alpha=exp(-delta*theta)' i.e.
             `alpha=exp(-delta*exp(parma[1]))'.

        pre: Initial estimates of random effect parameters.

   position: Two column matrix with rows giving index positions
             of random effects in the covariance matrix.

       iopt: TRUE if optimization should be performed.

      resid: TRUE if residuals to be calculated.

      delta: Scalar or vector giving the unit of measurement
             for each response value, set to unity by default.
             For example, if a response is measured to two dec-
             imals, delta=0.01. Ignored if response has class,
             response or repeated.

     others: Arguments controlling `nlm'.

   DDeessccrriippttiioonn::

        `carma' is designed to handle a polynomial within sub-
        ject design matrix with unequally spaced observations
        which can be at different times for different subjects.
        The origin of time is taken as the mean time of all the
        subjects. The within subject errors are assumed to be
        independent Gaussian or have a continuous time
        ARMA(p,q) Gaussian structure with the option to include
        measurement error.  The between subject random coeffi-
        cients are assumed to have an arbitrary covariance
        matrix. The fixed effect design matrix is a polynomial
        of equal or higher order than the within subject design
        matrix. This matrix can be augmented by covariates mul-
        tiplied by polynomial design matrices of any order up
        to the order of the first partition of the design
        matrix. The method is based on exact maximum likelihood
        using the Kalman filter to calculate the likelihood.

        For clustered (non-longitudinal) data, where only ran-
        dom effects will be fitted, the `times' may be any
        strictly increasing sequence distinguishing the
        responses on an individual.

        Marginal and individual profiles can be plotted using
        `profile' and `iprofile' and residuals with
        `plot.residuals'.

   VVaalluuee::

        A list of class `carma' is returned. For any ARMA of
        order superior to an AR(1), the (complex) roots of the
        characteristic equation are printed out; see Jones and
        Ackerson (1991) for their use in calculation of the
        covariance function.

   AAuutthhoorr((ss))::

        R.H. Jones and J.K. Lindsey

   RReeffeerreenncceess::

        Jones, R. H. and Ackerson, L. M. (1991) Serial correla-
        tion in unequally spaced longitudinal data. Biometrika,
        77, 721-731.

        Jones, R.H. (1993) Longitudinal Data Analysis with
        Serial Correlation: A State-space Approach. Chapman and
        Hall

   SSeeee AAllssoo::

        `elliptic', `gar', `glmm', `gnlmm', `iprofile',
        `kalseries', `plot.residuals', `profile', `potthoff',
        `read.list', `restovec', `rmna', `tcctomat', `tvc-
        tomat'.

   EExxaammpplleess::

        y <- matrix(rnorm(40),ncol=5)
        x1 <- gl(2,4)
        x2 <- gl(2,1,8)
        # independence with time trend
        carma(y, ccov=~x1, torder=2)
        # AR(1)
        carma(y, ccov=~x1, torder=2, arma=c(1,0,0), parma=-0.5)
        carma(y, ccov=~x1, torder=3, interact=3, arma=c(1,0,0), parma=-1)
        # ARMA(2,1)
        carma(y, ccov=~x1+x2, interact=c(2,0), torder=3,arma=c(2,1,0),
             parma=c(0.3,2,0.7))
        # random intercept
        carma(y, ccov=~x1+x2, interact=c(2,0), torder=3, pre=-0.4,
             position=c(1,1))
        # random coefficients
        carma(y, ccov=~x1+x2, interact=c(2,0), torder=3, pre=c(-0.4,0.1),
             position=rbind(c(1,1),c(2,2)))

