View source: R/pred_adjusted.R
pred_adjusted | R Documentation |
This function calculates adjusted predictions for variables of interest, taking into account covariates and group comparisons. It then returns whether the results align with the hypothesized direction of effects.
pred_adjusted(dataset, hypothesis, vars, covariates, group, ref)
dataset |
A data frame containing the data to be analyzed. |
hypothesis |
A string or vector of strings containing either 'increase' or 'decrease', indicating the expected direction of the effect. |
vars |
A vector of variable names in the dataset that are the outcomes of interest. These must be numeric columns. |
covariates |
A vector of covariates to include in the model. These must be numeric columns in the dataset. |
group |
The name of the grouping variable in the dataset. This must be
a column in the dataset and should not overlap with |
ref |
The reference category within the group variable. This must be a value present in the group column. |
A list with two elements:
A vector indicating whether each hypothesis was correct (1 for correct, 0 for incorrect).
A vector of weights corresponding to each variable in vars
,
calculated from the correlation matrix.
data("group_cog_data")
data("adjusted_example")
# simple example
pred_adjusted(adjusted_example, c("decrease", "increase"),
c('v1', 'v2'), 'sex', "group", 0)
# simulated example
pred_adjusted(dataset = group_cog_data, hypothesis = "decrease",
vars = c('craft_verbatim', 'fluency_f_words_correct'),
covariates = c('number_span_forward', 'number_span_backward'),
group = "group.factor", ref = "Control")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.