View source: R/plot_PAF_continuous.R
plot.PAF_q | R Documentation |
Plot impact fractions corresponding to risk-quantiles over several risk factors
## S3 method for class 'PAF_q' plot(x, ...)
x |
A PAF_q object. This is a dataframe that is created by running the function PAF_calc_continuous. |
... |
Other global arguments inherited by that might be passed to the ggplot routine |
A ggplot2 plotting object for PAF_q over the differing risk factors in x
library(splines) library(survival) library(parallel) options(boot.parallel="snow") options(boot.ncpus=2) # The above could be set to the number of available cores on the machine model_continuous <- glm(formula = case ~ region * ns(age, df = 5) + sex * ns(age, df = 5) + education +exercise + ns(diet, df = 3) + alcohol + stress + ns(lipids,df = 3) + ns(waist_hip_ratio, df = 3) + high_blood_pressure, family = "binomial", data = stroke_reduced) out <- PAF_calc_continuous(model_continuous,riskfactor_vec= c("diet","lipids","waist_hip_ratio"),q_vec=c(0.1,0.9), ci=FALSE,calculation_method="B",data=stroke_reduced) plot(out) # example with more quantile points and including confidence intervals # (more useful - but a bit slower to run) out <- PAF_calc_continuous(model_continuous,riskfactor_vec= c("diet","lipids","waist_hip_ratio"),q_vec=c(0.01, 0.1,0.3,0.5,0.7,0.9), ci=TRUE,calculation_method="B",data=stroke_reduced) plot(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.