inst/doc/blupsurvExample.R

### R code from vignette source 'blupsurvExample.Rnw'

###################################################
### code chunk number 1: foo
###################################################
options(keep.source = TRUE, width = 90)
foo <- packageDescription("blupsurv")


###################################################
### code chunk number 2: load-package
###################################################
library(blupsurv)
data(vigndata)


###################################################
### code chunk number 3: show-data
###################################################
vigndata[1:20,]


###################################################
### code chunk number 4: quickfit (eval = FALSE)
###################################################
## vigndata.quickfit <- bivrec( Surv2(start,stop,pain,fever) ~ age + sex + 
## cluster(state) + id(patientID), data=vigndata, K1=10, K2=10, verbose=0)


###################################################
### code chunk number 5: quickfit-summary
###################################################
summary(vigndata.quickfit)


###################################################
### code chunk number 6: fitplottoo
###################################################
plot(vigndata.quickfit)


###################################################
### code chunk number 7: fitplot
###################################################
plot(vigndata.quickfit)


###################################################
### code chunk number 8: quickfit2 (eval = FALSE)
###################################################
## vigndata.quickfit2 <- bivrec(Surv2(start,stop,pain,fever) ~ age + sex +  
## cluster(state) + id(patientID), K1=10, K2=10, excludevars1="age", data=vigndata, verbose=0)


###################################################
### code chunk number 9: quickfit2sum
###################################################
summary(vigndata.quickfit2)


###################################################
### code chunk number 10: finalfit (eval = FALSE)
###################################################
## vigndata.fit <- bivrec(Surv2(start,stop,pain,fever) ~ age + sex + cluster(state) + 
## id(patientID), K1=1, K2=1, excludevars1="age", data=vigndata, verbose=0)


###################################################
### code chunk number 11: finalfitsum
###################################################
summary(vigndata.fit)


###################################################
### code chunk number 12: fitfullplottoo
###################################################
plot(vigndata.fit)


###################################################
### code chunk number 13: fitfullplot
###################################################
plot(vigndata.fit)


###################################################
### code chunk number 14: boxplottoo
###################################################
Ji<-table(substr(names(vigndata.fit$frailty$subj1),1,2))
groups=rep(names(Ji),Ji)
par(mfrow=c(2,1))
title<-"Subject-level frailties, by cluster"
p<-boxplot(vigndata.fit$frailty$subj1 ~ groups, 
main=paste(title,"(pain)"), cex.main=2)
mtext(side = 1, p$names, at= 1:50, line = 1,cex=1)
p<-boxplot(vigndata.fit$frailty$subj2 ~ groups, 
main=paste(title,"(fever)"), cex.main=2)
mtext(side = 1, p$names, at= 1:50, line = 1,cex=1)


###################################################
### code chunk number 15: boxplot
###################################################
Ji<-table(substr(names(vigndata.fit$frailty$subj1),1,2))
groups=rep(names(Ji),Ji)
par(mfrow=c(2,1))
p<-boxplot(vigndata.fit$frailty$subj1 ~ groups, main="Subject-level frailties, by cluster (pain)", cex.main=2)
mtext(side = 1, p$names, at= 1:50, line = 1,cex=1)
p<-boxplot(vigndata.fit$frailty$subj2 ~ groups, main="Subject-level frailties, by cluster (fever)", cex.main=2)
mtext(side = 1, p$names, at= 1:50, line = 1,cex=1)


###################################################
### code chunk number 16: frailplottoo
###################################################
plot(vigndata.fit$frailty$subj1,vigndata.fit$frailty$subj2,xlab="pain",ylab="fever",
main="Subject-level frailties",pch=19, asp=1,xlim=c(0,3),ylim=c(0,3) )


###################################################
### code chunk number 17: frailplot
###################################################
plot(vigndata.fit$frailty$subj1,vigndata.fit$frailty$subj2,xlab="pain",ylab="fever",
main="Subject-level frailties",pch=19, asp=1,xlim=c(0,3),ylim=c(0,3) )

Try the blupsurv package in your browser

Any scripts or data that you put into this service are public.

blupsurv documentation built on May 2, 2019, 6:51 p.m.