Title: | Changing the Reference Group without Re-Running the Model |
---|---|
Description: | To re-calculate the coefficients and the standard deviation when changing the reference group. |
Authors: | Ziqiang Lin, Eugene M Laska, Carole E Siegel, Wangjian Zhang, Qiaoxuan Lin, Bo Ye. |
Maintainer: | Ziqiang Lin <[email protected]> |
License: | GPL-3 |
Version: | 0.0.1 |
Built: | 2024-11-06 06:15:52 UTC |
Source: | CRAN |
To re-calculate the coefficients and the standard deviation when changing the reference group.
rlevel(fit,var,oldrf,newrf,cl=NA)
rlevel(fit,var,oldrf,newrf,cl=NA)
fit |
Fitted model using glm, lm, glmnet or cv.glmnet |
var |
Vector of variable name in the model you plan to change reference |
oldrf |
Vector of old reference group name |
newrf |
Vector of new reference group name |
cl |
Column number of coefficient, only available when using glmnet or cv.glmnet |
Make sure the name of variables, name of old reference, and name of new reference much add quotation marks
New estimation of coefficient with statistics and P value (no statistics and P value for glmnet and cv.glmnet)
# similated data relapse <- rbinom(100,1,0.3) BUP <- c(rep("No",61),rep("Yes",39)) Gender <-sample(c('Male', 'Female'), 100, replace=TRUE) score <-sample(1:10,100,replace=TRUE) model=glm(relapse~BUP+Gender+score,family="binomial") rlevel(model,c("BUP","Gender"),c("No","Female"),c("Yes","Male"))
# similated data relapse <- rbinom(100,1,0.3) BUP <- c(rep("No",61),rep("Yes",39)) Gender <-sample(c('Male', 'Female'), 100, replace=TRUE) score <-sample(1:10,100,replace=TRUE) model=glm(relapse~BUP+Gender+score,family="binomial") rlevel(model,c("BUP","Gender"),c("No","Female"),c("Yes","Male"))