BSEM: Bayesian (Generalized) Partial Credits Model

Description Usage Arguments Value Examples

View source: R/BSEM.R

Description

An Bayesian implementation of the (Generalized) Partial Credits Model.

Usage

1
BSEM(x, levels, p=1, method="VB", Iters=500, Smpl=1000, Thin=1, A=500, seed=666)

Arguments

x

A matrix in the wide format. You should certify that: the minimum possible score is 1; all variables are named; and that are only variables to be modeled.

levels

The number of responses keys in the scale. If no value is inserted, the function assumes that the maximum value in x is the number of levels.

p

Indicates which model will be fitted. When p = 1, the function returns the Partial Credits Model. When p = 2, the function returns the Generalized Partial Credits Model.

method

The Bayesian estimation method to be used. Defaults to "VB" Variational Bayes. It can also be Laplace Approximation ("LA"), MCMC No-U-Turn Sampler ("MCMC"), Population Monte Carlo ("PMC"), or Iterative Quadrature ("IQ").

Iters

The maximum number of iterations. The default value, 500, is proposed for the default estimation method, "VB". For method "LA", we suggest 100 as the default. For method "MCMC", 20000. For method "PMC", 10. Finally, for method "IQ", 100.

Smpl

This argument indicates the number of posterior samples to be taken with sampling importance resampling for the estimation methods "IQ","LA", and "VB". For the "PMC" method, this is the number of samples per mixture component. This argument is not used by the "MCMC" method. The default value, 1000, is already fit for all the estimation methods that use this argument.

Thin

This is the number by which the posterior is thinned. Only "MCMC" and "PMC" estimation methods use this argument.

A

A is used only by the "MCMC" method. It is the number of initial, adaptive iterations to be discarded as burn-in. The value defaults to 500.

seed

The random seed for guaranteeing replicable results. As most examples in LaplacesDemon, it defaults to 666.

Value

A list containing the following components:

Data

The information used for running the model.

Model

The LaplacesDemon model used.

Fit

All the information returned by LaplacesDemon estimation method regarding the fit of the model.

abil

The MAP estimates of the theta parameter.

diff

The MAP estimates of the difficulty parameter.

disc

The MAP estimates of the discrimination parameter. Only returned when p = 2.

DIC

A list with the values of DIC, Dbar, and pV.

Examples

1
2
3
4
5
6
7
### Random Data with 100 observations and 10 variables with 5 levels of response
n = 100; v = 10; l = 5
Data <- simRasch(n, v, l)$data + 1
# Partial Credits Model
fit1  <- pcm(Data, levels=l, p=1, method="LA", Iters=100, Smpl=1000)
# Generalized Partial Credits Model
fit2  <- pcm(Data, levels=l, p=2, method="LA", Iters=100, Smpl=1000)

vthorrf/bsem documentation built on Dec. 24, 2021, 2:23 a.m.