lvna: Create a repeated Object, Leaving NAs

Description Usage Arguments Value Author(s) See Also Examples

View source: R/objectrm.r

Description

lvna forms an object of class, repeated, from a response object and possibly time-varying or intra-individual covariate (tvcov), and time-constant or inter-individual covariate (tccov) objects. If there are NAs in any variables, it also creates a logical vector indicating which observations have NAs either in the response or the covariate values. Subjects must be in the same order in all (three) objects to be combined.

Such objects can be printed and plotted. Methods are available for extracting the response, the numbers of observations per individual, the times, the weights, the units of measurement/Jacobian, the nesting variable, the covariates, and their names: response, nobs, times, weights, delta, nesting, covariates, and names.

Usage

1
lvna(response, ccov=NULL, tvcov=NULL)

Arguments

response

An object of class, response (created by restovec), containing the response variable information.

ccov

An object of class, tccov (created by tcctomat), containing the time-constant or inter-individual covariate information.

tvcov

An object of class, tvcov (created by tvctomat), containing the time-varying or intra-individual covariate information.

Value

Returns an object of class, repeated, containing a list of the response object (z$response, so that, for example, the response vector is z$response$y; see restovec), possibly the two classes of covariate objects (z$ccov and z$tvcov; see tcctomat and tvctomat), and a logical vector (z$NAs) indicating which observations have an NA in the response or some covariate.

Author(s)

J.K. Lindsey

See Also

DataMethods, covariates, covind, delta, dftorep, names, nesting, nobs, read.list, read.surv, response, resptype, restovec, rmna, tcctomat, times, transform, tvctomat, units, weights

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
y <- matrix(rnorm(20),ncol=5)
y[2,3] <- NA
tt <- c(1,3,6,10,15)
print(resp <- restovec(y,times=tt))
x <- c(0,0,1,1)
tcc <- tcctomat(x)
z <- matrix(rpois(20,5),ncol=5)
tvc <- tvctomat(z)
print(reps <- lvna(resp, tvcov=tvc, ccov=tcc))
response(reps)
response(reps, nind=2:3)
times(reps)
nobs(reps)
weights(reps)
covariates(reps)
covariates(reps,names="x")
covariates(reps,names="z")
names(reps)
nesting(reps)
# because individuals are the only nesting, this is the same as
covind(reps)
# binomial
y <- matrix(rpois(20,5),ncol=5)
y[2,3] <- NA
print(respb <- restovec(y,totals=y+matrix(rpois(20,5),ncol=5),times=tt))
print(repsb <- lvna(respb, tvcov=tvc, ccov=tcc))
response(repsb)
# censored data
y <- matrix(rweibull(20,2,5),ncol=5)
print(respc <- restovec(y,censor=matrix(rbinom(20,1,0.9),ncol=5),times=tt))
print(repsc <- lvna(respc, tvcov=tvc, ccov=tcc))
# if there is no censoring, censor indicator is not printed
response(repsc)
# nesting clustered within individuals
nest <- c(1,1,2,2,2)
print(respn <- restovec(y,censor=matrix(rbinom(20,1,0.9),ncol=5),
	times=tt,nest=nest))
print(repsn <- lvna(respn, tvcov=tvc, ccov=tcc))
response(respn)
times(respn)
nesting(respn)

rmutil documentation built on May 27, 2018, 5:03 p.m.