rancov: Function to extract the estimated covariance matrices for the...

Description Usage Arguments Value See Also Examples

View source: R/rancov.R

Description

A function to allow the random effects covariance matrix for a particular level of random effects specified in the sub-model to be extracted from the jointmeta1 model fit.

Usage

1
rancov(fitted, type = c("individual", "study"))

Arguments

fitted

a jointmeta1.object

type

a character string indicating what level the random effects covariance matrix should be returned for. If the individual level random effects covariance matrix is required then type = "individual". If the study level random effects covariance matrix is required then type = "study". Note that if study level random effects are not included in the model, then attempting to extract them will result in an error message.

Value

a matrix of dimensions equal to the number of random effects at the level specified by the type parameter.

See Also

jointmeta1, jointmeta1.object

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
   #change example data to jointdata object
   jointdat2<-tojointdata(longitudinal = simdat2$longitudinal,
   survival = simdat2$survival, id = 'id',longoutcome = 'Y',
   timevarying = c('time','ltime'),
   survtime = 'survtime', cens = 'cens',time = 'time')

   #set variables to factors
   jointdat2$baseline$study <- as.factor(jointdat2$baseline$study)
   jointdat2$baseline$treat <- as.factor(jointdat2$baseline$treat)

   #fit multi-study joint model
   #note: for demonstration purposes only - max.it restricted to 5
   #model would need more iterations to truely converge
   onestagefit<-jointmeta1(data = jointdat2, long.formula = Y ~ 1 + time +
                           + treat + study, long.rand.ind = c('int', 'time'),
                           long.rand.stud = c('treat'),
                           sharingstrct = 'randprop',
                           surv.formula = Surv(survtime, cens) ~ treat,
                           study.name = 'study', strat = TRUE, max.it=5)

    #extract the individual level random effects covariance matrix
    rancov(onestagefit, type = "individual")

    #extract the study level random effects covariance matrix
    rancov(onestagefit, type = "study")

mesudell/joineRmeta documentation built on Jan. 24, 2020, 6:06 p.m.