if (FALSE) {
data(sofa)
fit.vd1 <- pfr(death ~ lf.vd(SOFA) + age + los,
family="binomial", data=sofa)
fit.vd2 <- pfr(death ~ lf.vd(SOFA, transform="lagged") + age + los,
family="binomial", data=sofa)
fit.vd3 <- pfr(death ~ lf.vd(SOFA, transform="standardized") + age + los,
family="binomial", data=sofa)
fit.vd4 <- pfr(death ~ lf.vd(SOFA, transform="standardized",
basistype="te") + age + los,
family="binomial", data=sofa)
fit.vd5 <- pfr(death ~ lf.vd(SOFA, transform="linear", bs="ps") + age + los,
family="binomial", data=sofa)
fit.vd6 <- pfr(death ~ lf.vd(SOFA, transform="quadratic", bs="ps") + age + los,
family="binomial", data=sofa)
fit.vd7 <- pfr(death ~ lf.vd(SOFA, transform="noInteraction", bs="ps") + age + los,
family="binomial", data=sofa)
ests <- lapply(1:7, function(i) {
c.i <- coef(get(paste0("fit.vd", i)), n=173, n2=173)
c.i[(c.i$SOFA.arg <= c.i$SOFA.vd),]
})
# Try plotting for each i
i <- 1
lims <- c(-2,8)
if (requireNamespace("ggplot2", quietly = TRUE) &
requireNamespace("RColorBrewer", quietly = TRUE)) {
est <- ests[[i]]
est$value[est$valuelims[2]] <- lims[2]
ggplot2::ggplot(est, ggplot2::aes(SOFA.arg, SOFA.vd)) +
ggplot2::geom_tile(ggplot2::aes(colour=value, fill=value)) +
ggplot2::scale_fill_gradientn( name="", limits=lims,
colours=rev(RColorBrewer::brewer.pal(11,"Spectral"))) +
ggplot2::scale_colour_gradientn(name="", limits=lims,
colours=rev(RColorBrewer::brewer.pal(11,"Spectral"))) +
ggplot2::scale_y_continuous(expand = c(0,0)) +
ggplot2::scale_x_continuous(expand = c(0,0)) +
ggplot2::theme_bw()
}
}
Run the code above in your browser using DataLab