This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
summary(jointFit1) | |
str(fitLME) | |
par(mfrow = c(4,4)) | |
traceplot(jointFit1) | |
ggtraceplot(jointFit1, "alphas") | |
ggdensityplot(jointFit1, "alphas") | |
gelman_diag(jointFit1, "alphas") | |
densplot(jointFit1, "alphas") | |
cumuplot(jointFit1, "alphas") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fitLME <- lme(Severity ~ ns(time,3), | |
random = ~ time | Patientnr, | |
data=try2, | |
control=lmeControl(maxIter = 10000), | |
na.action=na.exclude) | |
fitSURV<-coxph(Surv(SurvTimeWeek, Event) ~ 1, | |
data = pancreas2, x = TRUE, | |
na.action=na.exclude, | |
cluster = Patientnr) | |
jointFit1 <- jm(fitSURV, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try2<-total%>%dplyr::filter(!Patientnr%in%8 & !Patientnr%in%20) | |
try2$meds <- c(0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0) | |
try2$RT <- recode(try2$Total_dose_spec, "1:2=1; 3=2") | |
table(try2$RT) | |
class(try2$RT) | |
fitLME <- lme(Severity ~ ns(time,3) + | |
Gender + | |
NRS_WorstPain_at_consultation + | |
Age_at_consultation + | |
Opioid_spec + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Linearity assumption | |
resMart<-residuals(fitSURV, type="martingale") | |
plot(pancreas2$NRS_WorstPain_at_consultation, resMart, main="Martingale residuals for Pain", ylab="Residuals", xlab="Ca4"); lines(loess.smooth(pancreas2$NRS_WorstPain_at_consultation, resMart), lwd=2, col="blue"); abline(h=0, col="red", lty=2, lwd=1.5) | |
plot(pancreas2$Age_at_consultation, resMart, main="Martingale residuals for Age", ylab="Residuals", xlab="Ca4"); lines(loess.smooth(pancreas2$Age_at_consultation, resMart), lwd=2, col="blue"); abline(h=0, col="red", lty=2, lwd=1.5) | |
## Influential observations | |
dfbetas<-residuals(fitSURV, type="dfbetas") | |
par(mfrow=c(4,3)) | |
plot(dfbetas[,1], type='h', main="dfBETAS for GenderMale", ylab="DfBETAS", lwd=2);abline(h=c(2/sqrt(dim(dfbetas)[1]),-(2/sqrt(dim(dfbetas)[1]))),lty=2, col="red") | |
plot(dfbetas[,2], type='h', main="dfBETAS for NRS Worst Pain", ylab="DfBETAS", lwd=2);abline(h=c(2/sqrt(dim(dfbetas)[1]),-(2/sqrt(dim(dfbetas)[1]))),lty=2, col="red") | |
plot(dfbetas[,3], type='h', main="dfBETAS fo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log-log plot for categorized predictor | |
KM_Surv <-with(pancreas2, Surv(SurvTime,Event==1)) | |
KM_by_Tumorsite <-npsurv(KM_Surv~Tumorsite_in_pancreas, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
KM_by_DiseaseStage <-npsurv(KM_Surv~Disease_stage_at_consultation, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
KM_by_Gender <-npsurv(KM_Surv~Gender, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
KM_by_Non_Opioid <-npsurv(KM_Surv~Non_opioid_spec, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
KM_by_Opioid <-npsurv(KM_Surv~Opioid_spec, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
KM_by_Surgery <-npsurv(KM_Surv~Surgery_prior_to_consultation, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
KM_by_TotalDose <-npsurv(KM_Surv~RT, data=pancreas2, type="kaplan-meier", conf.type="log-log") | |
par(mfrow=c(4,2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHassump <- cox.zph(fitSURV) | |
PHassump | |
par(mfrow=c(5,2)) | |
plot(PHassump[1], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for Gender"); abline(h=0, lty=2, lwd=1.5, col="red") | |
plot(PHassump[2], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for NRS"); abline(h=0, lty=2, lwd=1.5, col="red") | |
plot(PHassump[3], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for Disease Stage"); abline(h=0, lty=2, lwd=1.5, col="red") | |
plot(PHassump[4], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for Age"); abline(h=0, lty=2, lwd=1.5, col="red") | |
plot(PHassump[5], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for Tumorsite"); abline(h=0, lty=2, lwd=1.5, col="red") | |
plot(PHassump[6], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for Non-Opioid"); abline(h=0, lty=2, lwd=1.5, col="red") | |
plot(PHassump[7], xlab="Time", ylab="Residual", main="Schoenfeld residuals (scaled) for Opioid"); abline(h=0, lty=2, lwd=1.5, col="red") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pancreas2<-pancreas%>%dplyr::filter(!Patientnr%in%8 & !Patientnr%in%20) | |
pancreas2$meds <- c(0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0) | |
pancreas2$RT <- car::recode(pancreas2$Total_dose_spec, "1:2=1; 3=2") | |
table(pancreas2$RT) | |
class(pancreas2$RT) | |
fitSURV<-coxph(Surv(SurvTimeWeek, Event) ~ | |
Gender+ | |
NRS_WorstPain_at_consultation+ | |
Disease_stage_at_consultation+ | |
Age_at_consultation+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vis_miss(total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38)]) | |
gg_miss_upset(total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38)]) | |
gg_miss_upset(total) | |
n_var_miss(total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38)]) | |
gg_miss_var(total) | |
gg_miss_var(total,show_pct = TRUE) | |
gg_miss_var(total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38,79)],show_pct = TRUE, facet=timef) | |
gg_miss_case(total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38,79)],show_pct = TRUE, facet=timef) | |
gg_miss_case(total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38,49)],show_pct = TRUE, facet=Disease_stage_at_consultation) | |
gg_miss_fct(x=total[,c(3,6,9,12,15,19,20,23,26,29,32,35,38,79)], fct = timef) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
histogram(~ SurvTimeWeek | is.na(Physical_Functioning), data = total) | |
histogram(~ Emotional_Functioning | is.na(Physical_Functioning), data = total) | |
histogram(~ SurvTimeWeek | timef*is.na(Interference), data = total,type = "density", | |
panel = function(x, ...) { | |
panel.histogram(x, ...) | |
panel.mathdensity(dmath = dnorm, col = "black", | |
args = list(mean=mean(x),sd=sd(x))) | |
} ) | |
histogram(~ Severity | timef*is.na(Relief), data = total) | |
histogram(~ Severity | timef*is.na(Pain), data = total) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ggplot(total,aes(x = Relief,y = Severity)) + geom_miss_point() + facet_wrap(~timef) + theme_bw() # not sure this helps, a lof missings deletes already | |
ggplot(total,aes(x = Age_at_consultation,y = Overall_QOL)) + geom_miss_point() + facet_wrap(~Disease_stage_at_consultation)+theme_bw() | |
ggplot(total,aes(x = Severity,y = Overall_QOL)) + geom_miss_point() + theme_bw() |
NewerOlder