# NOT RUN {
## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
library(tableeasy)
data(pbc)
## Check variables
head(pbc)
##The censored data is not discussed here
pbc_full <- subset(pbc,status!=0)
pbc_full$status <- pbc_full$status-1
## Make categorical variables factors
varsToFactor <- c('status','trt','ascites','hepato','spiders','edema','stage','sex')
pbc_full[varsToFactor] <- lapply(pbc_full[varsToFactor], factor)
## Moderator variables
adj_pbc <- c('age','alk.phos','ast')
## General linear regression:
table2(x = 'albumin', y = 'bili',
adj = c(), data = pbc_full,
div = list(5,c(2,3)), div_num = list(c(3.2,4)),
ref = c(2,1), ref_num = c(2),
outformat = 2)
## Logistic regression:
table2(x ='albumin', y = 'status',
adj = adj_pbc, data = pbc_full,
div = list(5,c(2,3)),
method ='logistic')
## Conditional logistic regression:
table2(x = 'albumin', y = 'status', strata = 'trt',
adj = adj_pbc, data = pbc_full,
div = list(5,c(2,3)),
method = 'con_logistic')
## Cox proportional hazards regression:
table2(x = 'albumin', y = 'status', y_time = 'time',
adj = adj_pbc, data = pbc_full,
div = list(5,c(2,3)),
method = 'cox')
# }
Run the code above in your browser using DataLab