View source: R/predict_fit_and_ci.R
predict_fit_and_ci | R Documentation |
Principally intended as input to forest_plot_examples and plot_transfers.
predict_fit_and_ci( model, new_data, comp_labels, terms = TRUE, part_1 = NULL, units = "unitless", specified_units = NULL, fixed_values = NULL )
model |
Model to use in estimates/predictions. |
new_data |
New data 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 |
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 |
Note that confidence intervals use the t-distribution with the appropriate degrees of freedom for linear regression,
and the z-distribution for logistic and Cox regression, to match the behaviour of summary()
for these model objects. As long as there are a reasonable
number of samples (at least 30, say) the difference between the two is negligible.
Data frame with estimates/predictions.
lm_outcome <- comp_model(type = "linear", outcome = "BMI", data = simdata, covariates = c("agegroup", "sex"), comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep"), rounded_zeroes = FALSE ) old_comp <- comp_mean(simdata, comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep"), rounded_zeroes = FALSE ) new_comp <- change_composition( composition = old_comp, main_part = "moderate", main_change = +0.5, comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep") ) predict_fit_and_ci(model = lm_outcome, new_data = new_comp, comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.