gpt_fit: Fit GPT Model

View source: R/fit_gpt_user.R

gpt_fitR Documentation

Fit GPT Model

Description

Fit GPT Model

Usage

gpt_fit(
  x,
  y,
  data,
  file,
  latent,
  group = NULL,
  restrictions = NULL,
  baseline = FALSE,
  starting.values = NULL,
  eta.lower = NULL,
  eta.upper = NULL,
  n.fit = c(3, 1),
  maxit = c(300, 1000),
  EM.tol = 0.01,
  cpu = NULL,
  print = FALSE
)

Arguments

x

vector of observed discrete observations (e.g., choices) or name of variable in data

y

vector or matrix of observed continuous variable(s) (e.g., response times, confidence,...) or name of variable in data

data

data frame containing the variables as named in x and y

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"))

group

vector with the number of observations as in x and y, indicating to which group each observation belongs

restrictions

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

baseline

whether to fit baseline models that assume a saturated MPT structure and (a) separate continuous distributions per category (y.per.cat = no mixture) or (b) a single distribution across all categories (y.null). In each case, separate distributions are assumed for each continuous variable.

starting.values

starting values for theta and eta (used only in first EM run). Note that sensible starting values are guessed by default.

eta.lower

lower bound vector or scalar for eta parameters (assigned by name; or in alphabetical order). It is sufficient to constrain a subset of eta parameters selectively using a named vector.

eta.upper

upper bound vector or scalar for eta parameters

n.fit

number of EM and optim fitting runs (if any n.fit>1: with random starting values)

maxit

maximum number of EM and optim iterations, respectively

EM.tol

tolerance for EM algorithm

cpu

number of cores used to fit individual data (default: number of cores minus one). Alternatively: a cluster spawned by makeCluster()

print

whether to print current status

Details

The following paramaters are used to specify the latent distributions (will be assigned in this order to the parameters listed in the model file as last argument in each row/branch):

"normal":

mean (mu) and SD (sigma)

"exgauss" (sum of normal and independent exponential):

mean and SD of normal (mu, sigma); mean of exponential (tau)

"gamma":

shape (k), scale (theta), shift

"weibull":

shape (k), scale (lambda), shift

"lognormal":

mean and SD (of normal distribution before taking log), shift

"wald" (= inverse normal):

mean (mu), shape (lambda), shift

"exwald" (= sum of inverse normal and independent exponential):

mean, shape, shift

"beta":

shape1 (alpha) and shape2 (beta), see dbeta

"vonmises":

mu (mean), kappa (concentration) of von Mises distribution for circular data.

Examples

## Not run: 
n <- c(targets=75, lures=75)     # number of items
theta <- c(do=.6,dn=.4, g=.5)          # MPT parameters
eta <- c(mu=400, sig=50, lambda_do=300, 
         lambda_go=500, lambda_gn=500, 
         lambda_dn=300)          # exGaussian parameters

file <- paste0(path.package("gpt"), "/models/2htm_exgauss.txt")
gen <- gpt_gen(n=n, theta=theta, eta=eta, latent="exgauss", file=file)
fit <- gpt_fit(x=gen$x, y=gen$y, latent="exgauss", file=file, 
               restrictions=list("do=dn", "lambda_do=lambda_dn", 
                                 "lambda_go=lambda_gn"))
fit

## End(Not run)

danheck/gpt documentation built on March 29, 2025, 1:17 p.m.