Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#time to set up model and then evaluate
compMAR.mod <- glm(PCHGCA1N ~ SEXN + TRTPN, family=binomial, data=compMAR.dat)
compMAR.dat$phat.cmpl <- compMAR.mod$fitted.values
summary(compMAR.mod)
#check predictive power
roc(compMAR.dat$PCHGCA1N, fitted(compMAR.mod), plot=TRUE, legacy.axes=TRUE, print.auc=TRUE)
#pretty decent AUC value = C-statistic -- decent predictive power
#so with an AUC of .712, we have somewhat acceptable discrimination
#let's look at deviance residuals
devres <- residuals(compMAR.mod,"deviance")
plot(compMAR.dat$phat.cmpl, devres, main = "Deviance Residual Plot", xlab= "Estimated Probability", ylab="Deviance Residuals")
abline(h=c(-2,2))
#many repeat cases? so should look at another measure to evaluate model fit
#we have quite a few repeat cases as we only have a few levels so we can use the
#Deviance GoF test to check calibration
#check model fit and assess calibration
devdif.po <- compMAR.mod$null.deviance - compMAR.mod$deviance
df.po <- 3 - 1 #p1-p0 = (2+1)-(0+1)
pval.po <- pchisq(devdif.po, df.po, ncp=0, lower.tail = FALSE, log.p = FALSE)
cbind(devdif.po,df.po,pval.po)
#we reject null and conclude that the model does NOT fit the data well
#logistic response function is NOT appropriate for this dataset
#IMPUTED AS NON-RESPONDER
#create imputed dataset
impMAR.dat <- MARdata.respdat
i <- 1
for(i in 1:length(impMAR.dat$USUBJID)){
if(is.na(MARdata.respdat$AVAL[i])==TRUE){
impMAR.dat$PCHGCA1N[i] <- 0
i <- i+1
}
}
#time to set up model and then evaluate
impMAR.mod <- glm(PCHGCA1N ~ SEXN + TRTPN, family=binomial, data=impMAR.dat)
impMAR.dat$phat.imp <- impMAR.mod$fitted.values
summary(impMAR.mod)
#check predictive power
roc(impMAR.dat$PCHGCA1N, fitted(impMAR.mod), plot=TRUE, legacy.axes=TRUE, print.auc=TRUE)
#pretty decent AUC value = C-statistic -- decent predictive power
#so with an AUC of .721, we have acceptable discrimination -- BETTER THAN COMPLETER
#let's look at deviance residuals
devres <- residuals(impMAR.mod,"deviance")
plot(impMAR.dat$phat.imp, devres, main = "Deviance Residual Plot", xlab= "Estimated Probability", ylab="Deviance Residuals")
abline(h=c(-2,2))
#many repeat cases? so should look at another measure to evaluate model fit
#we have quite a few repeat cases as we only have a few levels so we can use the
#Deviance GoF test to check calibration
#check model fit and assess calibration
devdif.po <- impMAR.mod$null.deviance - impMAR.mod$deviance
df.po <- 3 - 1 #p1-p0 = (2+1)-(0+1)
pval.po <- pchisq(devdif.po, df.po, ncp=0, lower.tail = FALSE, log.p = FALSE)
cbind(devdif.po,df.po,pval.po)
#we reject null and conclude that the model does NOT fit the data well
#logistic response function is NOT appropriate for this dataset
#to get a feel for how the predicted probabilities look based on the model
library(ggplot2)
ggplot() +
geom_freqpoly(data=ogADPAS.respdat, aes(x=phat.comp), color="chartreuse") +
geom_freqpoly(data=compMCAR10.dat, aes(x=phat.10cmpl), color="coral") +
geom_freqpoly(data=impMCAR10.dat, aes(x=phat.10imp), color="darkorchid") +
theme_classic()
ggplot() +
geom_point(data=ogADPAS.respdat, aes(x=phat.comp, y=TRTPN, shape=SEXN), color="chartreuse") +
geom_point(data=compMCAR10.dat, aes(x=phat.10cmpl, y=TRTPN, shape=SEXN), color="coral") +
geom_point(data=impMCAR10.dat, aes(x=phat.10imp, y=TRTPN, shape=SEXN), color="darkorchid") +
theme_classic()
ggplot() +
geom_line(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, group=SEXN, linetype=SEXN), color="chartreuse") + #whole data
geom_line(data=compMCAR10.dat, aes(x=TRTPN, y=phat.10cmpl, group=SEXN, linetype=SEXN), color="coral") + #completer data
geom_line(data=impMCAR10.dat, aes(x=TRTPN, y=phat.10imp, group=SEXN, linetype=SEXN), color="darkorchid") + #imputed as non-responder data
theme_classic()
library(ggplot2)
ggplot()+
scale_fill_brewer(palette="Dark2")+
geom_bar(data=ogADPAS.respdat, aes(x=TRTPN, fill=SEXN), position="dodge", color="black") +
geom_bar(data=compMCAR10.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "limegreen") +
#geom_bar(data=impMCAR10.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "limegreen") +
geom_bar(data=compMCAR20.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "blue") +
#geom_bar(data=impMCAR20.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "blue") +
geom_bar(data=compMCAR30.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "mediumorchid") +
#geom_bar(data=impMCAR30.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "mediumorchid") +
geom_bar(data=compMAR.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "red") +
#geom_bar(data=impMAR.dat, aes(x=TRTPN, fill=SEXN), position = "dodge", color = "red")
theme_classic()
ggplot() +
geom_freqpoly(data=ogADPAS.respdat, aes(x=TRTPN, color = SEXN), stat="count") +
geom_freqpoly(data=compMCAR10.dat, aes(x=phat.10cmpl), color="coral") +
geom_freqpoly(data=impMCAR10.dat, aes(x=phat.10imp), color="darkorchid") +
theme_classic()
#FEMALE GRAPH
ggplot() +
scale_fill_brewer(palette="Set2")+
geom_bar(data=subset(ogADPAS.respdat, ogADPAS.respdat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="black") + #whole data
geom_bar(data=subset(compMAR.dat, compMAR.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="red") + #completer data
geom_bar(data=subset(impMAR.dat, impMAR.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="red", linetype="dotted") + #imputed as non-responder data
geom_bar(data=subset(compMCAR10.dat, compMCAR10.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="limegreen") + #completer data
geom_bar(data=subset(impMCAR10.dat, impMCAR10.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="limegreen", linetype="dotted") + #imputed as non-responder data
geom_bar(data=subset(compMCAR20.dat, compMCAR20.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="blue") + #completer data
geom_bar(data=subset(impMCAR20.dat, impMCAR20.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="blue", linetype="dotted") + #imputed as non-responder data
geom_bar(data=subset(compMCAR30.dat, compMCAR30.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="mediumorchid") + #completer data
geom_bar(data=subset(impMCAR30.dat, impMCAR30.dat$SEXN == 2), aes(x=TRTPN, fill=PCHGCA1N), position="dodge", color="mediumorchid", linetype="dotted") + #imputed as non-responder data
theme_classic()
tab1 <- as.data.frame(table(ogADPAS.respdat$PCHGCA1N, ogADPAS.respdat$TRTPN, ogADPAS.respdat$SEXN))
#PCHGCA1N: 0, non-responder; 1, responder TRTPN: 1, placebo; 2 active control (ustek);
#3, 140mg test; 4, 210 test SEXN: 1, male; 2, female, 3, unknown (no 3s appear)
tab2 <- as.data.frame(table(compMCAR10.dat$PCHGCA1N, compMCAR10.dat$TRTPN, compMCAR10.dat$SEXN))
tab3 <- as.data.frame(table(impMCAR10.dat$PCHGCA1N, impMCAR10.dat$TRTPN, impMCAR10.dat$SEXN))
tab4 <- as.data.frame(table(compMCAR20.dat$PCHGCA1N, compMCAR20.dat$TRTPN, compMCAR20.dat$SEXN))
tab5 <- as.data.frame(table(impMCAR20.dat$PCHGCA1N, impMCAR20.dat$TRTPN, impMCAR20.dat$SEXN))
tab6 <- as.data.frame(table(compMCAR30.dat$PCHGCA1N, compMCAR30.dat$TRTPN, compMCAR30.dat$SEXN))
tab7 <- as.data.frame(table(impMCAR30.dat$PCHGCA1N, impMCAR30.dat$TRTPN, impMCAR30.dat$SEXN))
tab8 <- as.data.frame(table(compMAR.dat$PCHGCA1N, compMAR.dat$TRTPN, compMAR.dat$SEXN))
tab9 <- (table(impMAR.dat$PCHGCA1N, impMAR.dat$TRTPN, impMAR.dat$SEXN))
plot(tab1) #will figure out graphs later
#FEMALE GRAPH
ggplot() +
geom_line(data=subset(ogADPAS.respdat, ogADPAS.respdat$SEXN == 2), aes(x=TRTPN, y=phat.comp, group=1), color="black") + #whole data
geom_line(data=subset(compMAR.dat, compMAR.dat$SEXN == 2), aes(x=TRTPN, y=phat.cmpl, group=1), color="red") + #completer data
geom_line(data=subset(impMAR.dat, impMAR.dat$SEXN == 2), aes(x=TRTPN, y=phat.imp, group=1), color="red", linetype="dotted") + #imputed as non-responder data
geom_line(data=subset(compMCAR10.dat, compMCAR10.dat$SEXN == 2), aes(x=TRTPN, y=phat.10cmpl, group=1), color="limegreen") + #completer data
geom_line(data=subset(impMCAR10.dat, impMCAR10.dat$SEXN == 2), aes(x=TRTPN, y=phat.10imp, group=1), color="limegreen", linetype="dotted") + #imputed as non-responder data
geom_line(data=subset(compMCAR20.dat, compMCAR20.dat$SEXN == 2), aes(x=TRTPN, y=phat.20cmpl, group=1), color="blue") + #completer data
geom_line(data=subset(impMCAR20.dat, impMCAR20.dat$SEXN == 2), aes(x=TRTPN, y=phat.20imp, group=1), color="blue", linetype="dotted") + #imputed as non-responder data
geom_line(data=subset(compMCAR30.dat, compMCAR30.dat$SEXN == 2), aes(x=TRTPN, y=phat.30cmpl, group=1), color="mediumorchid") + #completer data
geom_line(data=subset(impMCAR30.dat, impMCAR30.dat$SEXN == 2), aes(x=TRTPN, y=phat.30imp, group=1), color="mediumorchid", linetype="dotted") + #imputed as non-responder data
labs(title = "Predicted Probability of Response for Females", x="Treatment Group", y = "Predicted Probability")+
scale_x_discrete(labels=c("1"="Placebo", "2"="Active Control", "3"= "140mg Drug X", "4"= "210mg Drug X")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#MALE GRAPH
ggplot() +
geom_line(data=subset(ogADPAS.respdat, ogADPAS.respdat$SEXN == 1), aes(x=TRTPN, y=phat.comp, group=1), color="black") + #whole data
geom_line(data=subset(compMAR.dat, compMAR.dat$SEXN == 1), aes(x=TRTPN, y=phat.cmpl, group=1), color="red") + #completer data
geom_line(data=subset(impMAR.dat, impMAR.dat$SEXN == 1), aes(x=TRTPN, y=phat.imp, group=1), color="red", linetype="dotted") + #imputed as non-responder data
geom_line(data=subset(compMCAR10.dat, compMCAR10.dat$SEXN == 1), aes(x=TRTPN, y=phat.10cmpl, group=1), color="limegreen") + #completer data
geom_line(data=subset(impMCAR10.dat, impMCAR10.dat$SEXN == 1), aes(x=TRTPN, y=phat.10imp, group=1), color="limegreen", linetype="dotted") + #imputed as non-responder data
geom_line(data=subset(compMCAR20.dat, compMCAR20.dat$SEXN == 1), aes(x=TRTPN, y=phat.20cmpl, group=1), color="blue") + #completer data
geom_line(data=subset(impMCAR20.dat, impMCAR20.dat$SEXN == 1), aes(x=TRTPN, y=phat.20imp, group=1), color="blue", linetype="dotted") + #imputed as non-responder data
geom_line(data=subset(compMCAR30.dat, compMCAR30.dat$SEXN == 1), aes(x=TRTPN, y=phat.30cmpl, group=1), color="mediumorchid") + #completer data
geom_line(data=subset(impMCAR30.dat, impMCAR30.dat$SEXN == 1), aes(x=TRTPN, y=phat.30imp, group=1), color="mediumorchid", linetype="dotted") + #imputed as non-responder data
labs(title = "Predicted Probability of Response for Males", x="Treatment Group", y = "Predicted Probability")+
scale_x_discrete(labels=c("1"="Placebo", "2"="Active Control", "3"= "140mg Drug X", "4"= "210mg Drug X")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#ALL INFORMATION
ggplot() +
geom_line(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, group=1), color="black") + #whole data
geom_point(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, shape=SEXN), color="black", size=1) +
geom_line(data=compMAR.dat, aes(x=TRTPN, y=phat.cmpl, group=1), color="red") + #completer data
geom_point(data=compMAR.dat, aes(x=TRTPN, y=phat.cmpl, shape=SEXN), color="red", size=1) +
geom_line(data=impMAR.dat, aes(x=TRTPN, y=phat.imp, group=1), color="red", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMAR.dat, aes(x=TRTPN, y=phat.imp, shape=SEXN), color="red", size=1) +
geom_line(data=compMCAR10.dat, aes(x=TRTPN, y=phat.10cmpl, group=1), color="limegreen") + #completer data
geom_point(data=compMCAR10.dat, aes(x=TRTPN, y=phat.10cmpl, shape=SEXN), color="limegreen", size=1) +
geom_line(data=impMCAR10.dat, aes(x=TRTPN, y=phat.10imp, group=1), color="limegreen", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMCAR10.dat, aes(x=TRTPN, y=phat.10imp, shape=SEXN), color="limegreen", size=1) +
geom_line(data=compMCAR20.dat, aes(x=TRTPN, y=phat.20cmpl, group=1), color="blue") + #completer data
geom_point(data=compMCAR20.dat, aes(x=TRTPN, y=phat.20cmpl, shape=SEXN), color="blue", size=1) +
geom_line(data=impMCAR20.dat, aes(x=TRTPN, y=phat.20imp, group=1), color="blue", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMCAR20.dat, aes(x=TRTPN, y=phat.20imp, shape=SEXN), color="blue", size=1) +
geom_line(data=compMCAR30.dat, aes(x=TRTPN, y=phat.30cmpl, group=1), color="mediumorchid") + #completer data
geom_point(data=compMCAR30.dat, aes(x=TRTPN, y=phat.30cmpl, shape=SEXN), color="mediumorchid", size=1) +
geom_line(data=impMCAR30.dat, aes(x=TRTPN, y=phat.30imp, group=1), color="mediumorchid", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMCAR30.dat, aes(x=TRTPN, y=phat.30imp, shape=SEXN), color="mediumorchid", size=1) +
labs(title = "Predicted Probability of Response by Sex", x="Treatment Group", y = "Predicted Probability", shape = "Sex")+
scale_x_discrete(labels=c("1"="Placebo", "2"="Active Control", "3"= "140mg Drug X", "4"= "210mg Drug X")) +
scale_shape_discrete(labels=c("1"="Male", "2"="Female")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#COMPLETERS
ggplot() +
geom_line(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, group=1), color="black") + #whole data
geom_point(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, shape=SEXN), color="black") +
geom_line(data=compMAR.dat, aes(x=TRTPN, y=phat.cmpl, group=1), color="red") + #completer data
geom_point(data=compMAR.dat, aes(x=TRTPN, y=phat.cmpl, shape=SEXN), color="red") +
geom_line(data=compMCAR10.dat, aes(x=TRTPN, y=phat.10cmpl, group=1), color="limegreen") + #completer data
geom_point(data=compMCAR10.dat, aes(x=TRTPN, y=phat.10cmpl, shape=SEXN), color="limegreen") +
geom_line(data=compMCAR20.dat, aes(x=TRTPN, y=phat.20cmpl, group=1), color="blue") + #completer data
geom_point(data=compMCAR20.dat, aes(x=TRTPN, y=phat.20cmpl, shape=SEXN), color="blue") +
geom_line(data=compMCAR30.dat, aes(x=TRTPN, y=phat.30cmpl, group=1), color="mediumorchid") + #completer data
geom_point(data=compMCAR30.dat, aes(x=TRTPN, y=phat.30cmpl, shape=SEXN), color="mediumorchid") +
labs(title = "Predicted Probability of Response for Completer Data by Sex", x="Treatment Group", y = "Predicted Probability", shape="Sex")+
scale_x_discrete(labels=c("1"="Placebo", "2"="Active Control", "3"= "140mg Drug X", "4"= "210mg Drug X")) +
scale_shape_discrete(labels=c("1"="Male", "2"="Female")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#IMPUTED AS NON-RESP
ggplot() +
geom_line(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, group=1), color="black") + #whole data
geom_point(data=ogADPAS.respdat, aes(x=TRTPN, y=phat.comp, shape=SEXN), color="black") +
geom_line(data=impMAR.dat, aes(x=TRTPN, y=phat.imp, group=1), color="red", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMAR.dat, aes(x=TRTPN, y=phat.imp, shape=SEXN), color="red") +
geom_line(data=impMCAR10.dat, aes(x=TRTPN, y=phat.10imp, group=1), color="limegreen", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMCAR10.dat, aes(x=TRTPN, y=phat.10imp, shape=SEXN), color="limegreen") +
geom_line(data=impMCAR20.dat, aes(x=TRTPN, y=phat.20imp, group=1), color="blue", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMCAR20.dat, aes(x=TRTPN, y=phat.20imp, shape=SEXN), color="blue") +
geom_line(data=impMCAR30.dat, aes(x=TRTPN, y=phat.30imp, group=1), color="mediumorchid", linetype="dotted") + #imputed as non-responder data
geom_point(data=impMCAR30.dat, aes(x=TRTPN, y=phat.30imp, shape=SEXN), color="mediumorchid") +
labs(title = "Predicted Probability of Response for Imputed Data by Sex", x="Treatment Group", y = "Predicted Probability", shape="Sex")+
scale_x_discrete(labels=c("1"="Placebo", "2"="Active Control", "3"= "140mg Drug X", "4"= "210mg Drug X")) +
scale_shape_discrete(labels=c("1"="Male", "2"="Female")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#ODDS RATIOS and confidence intervals
zscore <- qnorm(.98)
ogsum <- summary(OGdata.mod)
c10sum <- summary(compMCAR10.mod)
i10sum <- summary(impMCAR10.mod)
c20sum <- summary(compMCAR20.mod)
i20sum <- summary(impMCAR20.mod)
c30sum <- summary(compMCAR30.mod)
i30sum <- summary(impMCAR30.mod)
cMARsum <- summary(compMAR.mod)
iMARsum <- summary(impMAR.mod)
#create rows of data: estimate, std error
FullData <- c(ogsum$coefficients[,1], ogsum$coefficients[,2])
c10MCAR <- c(c10sum$coefficients[,1], c10sum$coefficients[,2])
i10MCAR <- c(i10sum$coefficients[,1], i10sum$coefficients[,2])
c20MCAR <- c(c20sum$coefficients[,1], c20sum$coefficients[,2])
i20MCAR <- c(i20sum$coefficients[,1], i20sum$coefficients[,2])
c30MCAR <- c(c30sum$coefficients[,1], c30sum$coefficients[,2])
i30MCAR <- c(i30sum$coefficients[,1], i30sum$coefficients[,2])
cMAR <- c(cMARsum$coefficients[,1], cMARsum$coefficients[,2])
iMAR <- c(iMARsum$coefficients[,1], iMARsum$coefficients[,2])
datanamesN <- c(1,2,3,4,5,6,7,8,9)
table <- rbind(FullData, c10MCAR, i10MCAR, c20MCAR, i20MCAR, c30MCAR, i30MCAR, cMAR, iMAR)
table <- cbind(datanamesN, table)
table <- as.data.frame(table)
#where Lo=140mg, Hi=210mg
names(table) <- c("dataset", "intEst", "femEst", "acEst", "LoEst", "HiEst","intSE", "femSE", "acSE", "LoSE", "HiSE")
table$zscore <- rep(zscore,9)
#Female vs Male OR
ggplot(table, aes(x=exp(femEst), y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=exp(femEst + (zscore*femSE)), xmin = exp(femEst - (zscore*femSE)))) +
labs(title = "Female vs Male OR Estimates", x="OR", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Active Control vs Placebo OR
ggplot(table, aes(x=exp(acEst), y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=exp(acEst + (zscore*acSE)), xmin = exp(acEst - (zscore*acSE))))+
labs(title = "Active vs Placebo OR Estimates", x="OR", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#140mg vs Placebo OR
ggplot(table, aes(x=exp(LoEst), y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=exp(LoEst + (zscore*LoSE)), xmin = exp(LoEst - (zscore*LoSE))))+
labs(title = "140mg vs Placebo OR Estimates", x="OR", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#210mg vs Placebo OR
ggplot(table, aes(x=exp(HiEst), y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=exp(HiEst + (zscore*HiSE)), xmin = exp(HiEst - (zscore*HiSE))))+
labs(title = "210mg vs Placebo OR Estimates", x="OR", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
library(ggplot2)
#first: intercept
ggplot(table, aes(x=intEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
labs(title = "Intercept Estimates", x="Intercept Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
table(ogADPAS.respdat$PCHGCA1N, ogADPAS.respdat$TRTPN, ogADPAS.respdat$SEXN)
#PCHGCA1N: 0, non-responder; 1, responder TRTPN: 1, placebo; 2 active control (ustek);
#3, 140mg test; 4, 210 test SEXN: 1, male; 2, female, 3, unknown (no 3s appear)
table(compMCAR10.dat$PCHGCA1N, compMCAR10.dat$TRTPN, compMCAR10.dat$SEXN)
table(impMCAR10.dat$PCHGCA1N, impMCAR10.dat$TRTPN, impMCAR10.dat$SEXN)
library(ggplot2)
#first: intercept, b0
ggplot(table, aes(x=intEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
labs(title = "Intercept Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Female b2
ggplot(table, aes(x=femEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
labs(title = "Female Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Active Control b3
ggplot(table, aes(x=acEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
labs(title = "Active Control Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#140mg b4
ggplot(table, aes(x=LoEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=LoEst + (zscore*LoSE), xmin = LoEst - (zscore*LoSE)))+
labs(title = "140mg Drug X Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#210mg b5
ggplot(table, aes(x=HiEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=HiEst + (zscore*HiSE), xmin = HiEst - (zscore*HiSE)))+
labs(title = "210mg Drug X Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Female b2
ggplot(table, aes(x=femEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
labs(title = "Female Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))+
#Active Control b3
ggplot(table, aes(x=acEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
labs(title = "Active Control Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
ggplot(data=table) +
geom_point(aes(x=intEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
ggplot(data=table) +
geom_point(aes(x=intEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE)))
ggplot() +
geom_point(table, aes(x=intEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE)))
library(ggplot2)
#first: intercept, b0
ggplot(table, aes(x=intEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
labs(title = "Intercept Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Female b2
ggplot(table, aes(x=femEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
labs(title = "Female Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))+
#Active Control b3
ggplot(table, aes(x=acEst, y=as.factor(dataset)))
library(ggplot2)
#first: intercept, b0
ggplot(table, aes(x=intEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
labs(title = "Intercept Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Female b2
ggplot(table, aes(x=femEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
labs(title = "Female Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Active Control b3
ggplot(table, aes(x=acEst, y=as.factor(dataset)))
geom_point() +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
labs(title = "Active Control Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
library(ggplot2)
#first: intercept, b0
ggplot(table, aes(x=intEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
labs(title = "Intercept Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Female b2
ggplot(table, aes(x=femEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
labs(title = "Female Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Active Control b3
ggplot(table, aes(x=acEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
labs(title = "Active Control Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#140mg b4
ggplot(table, aes(x=LoEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=LoEst + (zscore*LoSE), xmin = LoEst - (zscore*LoSE)))+
labs(title = "140mg Drug X Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#210mg b5
ggplot(table, aes(x=HiEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=HiEst + (zscore*HiSE), xmin = HiEst - (zscore*HiSE)))+
labs(title = "210mg Drug X Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
ggplot() +
geom_point(table, aes(x=intEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
geom_point(table, aes(x=femEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
geom_point(table, aes(x=acEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
geom_point(table, aes(x=LoEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=LoEst + (zscore*LoSE), xmin = LoEst - (zscore*LoSE)))+
geom_point(table, aes(x=HiEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=HiEst + (zscore*HiSE), xmin = HiEst - (zscore*HiSE)))+
ggplot() +
geom_point(table, aes(x=intEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
geom_point(table, aes(x=femEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
geom_point(table, aes(x=acEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
geom_point(table, aes(x=LoEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=LoEst + (zscore*LoSE), xmin = LoEst - (zscore*LoSE)))+
geom_point(table, aes(x=HiEst, y=as.factor(dataset))) +
geom_errorbarh(aes(xmax=HiEst + (zscore*HiSE), xmin = HiEst - (zscore*HiSE)))
ggplot() +
geom_point(table, aes(x=intEst, y=as.factor(dataset))) +
geom_errorbarh(table, aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
geom_point(table, aes(x=femEst, y=as.factor(dataset))) +
geom_errorbarh(table,aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
geom_point(table, aes(x=acEst, y=as.factor(dataset))) +
geom_errorbarh(table,aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
geom_point(table, aes(x=LoEst, y=as.factor(dataset))) +
geom_errorbarh(table,aes(xmax=LoEst + (zscore*LoSE), xmin = LoEst - (zscore*LoSE)))+
geom_point(table, aes(x=HiEst, y=as.factor(dataset))) +
geom_errorbarh(table,aes(xmax=HiEst + (zscore*HiSE), xmin = HiEst - (zscore*HiSE)))
library(ggplot2)
#first: intercept, b0
ggplot(table, aes(x=intEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=intEst + (zscore*intSE), xmin = intEst - (zscore*intSE))) +
labs(title = "Intercept Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Female b2
ggplot(table, aes(x=femEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=femEst + (zscore*femSE), xmin = femEst - (zscore*femSE))) +
labs(title = "Female Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#Active Control b3
ggplot(table, aes(x=acEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=acEst + (zscore*acSE), xmin = acEst - (zscore*acSE)))+
labs(title = "Active Control Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#140mg b4
ggplot(table, aes(x=LoEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=LoEst + (zscore*LoSE), xmin = LoEst - (zscore*LoSE)))+
labs(title = "140mg Drug X Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
#210mg b5
ggplot(table, aes(x=HiEst, y=as.factor(dataset))) +
geom_point() +
geom_errorbarh(aes(xmax=HiEst + (zscore*HiSE), xmin = HiEst - (zscore*HiSE)))+
labs(title = "210mg Drug X Coefficient Estimates", x="Estimate Value", y = "Model")+
scale_y_discrete(labels=c("Full Data", "C MCAR10", "I MCAR10", "C MCAR20", "I MCAR20", "C MCAR30", "I MCAR30", "C MAR", "I MAR")) +
theme_classic() +
theme(plot.title=element_text(hjust=0.5))
table.flip <- cbind(FullData, c10MCAR, i10MCAR, c20MCAR, i20MCAR, c30MCAR, i30MCAR, cMAR, iMAR)
table.flip
table.flip <- cbind(FullData, c10MCAR, i10MCAR, c20MCAR, i20MCAR, c30MCAR, i30MCAR, cMAR, iMAR)
table.flip <- cbind(datanamesN, table.flip)
table.flip <- as.data.frame(table.flip)
table.flip
table.flip <- cbind(FullData, c10MCAR, i10MCAR, c20MCAR, i20MCAR, c30MCAR, i30MCAR, cMAR, iMAR)
table.flip <- rbind(datanamesN, table.flip)
table.flip <- as.data.frame(table.flip)
table.flip