hltm: Fitting Hierarchical Latent Trait Models (for Binary...

Description Usage Arguments Value References Examples

View source: R/hltm.R

Description

hltm fits a hierarchical latent trait model in which both the mean and the variance of the latent preference (ability parameter) may depend on person-specific covariates (x and z). Specifically, the mean is specified as a linear combination of x and the log of the variance is specified as a linear combination of z.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
hltm(
  y,
  x = NULL,
  z = NULL,
  constr = c("latent_scale", "items"),
  beta_set = 1L,
  sign_set = TRUE,
  init = c("naive", "glm", "irt"),
  control = list()
)

Arguments

y

A data frame or matrix of item responses.

x

An optional model matrix, including the intercept term, that predicts the mean of the latent preference. If not supplied, only the intercept term is included.

z

An optional model matrix, including the intercept term, that predicts the variance of the latent preference. If not supplied, only the intercept term is included.

constr

The type of constraints used to identify the model: "latent_scale", or "items". The default, "latent_scale" constrains the mean of latent preferences to zero and the geometric mean of prior variance to one; "items" places constraints on item parameters instead and sets the mean of item difficulty parameters to zero and the geometric mean of the discrimination parameters to one.

beta_set

The index of the item for which the discrimination parameter is restricted to be positive (or negative). It may take any integer value from 1 to ncol(y).

sign_set

Logical. Should the discrimination parameter of the corresponding item (indexed by beta_set) be positive (if TRUE) or negative (if FALSE)?

init

A character string indicating how item parameters are initialized. It can be "naive", "glm", or "irt".

control

A list of control values

max_iter

The maximum number of iterations of the EM algorithm. The default is 150.

eps

Tolerance parameter used to determine convergence of the EM algorithm. Specifically, iterations continue until the Euclidean distance between β_{n} and β_{n-1} falls under eps, where β is the vector of item discrimination parameters. eps=1e-4 by default.

max_iter2

The maximum number of iterations of the conditional maximization procedures for updating γ and λ. The default is 15.

eps2

Tolerance parameter used to determine convergence of the conditional maximization procedures for updating γ and λ. Specifically, iterations continue until the Euclidean distance between two consecutive log likelihoods falls under eps2. eps2=1e-3 by default.

K

Number of Gauss-Legendre quadrature points for the E-step. The default is 21.

C

[-C, C] sets the range of integral in the E-step. C=3 by default.

Value

An object of class hltm.

coefficients

A data frame of parameter estimates, standard errors, z values and p values.

scores

A data frame of EAP estimates of latent preferences and their approximate standard errors.

vcov

Variance-covariance matrix of parameter estimates.

log_Lik

The log-likelihood value at convergence.

N

Number of units.

J

Number of items.

H

A vector denoting the number of response categories for each item.

ylevels

A list showing the levels of the factorized response categories.

p

The number of predictors for the mean equation.

q

The number of predictors for the variance equation.

control

List of control values.

call

The matched call.

References

Zhou, Xiang. 2019. "Hierarchical Item Response Models for Analyzing Public Opinion." Political Analysis.

Examples

1
2
3
4
5
6
7
8
y <- nes_econ2008[, -(1:3)]
x <- model.matrix( ~ party * educ, nes_econ2008)
z <- model.matrix( ~ party, nes_econ2008)

dichotomize <- function(x) findInterval(x, c(mean(x, na.rm = TRUE)))
y[] <- lapply(y, dichotomize)
nes_m1 <- hltm(y, x, z)
nes_m1

Example output

Registered S3 method overwritten by 'pryr':
  method      from
  print.bytes Rcpp
...........
 converged at iteration 11 

Call:
hltm(y = y, x = x, z = z)

Mean Regression:
                        Estimate Std_Error z_value p_value
x(Intercept)              -0.444     0.094  -4.751   0.000
xpartyindependent          0.351     0.087   4.039   0.000
xpartyRepublican           1.035     0.132   7.843   0.000
xeduc2                     0.027     0.078   0.344   0.731
xpartyindependent:educ2    0.235     0.116   2.034   0.042
xpartyRepublican:educ2     0.436     0.148   2.942   0.003

Variance Regression:
                  Estimate Std_Error z_value p_value
z(Intercept)        -0.084     0.154  -0.548   0.584
zpartyindependent    0.160     0.113   1.410   0.158
zpartyRepublican     0.120     0.147   0.811   0.417

Log Likelihood: -10201.89

hIRT documentation built on April 14, 2020, 7:07 p.m.

Related to hltm in hIRT...