| predict_delta_comps {codaredistlm} | R Documentation |
Get predictions from compositional ilr multiple linear regression model
Description
Provided the data (containing outcome, compositional components and covariates), fit a ilr multiple linear regression model and provide predictions from reallocating compositional values pairwise amunsnst the components model.
Usage
predict_delta_comps(
dataf,
y,
comps,
covars = NULL,
deltas = c(0, 10, 20)/(24 * 60),
comparisons = c("prop-realloc", "one-v-one")[1],
alpha = 0.05
)
Arguments
dataf |
A |
y |
Name (as string/character vector of length 1) of outcome variable in |
comps |
Character vector of names of compositions in |
covars |
Optional. Character vector of covariates names (non-comp variables) in |
deltas |
A vector of time-component changes (as proportions of compositions , i.e., values between -1 and 1). Optional.
Changes in compositions to be computed pairwise. Defaults to 0, 10 and 20 minutes as a proportion of the 1440 minutes
in a day (i.e., approximately |
comparisons |
Currently two choices: |
alpha |
Optional. Level of significance. Defaults to 0.05. |
Details
Values in the comps columns must be strictly greater than zero. These compositional values are NOT assumed to be constrained to (0, 1)
values as the function normalises the compositions row-wise to sum to 1 in part of it's processing of the dataset before analysis.
Please see the deltacomp package README.md file for examples and explanation of the comparisons = "prop-realloc" and comparisons = "one-v-one" options.
Value
Messages are printed to the console as the function tests the inputs, produces the isometric log ratios (ilrs), fits the linear model and produces the redistributed time-use predictions (with confidence intervals).
Returns a data.frame of the time-use redistribution predictions (and 95% confidence intervals) with the following columns:
-
comp+: the compositional variable with the addition of thedeltavalue -
comp-: the compositional variable with the subtraction of thedeltavalue -
delta: the time-use redistribution value -
alpha: significance level for the 100(1-alpha)% confidence interval -
delta_pred: the predicted mean change in the outcome variable -
ci_lo: the lower limit of 100(1-alpha)% confidence interval corresponding todelta_pred -
ci_up: the upper limit of 100(1-alpha)% confidence interval corresponding todelta_pred -
sig:"*"if thedelta_predis significantly different from 0 at thealphalevel (empty string otherwise)
The data.frame has a class of deltacomp_obj which denotes there are additional attributes of the returned object accessible using attr(*, "attribute_name").
The possible values for "attribute_name" are:
-
dataf: a data.frame of the predictors (covariates and ilrs) -
y: a vector of the outcome variable -
comps: a character vector of the time-use composition names -
lm: thelmobject of the multiple linear regression fit (usingyanddataffrom above) -
deltas: the redistributed time-use values used in the predictions -
comparisons:"one-v-one"or"prop-realloc"provided as thecomparisonsargument -
alpha: significance level for the 100(1-alpha)% confidence intervals -
ilr_basis: the ilr change of basis matrixV -
mean_pred: a single row data.frame with the predicted mean outcome (fitcolumn) value from the "average" set of predictors
Author(s)
Ty Stanford <tystan@gmail.com>
Examples
predict_delta_comps(
dataf = fat_data,
y = "fat",
comps = c("sl", "sb", "lpa", "mvpa"),
covars = c("sibs", "parents", "ed"),
deltas = seq(-60, 60, by = 5) / (24 * 60),
comparisons = "one-v-one",
alpha = 0.05
)
delta_comp_out <- predict_delta_comps(
dataf = fat_data,
y = "fat",
comps = c("sl", "sb", "lpa", "mvpa"),
covars = NULL,
deltas = seq(-60, 60, by = 5) / (24 * 60),
comparisons = "prop-realloc",
alpha = 0.05
)
# get the mean prediction from the returned object
attr(delta_comp_out, "mean_pred")