simulate_data: Generate a data set using a 'study_parameters'-object

View source: R/simulate.R

simulate_dataR Documentation

Generate a data set using a study_parameters-object

Description

Generate a data set using a study_parameters-object

Usage

simulate_data(paras, n = 1)

## S3 method for class 'plcp'
simulate_data(paras, n = NULL)

## S3 method for class 'plcp_multi'
simulate_data(paras, n = 1)

Arguments

paras

An object created by study_parameters

n

Optional; specifies which row n should be used if object is a data.frame containing multiple setups.

Value

A data.frame with the simulated data in long form. With the following columns:

  • y the outcome vector, with missing values as NA

  • y_c the outcome vector, without missing values removed.

  • time the time vector

  • treatment treatment indicator (0 = "control", 1 = "treatment")

  • subject subject-level id variable, from 1 to total number of subjects.

  • cluster for three-level models; the cluster-level id variable, from 1 to the total number of clusters.

Examples

p <- study_parameters(n1 = 11,
                      n2 = 10,
                      n3 = 4,
                      T_end = 10,
                      fixed_intercept = 37,
                      fixed_slope = -0.65,
                      sigma_subject_intercept = 2.89,
                      sigma_cluster_intercept = 0.6,
                      icc_slope = 0.1,
                      var_ratio = 0.03,
                      sigma_error = 1.5,
                      cor_subject = -0.5,
                      cor_cluster = 0,
                      cohend = 0.5)

d <- simulate_data(p)

rpsychologist/powerlmm documentation built on May 11, 2023, 12:24 a.m.