predict.gpt_fit: Predictions for GPT Models

View source: R/predict_gpt_fit.R

predict.gpt_fitR Documentation

Predictions for GPT Models

Description

Computes expected category/branch probabilities and the corresponding conditional means and quantiles/densities for the continuous latent distributions.

Usage

## S3 method for class 'gpt_fit'
predict(
  object,
  cat = TRUE,
  dens = FALSE,
  group,
  dim = 1,
  quantiles = c(0.1, 0.3, 0.5, 0.7, 0.9),
  prec = 500,
  ...
)

Arguments

object

GPT model fitted by gpt_fit

cat

if FALSE computes expected probabilities and conditional densities for the latent MPT branches (and not for the observable MPT categories)

dens

if TRUE, returns conditional densities (instead of quantiles) for each category/branch

group

select group by an index, e.g., group=1 (if mutliple groups were fitted)

dim

only for multivariate continuous data: dimension for prediction

quantiles

which quantiles to predict

prec

number of evaluations of the GPT density to compute conditional means/quantiles for the latent distributions

...

ignored

Examples

## Not run: 
# generate data
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 <- gpt_fit(x=gen$x, y=gen$y, latent="exgauss", file=file, 
               restrictions=list("do=dn", "lambda_do=lambda_dn", 
                                 "lambda_go=lambda_gn"))
                                 
# Predictions for MPT categories:
predict(fit)

# Predictions for latent MPT branches:
p <- predict(fit, cat=FALSE, dens=TRUE)
yy <- as.numeric(colnames(p[,-(1:5)]))
plot(yy, p[1,-(1:5)], main="2HTM", type="l")
lines(yy, p[3,-(1:5)], col=2)
legend("topright", col=1:2, lty=1, c("Detect","Guess"))

## End(Not run)


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