Learn R Programming

PredTest (version 0.1.0)

pred_adjusted: Adjusted Predictions Based on Group Comparisons

Description

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.

Usage

pred_adjusted(dataset, hypothesis, vars, covariates, group, ref)

Value

A list with two elements:

results

A vector indicating whether each hypothesis was correct (1 for correct, 0 for incorrect).

weights

A vector of weights corresponding to each variable in vars, calculated from the correlation matrix.

Arguments

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 vars or covariates.

ref

The reference category within the group variable. This must be a value present in the group column.

Examples

Run this code
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")

Run the code above in your browser using DataLab