carma
is designed to handle a polynomial within subject 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 coefficients 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 multiplied 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.
carma(response = NULL, ccov = NULL, times = NULL, torder = 0,
interaction, arma = c(0, 0, 0), parma = NULL, pre = NULL,
position = NULL, iopt = TRUE, resid = TRUE,
transform = "identity", delta = NULL, envir = parent.frame(),
print.level = 0, typsize = abs(p), ndigit = 10, gradtol = 1e-05,
steptol = 1e-05, iterlim = 100, fscale = 1, stepmax = 10 * sqrt(p
%*% p))# S3 method for carma
coef(object, ...)
# S3 method for carma
deviance(object, ...)
# S3 method for carma
residuals(object, recursive = TRUE, ...)
# S3 method for carma
print(x, digits = max(3, .Options$digits - 3),
correlation = TRUE, ...)
# S3 method for carma
mprofile(z, times = NULL, ccov, plotse = TRUE, ...)
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
or lvna
). If the
repeated
data object contains more than one response variable, give
that object in envir
and give the name of the response variable to be
used here.
A matrix of columns of baseline covariates with one row per
individual, a model formula using vectors of the same size, or an object of
class, tccov
(created by tcctomat
). If response
has class, repeated
, the covariates must be specified as a Wilkinson
and Rogers formula unless none are to be used.
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 necessary if equally spaced. Ignored if response has class,
response
or repeated
.
Order of the polynomial in time to be fitted.
Vector indicating order of interactions of covariates with time.
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 supplied, it is assumed to be the order of the AR.
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 positive, 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]))
.
Initial estimates of random effect parameters.
Two column matrix with rows giving index positions of random effects in the covariance matrix.
TRUE if optimization should be performed.
TRUE if residuals to be calculated.
Transformation of the response variable: identity
,
exp
, square
, sqrt
, or log
.
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 decimals, delta=0.01
. Ignored if response has class,
response
or repeated
.
Environment in which model formulae are to be interpreted or a
data object of class, repeated
, tccov
, or tvcov
; the
name of the response variable should be given in response
. If
response
has class repeated
, it is used as the environment.
Arguments for nlm.
Arguments for nlm.
Arguments for nlm.
Arguments for nlm.
Arguments for nlm.
Arguments for nlm.
Arguments for nlm.
Arguments for nlm.
An object of class, carma
.
additional arguments.
If TRUE, recursive residuals or fitted values are given; otherwise, marginal ones.
An object of class, carma
.
number of digits to print.
logical; print correlations.
An object of class, carma
.
Plot the standard errors around the marginal profile curve.
A list of class carma
is returned that contains all of the
relevant information calculated, including error codes.
coef
: Coefficients
deviance
: Deviance
residuals
: Residuals
print
: Print method
mprofile
: Special marginal profiles with SEs
For clustered (non-longitudinal) data, where only random effects will be
fitted, times
are not necessary.
Marginal and individual profiles can be plotted using
mprofile
and iprofile
and
residuals with plot.residuals
.
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.
Jones, R. H. and Ackerson, L. M. (1991) Serial correlation 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
elliptic
, gar
,
gnlmix
, glmm
,
gnlmm
, iprofile
,
kalseries
, mprofile
,
plot.residuals
, potthoff
,
read.list
, restovec
,
rmna
, tcctomat
,
tvctomat
.
# NOT RUN {
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)))
# }
Run the code above in your browser using DataLab