View source: R/plot_transfers.R
plot_transfers | R Documentation |
Plots model predictions for transfers/substitutions between the named parts.
plot_transfers( from_part, to_part, model, comp_labels, terms = TRUE, part_1 = NULL, yllimit = NULL, yulimit = NULL, xllimit = NULL, xulimit = NULL, y_label = NULL, plot_log = FALSE, lower_quantile = 0.05, upper_quantile = 0.95, units = "unitless", specified_units = NULL, fixed_values = NULL, granularity = 10000, point_specification = ggplot2::geom_point(size = 2), error_bar_colour = "grey", theme = NULL )
from_part |
Should be an element of |
to_part |
Should be an element of |
model |
Model to use in estimates/predictions. |
comp_labels |
The labels of the compositional columns. |
terms |
Are estimates for differences in outcome associated with differences in compositional variables? If |
part_1 |
Used with ilr-pivot coordinate transformation to specify which should be first part. Passed to |
yllimit |
Lower limit of y-axis shown on plot. |
yulimit |
Upper limit of y-axis shown on plot. |
xllimit |
Lower limit of x-axis shown on plot. Should be in same scale as |
xulimit |
Upper limit of x-axis shown on plot. Should be in same scale as |
y_label |
Label for y-axis. |
plot_log |
If this is |
lower_quantile |
If set, this gives the lower limit of plotting (as a quantile for both variables of interest). In practice, the current behaviour is to calculate the range of both variables between the upper and lower quantile, and use the narrower one. |
upper_quantile |
If set, this gives the upper limit of plotting (as a quantile for both variables of interest). |
units |
What should the units of the compositional variables be in any output? Currently available are "unitless" (where working in terms of proportions), "hr/day", "hr/wk", "min/day", "min/wk" and "specified", in which case the |
specified_units |
If units are being specified via the composition sum, this is where it is done. It should be a vector where the first argument is a string describing the units, and the second argument is the expected sum of a composition e.g. |
fixed_values |
If |
granularity |
Does not usually require setting. If set, gives the number of points plotted on the graph. If it is too low, the plot will contain gaps. If it is too high, plotting will be slow. |
point_specification |
Should be a |
error_bar_colour |
Should be an R-recognised colour for error bars, specified by name in quotation marks. |
theme |
Optional |
Plot with balance of two parts plotted as exposure/ independent variable.
lm_outcome <- comp_model(type = "linear", outcome = "BMI", covariates = c("agegroup", "sex"), data = simdata, comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep"), rounded_zeroes = FALSE ) epicoda::plot_transfers(from_part = "sedentary", to_part = "moderate", model = lm_outcome , comp_labels =c("vigorous", "moderate", "light", "sedentary", "sleep"), y_label = "Model-predicted difference in BMI", units = "hr/day", terms = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.