Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created November 10, 2022 13:41
Show Gist options
  • Save MJacobs1985/fe1d89d573f6f4581c9d534daf49c1a8 to your computer and use it in GitHub Desktop.
Save MJacobs1985/fe1d89d573f6f4581c9d534daf49c1a8 to your computer and use it in GitHub Desktop.
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 +
Total_dose_spec,
random = ~ time | Patientnr,
data=try2,
control=lmeControl(maxIter = 10000),
na.action=na.exclude)
## Check assumptions
plot(fitLME)
qqnorm(fitLME)
plot(fitLME, Gender ~ resid(.), abline = 0 )
plot(fitLME, NRS_WorstPain_at_consultation ~ resid(.), abline = 0 )
plot(fitLME, Age_at_consultation ~ resid(.), abline = 0 )
plot(fitLME, as.factor(Patientnr) ~ resid(.), abline = 0 )
plot(fitLME, as.factor(Surgery_prior_to_consultation) ~ resid(.), abline = 0 )
plot(fitLME, as.factor(Disease_stage_at_consultation) ~ resid(.), abline = 0 )
plot(fitLME, as.factor(Tumorsite_in_pancreas) ~ resid(.), abline = 0 )
plot(fitLME, as.factor(Non_opioid_spec) ~ resid(.), abline = 0 )
plot(fitLME, as.factor(Opioid_spec) ~ resid(.), abline = 0 )
plot(fitLME, as.factor(RT) ~ resid(.), abline = 0 )
coef(fitLME) #BELANDRIJK! ALLE INTERCEPTS PER PATIENT!
pairs(fitLME)
summary(fitLME)
plot_model(fitLME, grid=T, sort.est="sort.all", y.offset=1.0) # Plot showing coefficients and their confidence interval
plot_model(fitLME, grid=T, type="diag") # Diagnostics plots
plot_model(fitLME, type="eff")
plot_model(fitLME, show.values = TRUE, value.offset = .3)
plot_model(fitLME, type="re") ##!!ERROR
plot_model(fitLME, type="std")
plot_model(fitLME, type="slope")
plot_model(fitLME, type="resid") ##!!ERROR
plot_model(fitLME, type="pred", grid=T, terms=c("time [all]")) ##!! ALLEEN MET TIME WERKT!!
plot_model(fitLME, type="pred", pred.type = "re", grid=T, terms=c("time [all]")) ##!!ERROR
plot_model(fitLME, type="pred", show.data = TRUE, pred.type = "fe", grid=T, terms=c("time [all]")) ##!! ALLEEN MET TIME WERKT!!
tab_model(fitLME, #BELANGRIJK!!!!!!!
show.std=T,
show.r2=T,
show.aic=T,
show.aicc = T,
show.dev=T,
show.re.var=T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment