DataMethods {rmutil}R Documentation

Methods for response, tccov, tvcov, and repeated Data Objects


Objects of class, response, contain response values, and possibly the corresponding times, binomial totals, nesting categories, censor indicators, and/or units of precision/Jacobian. Objects of class, tccov, contain time-constant or inter-individual, baseline covariates. Objects of class, tvcov, contain time-varying or intra-individual covariates. Objects of class, repeated, contain a response object and possibly tccov and tvcov objects.

In formula and functions, the key words, times can be used to refer to the response times from the data object as a covariate, individuals to the index for individuals as a factor covariate, and nesting the index for nesting as a factor covariate. The latter two only work for W&R notation.

The following methods are available for accessing the contents of such data objects. places all of the variables in the data object in one dataframe, extending time-constant covariates to the length of the others unless the object has class, tccov. Binomial and censored response variables have two columns, respectively `yes' and `no' and response and censoring indicator, with the name given to the response.

as.matrix: places all of the variables in the data object in one matrix, extending time-constant covariates to the length of the others unless the object has class, tccov. If any covariates are factor variables (instead of the corresponding sets of indicator variables), the matrix will be character instead of numeric.

covariates: extracts covariate matrices from a data object (for formulae and functions, possibly for selected individuals. See covariates.formulafn).

covind: gives the indexing of the response by individual (that is, the nesting indicator for observations within individuals). It can be used to expand time-constant covariates to the size of the repeated measurements response.

delta: extracts the units of measurement vector and Jacobian of any transformation of the response, possibly for selected individuals. Note that, if the unit of measurement/Jacobian is available in the response object, this is automatically included in the calculation of the likelihood function in all library model functions.

units: prints the variable names and their description and returns the latter.

formula: gives the formula used to create the time-constant covariate matrix of a data object (for formulae and functions, see formula.formulafn).

names: extracts the names of the response and/or covariates.

nesting: gives the coding variable(s) for individuals (same as covind) and also for nesting within individuals if available, possibly for selected individuals.

nobs: gives the number of observations per individual.

plot: plots the variables in the data object in various ways. For repeated objects, name can be a response or a time-varying covariate.

print: prints summary information about the variables in a data object.

response: extracts the response vector, possibly for selected individuals. If there are censored observations, this is a two-column matrix, with the censor indicator in the second column. For binomial data, it is a two-column matrix with "positive" (y) and "negative" (totals-y) frequencies.

resptype: extracts the type of each response.

times: extracts the times vector, possibly for selected individuals.

transform: transforms variables. For example, transform(z, y=fcn1(y), times=fcn2(times)) where fcn1 and fcn2 are transformation functions. When the response is transformed, the Jacobian is automatically calculated. New response variables and covariates can be created in this way, if the left hand side is a new name (ynew=fcn3(y)), as well as replacing an old variable with the transformed one. If the transformation reverses the order of the responses, use its negative to keep the ordering and have a positive Jacobian; for example, ry=-1/y. For repeated objects, only the response and the times can be transformed.

units: prints the variable names and their units of measurement and returns the latter.

weights: extracts the weight vector, possibly for selected individuals.

covariates(z, nind=NULL, names=NULL, expand=F)
delta(z, nind=NULL, names=NULL)
nesting(z, nind=NULL)
plot(z, name=NULL, nind=NULL, nest=1, ccov=NULL, add=F, lty=NULL, pch=NULL,
        main=NULL, ylim=NULL, xlim=NULL, xlab=NULL, ylab=NULL, ...)
print(z, nindmax=50)
response(z, nind=NULL, names=NULL)
times(z, nind=NULL)
transform(z, times=NULL, ...)
weights(z, nind=NULL)


z A response, tccov, tvcov, or repeated data object. For covind and nobs, this may also be a model.
y The function, when the response is to be transformed.
times The function, when the times are to be transformed.
names The names of the response variable(s) or covariate(s).
nind The numbers of individuals to be used. (For plotting, cannot be used simultaneously with ccov.)
expand For intra-class (time-constant) covariates, if TRUE, expand them to give one value per observation rather than one per individual. Only works with repeated objects when all individuals are requested (nind=NULL).
ccov For plotting: If a vector of values for the time-constant covariates is supplied, only individuals having that set of values will have profiles plotted. These values must be in the order in which the covariates appear when the data object is printed. For factor variables, the codes must be given. If the name of a covariate is supplied, a set of graphs is plotted, one for each covariate value, showing profiles of all individuals having that value. (The covariate can have a maximum of six values.) Cannot be used simultaneously with nind.
nest For plotting: nesting category to plot.
add For plotting: add to previous plot.
nindmax For printing a response, tvcov, or repeated object, if the number of individuals is greater than nindmax, the range of numbers of observations per individual is printed instead of the vector of numbers.


These methods extract information stored in response, tccov, tvcov, and repeated data objects created respectively by restovec, tcctomat, tvctomat, and rmna.
Note that if a vector of binomial totals or a censoring indicator is present, this is extract as the second column of the matrix produced by the response method.


J.K. Lindsey

See Also

restovec, rmna, tcctomat, tvctomat.


# set up some data and create the objects
y <- matrix(rnorm(20),ncol=5)
tt <- c(1,3,6,10,15)
print(resp <- restovec(y, times=tt, units="m", type="duration"))
x <- c(0,0,1,1)
x2 <- as.factor(c("a","b","a","b"))
tcc <- tcctomat(data.frame(x=x,x2=x2))
z <- matrix(rpois(20,5),ncol=5)
tvc <- tvctomat(z)
print(reps <- rmna(resp, tvcov=tvc, ccov=tcc))
plot(reps, nind=1:2)
plot(reps, ccov=c(0,1))
plot(reps, ccov="x2")
plot(reps, name="z", nind=3:4, pch=1:2)
plot(reps, name="z", ccov="x2")
response(transform(resp, y=1/y))
response(reps, nind=2:3)
delta(transform(reps,y=1/y), nind=3)
covariates(tcc, nind=2:3)
covariates(tvc, nind=3)
covariates(reps, nind=3)
# because individuals are the only nesting, this is the same as
# use in glm
glm(y~x+z, data=reps)

[Package rmutil version 1.0 Index]