gpt_gen_sample: Generate Sample of Data Sets

View source: R/gen_data_sample.R

gpt_gen_sampleR Documentation

Generate Sample of Data Sets

Description

Allows to simulate parameter heterogeneity. Note that truncated normal distributions are used to ensure that parameters within the specified bounds.

Usage

gpt_gen_sample(
  S,
  n,
  theta,
  eta,
  theta_sd = 0,
  eta_sd = 0,
  file,
  latent,
  restrictions = NULL,
  cpu
)

Arguments

S

sample size (number of participants)

n

vector of the length of number of trees with n per tree

theta

vector of true MPT parameter values (consider also restricted parameters!). Values will be appropriatly reordered if a named vector ist given (otherwise, check order!).

eta

vector of true continuous parameters. Values will be appropriatly reordered if a named vector ist given (otherwise, check order!).

theta_sd

vector giving the standard deviation of normally distributed MPT parameters across participants (default: homogeneity)

eta_sd

vector giving the standard deviation of normally distributed continuous parameters across participants (default: homogeneity)

file

a character vector specifying the path to the model file

latent

type of latent continuous distribution (one of "normal", "exgauss", "exwald", "gamma", "weibull", "lognormal", "wald", or beta). Can be a vector if multiple continuous variables y have different distributions (e.g., latent = c("normal", "gamma"))

restrictions

list with parameter restrictions (e.g., list("g=0.5", "mean1=mean2=100"))

cpu

number of cores used for data generation (default: number of cores minus one). alternatively, a parallel cluster initialized by 'cl <- parallel::makeCluster(4)'

See Also

gpt_gen

Examples

###### 2-High-Threshold Model (with fixed guessing) ######

## Not run: 
n <- c(targets=20, lures=20)     # number of items
theta <- c(do=.6,dn=.4, g=.5)          # MPT parameters
eta <- c(mu=400, sig=50, lambda_do=200, 
         lambda_go=600, lambda_gn=400, 
         lambda_dn=300)          # exGaussian parameters
file <- paste0(path.package("gpt"), "/models/2htm_exgauss.txt")

gen <- gpt_gen_sample(S=3, n=n, theta=theta, eta=eta, 
                      theta_sd=.1, eta_sd=10,
                      file =file, latent="exgauss")
sapply(gen, head, 3) 
# check mean of latent continuous distributions:
by(gen$data$y, gen$data$state, mean)

## End(Not run)

danheck/gpt documentation built on Feb. 12, 2024, 6:21 a.m.