View source: R/plot_sequential_PAF.R
plot.SAF_summary | R Documentation |
Produce plots of sequential and average PAF
## S3 method for class 'SAF_summary'
plot(
x,
number_rows = 3,
max_PAF = 0.4,
min_PAF = 0,
point.size = 4,
axis.text.size = 6,
title.size = 6,
axis.title.size = 6,
...
)
x |
An SAF_summary R object produced by running the average_paf function. |
number_rows |
integer How many rows of plots will be included on the associated figure. |
max_PAF |
upper limit of y axis on PAF plots (default = 0.4) |
min_PAF |
lower limit of y axis on PAF plots (default = 0) |
point.size |
size of points on each individual plot (default=4) |
axis.text.size |
size of axis labels on each plot (default=6) |
title.size |
size of title on each individual plot (default=6) |
axis.title.size |
size of titles on each plot (default=6) |
... |
Other global arguments inherited by that might be passed to the ggplot routine |
A ggplot2 plotting object illustrating average sequential PAF by position and average PAF by risk factor.
Ferguson, J., O’Connell, M. and O’Donnell, M., 2020. Revisiting sequential attributable fractions. Archives of Public Health, 78(1), pp.1-9. Ferguson, J., Alvarez-Iglesias, A., Newell, J., Hinde, J. and O’Donnell, M., 2018. Estimating average attributable fractions with confidence intervals for cohort and case–control studies. Statistical methods in medical research, 27(4), pp.1141-1152
library(splines)
library(survival)
library(parallel)
options(boot.parallel="snow")
options(boot.ncpus=2)
# Simulated data on occupational and environmental exposure to
# chronic cough from Eide, 1995
# First specify the causal graph, in terms of the parents of each node. Then put into a list
parent_urban.rural <- c()
parent_smoking.category <- c("urban.rural")
parent_occupational.exposure <- c("urban.rural")
parent_y <- c("urban.rural","smoking.category","occupational.exposure")
parent_list <- list(parent_urban.rural, parent_smoking.category,
parent_occupational.exposure, parent_y)
# also specify nodes of graph, in order from root to leaves
node_vec <- c("urban.rural","smoking.category","occupational.exposure", "y")
model_list=automatic_fit(Hordaland_data,
parent_list=parent_list, node_vec=node_vec, prev=.09)
out <- average_paf(data=model_list[[length(model_list)]]$data,
model_list=model_list,
parent_list=parent_list, node_vec=node_vec, prev=.09, nperm=10,
riskfactor_vec = c("urban.rural","occupational.exposure"),ci=FALSE)
plot(out)
# plot with confidence intervals for average and sequential PAF
# (This is probably more useful for more than 2 risk factors).
# Separate axes for each risk factor so confidence intervals can be clearly displayed
out <- average_paf(data=model_list[[length(model_list)]]$data,
model_list=model_list,
parent_list=parent_list, node_vec=node_vec, prev=.09, nperm=10,
riskfactor_vec = c("urban.rural","occupational.exposure"),ci=TRUE,boot_rep=8)
plot(out)
# Here we plot, with margin of error of point estimate when 50 permutations are used
out <- average_paf(data=model_list[[length(model_list)]]$data,
model_list=model_list,
parent_list=parent_list, node_vec=node_vec, prev=.09, nperm=50,
riskfactor_vec = c("urban.rural","occupational.exposure"),ci=FALSE,exact=FALSE)
plot(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.