replext_gls: Replications and Extension of Generalized Least Squares...

View source: R/replext_gls.R

replext_glsR Documentation

Replications and Extension of Generalized Least Squares Simulation

Description

This function performs multiple simulations of Generalized Least Squares (GLS) models across various conditions, extending the work of Maric et al. (2014). It allows for the exploration of different numbers of timepoints per phase and autocorrelation parameters, providing a comprehensive analysis of model performance across these conditions.

Usage

replext_gls(
  n_timepoints_list,
  rho_list,
  iterations,
  n_phases = 2,
  n_IDs = 1,
  betas,
  formula,
  covariate_specs = NULL,
  alpha_level = 0.05,
  verbose = FALSE
)

Arguments

n_timepoints_list

Numeric vector. The numbers of timepoints per phase to simulate.

rho_list

Numeric vector. The autocorrelation parameters to simulate.

iterations

Integer. The number of simulations to run for each combination of conditions.

n_phases

Integer. The number of phases in the design. Default is 2.

n_IDs

Integer. The number of subjects (IDs) to simulate. Default is 1.

betas

Named numeric vector. The true coefficient values for the model.

formula

Formula object. The model formula to be fitted.

covariate_specs

List of lists. Specifications for generating covariates. Each inner list should contain elements 'vars' (variable names), 'dist' (distribution function name), 'args' (list of distribution parameters), and optionally 'expr' (a function to generate data).

alpha_level

Numeric. The significance level for hypothesis tests. Default is 0.05.

verbose

Logical. If TRUE, print progress messages. Default is FALSE.

Value

A data frame of class 'replext_gls' containing simulation results, including:

term

Character. The name of the model term.

tppp

Integer. The number of timepoints per phase.

rho

Numeric. The autocorrelation parameter.

success_rate

Numeric. The proportion of successful model fits.

mean_estimates

Numeric. The mean of the estimated coefficients.

mean_bias

Numeric. The mean bias of the estimated coefficients.

se_estimates

Numeric. The standard error of the estimated coefficients.

rejection_rates

Numeric. The proportion of significant hypothesis tests.

se_rejection_rates

Numeric. The standard error of the rejection rates.

mean_rmse

Numeric. The mean root mean square error of the estimates.

alpha_level

Numeric. The significance level used for hypothesis tests.

iterations

Integer. The number of iterations performed.

n_phases

Integer. The number of phases in the design.

n_IDs

Integer. The number of subjects simulated.

formula

Character. The model formula used.

covariate_specs

Character. The covariate specifications used.

References

Maric, M., de Haan, E., Hogendoorn, S.M., Wolters, L.H. & Huizenga, H.M. (2014). Evaluating statistical and clinical significance of intervention effects in single-case experimental designs: An SPSS method to analyze univariate data. Behavior Therapy. doi: 10.1016/j.beth.2014.09.009

Examples

results <- replext_gls(
  n_timepoints_list = c(10),
  rho_list = c(0.2),
  iterations = 10,
  betas = c("(Intercept)" = 0, "phase1" = 1),
  formula = y ~ phase
)


scdtb documentation built on Sept. 30, 2024, 9:35 a.m.