
This function is a wrapper that conditionally handles filtering by group or time, calculates the difference vector, and evaluates hypotheses to return a list of results.
pred_results(
dataset,
id = NULL,
vars,
type = "group",
hypothesis,
gtvar,
grp_a,
grp_b,
location = "median",
diff_method = "wilcoxon",
phi_0 = 0.5
)
A list containing:
A vector of 0s and 1s indicating whether each hypothesis was correct.
A vector of the differences between groups.
The column variables used in the analysis.
A data frame for research.
The column that identifies unique subjects. This should be NULL
if type
is 'group' and should not be NULL
if type
is 'prepost'.
The column variables of interest.
The type of study. Valid values are 'group' for group-based data and 'prepost' for pre-post data. Defaults to 'group'.
A vector or string of valid hypotheses: 'increase', 'decrease', or 'different'.
The column of interest to divide the groups (e.g., time or treatment).
The first subset of interest within the gtvar
column
(e.g., 'pre' or 'control').
The second subset of interest within the gtvar
column
(e.g., 'post' or 'treatment').
The measure of central tendency to use for the difference calculation. Valid options are 'median' or 'mean'. Defaults to 'median'.
The method to use for testing 'different' hypotheses. Valid options are 'wilcoxon' or 't'. Defaults to 'wilcoxon'.
The decision rule threshold for the p-value. If p-value < phi_0, then there's sufficient evidence for a success for a difference. Defaults to 0.50.
This function performs error handling to ensure appropriate input values and types. It then filters the data based on the study type, calculates the difference vector, and evaluates the hypotheses using the specified method.
data("group_data_example")
data("group_cog_data")
data("pre_post_data_example")
data("pre_post_fit")
# simple group analysis
pred_results(dataset=group_data_example, vars=c('v1', 'v2'),
hypothesis=c("increase", "different"), gtvar="group", grp_a="placebo", grp_b="drug")
# simple prepost analysis
pred_results(dataset=pre_post_data_example, id="ID", vars=c('v1', 'v2', 'v3'),
type="prepost", hypothesis="increase", gtvar="time", grp_a=0, grp_b=12)
# simulated group analysis
pred_results(dataset=group_cog_data, vars=c('blind_moca_uncorrected', 'craft_verbatim'),
type="group", hypothesis="decrease", gtvar="group.factor", grp_a="Control", grp_b="ESKD")
# simulated prepost analysis
pred_results(dataset=pre_post_fit, id="ID", vars=c('Flex_right', 'Flex_left'),
type="prepost", hypothesis="increase", gtvar="Time", grp_a=0, grp_b=1)
Run the code above in your browser using DataLab