ecif.pred: Excess CIF prediction based on newdata and geepack::geese...

Description Usage Arguments Value Examples

View source: R/matchcif.R

Description

Excess CIF prediction based on newdata and geepack::geese estimates.

Usage

1
2
ecif.pred(model = NULL, times, formula, dataset, strata.levels = NULL,
  coefs = NULL, vcov = NULL, link = "log")

Arguments

model

geese object. To be defined if coefs and vcov are null.

times

vector of timepoints as the one used to estimate the GEE model

formula

model formula

dataset

new data

strata.levels

if CIF predicted for different strata, define strata levels

coefs

coefficient estimates (model$beta). To be specified if model is NULL

vcov

coefficient variance and covariance matrix (model$vbeta). To be specified if model is NULL, together with coefs.

link

link from the gee model

Value

dataset with predicted values; ready to be used with ggplot2

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
dcif<-sim.data.MatchCR(1000,5)
tp<-c(0.5,1,2,5,10,15,25)
setdcif1<-compcomp(timereg::Event(time=FALSE,time2=time,cause=cause)~X1+X2, 
                   data=dcif, cluster=i, idControl=j, time.points=tp,
                   cens.formula=NULL, event=1)
exc.cif.mod1<-geepack::geese(Rt~-1+factor(h)+X1+X2,
                    data=setdcif1,
                    family="gaussian", #error distribution
                    mean.link = "log", #link function for Rt
                    corstr="independence", #correlation structure
                    id=clust.num, #cluster vector
                    weights=weights #censoring weights 
                    )
### prediction: 
af<-paste0("-1+factor(h)+X1+X2") #model formula
newd<-data.frame(expand.grid(h=tp,X1=c(0,1),X2=c(0.8,1.5,2.5))) # newdata
# define the different subjects for whom the excess risk is predicted
strata.levels<-factor(1:6, levels=1:6,
                      labels =paste0(rep("X1=",6),
                      expand.grid(X1=c(0,1),X2=c(0.8,1.5,2.5))[,1], 
                      rep(", X2=",6),
                      expand.grid(X1=c(0,1),X2=c(0.8,1.5,2.5))[,2]))
pred.exc.cif<-ecif.pred(exc.cif.mod1,times = tp,dataset = newd,
                        formula = af, strata.levels = strata.levels)
head(pred.exc.cif,8)

cribosch/matchsurv documentation built on Aug. 15, 2019, 11:55 a.m.