Fits the Generalized Partial Credit model for ordinal polytomous data, under the Item Response Theory approach.

```
gpcm(data, constraint = c("gpcm", "1PL", "rasch"), IRT.param = TRUE,
start.val = NULL, na.action = NULL, control = list())
```

data

a `data.frame`

or a numeric `matrix`

of manifest variables.

constraint

a character string specifying which version of the Generalized Partial Credit Model to fit. See **Details** and
**Examples** for more info.

IRT.param

logical; if `TRUE`

then the coefficients' estimates are reported under the
usual IRT parameterization. See **Details** for more info.

start.val

a list of starting values or the character string `"random"`

. If a list, each one of its
elements corresponds to each item and should contain a numeric vector with initial values for the
threshold parameters and discrimination parameter; even if `constraint = "rasch"`

or `constraint = "1PL"`

,
the discrimination parameter should be provided for all the items. If `"random"`

, random starting values are computed.

na.action

the `na.action`

to be used on `data`

; default `NULL`

the model uses the available
cases, i.e., it takes into account the observed part of sample units with missing values (valid under MAR
mechanisms if the model is correctly specified).

control

a named list of control values with components,

- iter.qN
the number of quasi-Newton iterations. Default 150.

- GHk
the number of Gauss-Hermite quadrature points. Default 21.

- optimizer
which optimization routine to use; options are "optim" and "nlminb", the latter being the default.

- optimMethod
the optimization method to be used in

`optim()`

. Default is "BFGS".- numrDeriv
which numerical derivative algorithm to use to approximate the Hessian matrix; options are "fd" for forward difference approximation and "cd" for central difference approximation. Default is "fd".

- epsHes
step size to be used in the numerical derivative. Default is 1e-06. If you choose

`numrDeriv = "cd"`

, then change this to a larger value, e.g., 1e-03 or 1e-04.- parscale
the

`parscale`

control argument of`optim()`

. Default is 0.5 for all parameters.- verbose
logical; if

`TRUE`

info about the optimization procedure are printed.

An object of class `gpcm`

with components,

a named list with components the parameter values at convergence for each item.

the log-likelihood value at convergence.

the convergence identifier returned by `optim()`

or `nlminb()`

.

the approximate Hessian matrix at convergence.

the number of function and gradient evaluations used by the quasi-Newton algorithm.

a list with two components: (i) `X`

: a numeric matrix
that contains the observed response patterns, and (ii) `obs`

: a numeric vector that contains the observed
frequencies for each observed response pattern.

a list with two components used in the Gauss-Hermite rule: (i) `Z`

: a numeric matrix that contains
the abscissas, and (ii) `GHw`

: a numeric vector that contains the corresponding weights.

the maximum absolute value of the score vector at convergence.

the value of the `constraint`

argument.

the value of the `IRT.param`

argument.

a copy of the response data matrix.

the values used in the `control`

argument.

the value of the `na.action`

argument.

the matched call.

In case the Hessian matrix at convergence is not positive definite try to re-fit the model by specifying the starting values or using
`start.val = "random"`

.

The Generalized Partial Credit Model is an IRT model, that can handle ordinal manifest variables. This model was discussed by Masters (1982) and it was extended by Muraki (1992).

The model is defined as follows $$P_{ik}(z) = \frac{\exp \sum \limits_{c = 0}^k \beta_i (z - \beta_{ic}^*)}{ \sum \limits_{r = 0}^{m_i} \exp \sum \limits_{c = 0}^r \beta_i (z - \beta_{ic}^*)},$$ where \(P_{ik}(z)\) denotes the probability of responding in category \(k\) for item \(i\), given the latent ability \(z\), \(\beta_{ic}^*\) are the item-category parameters, \(\beta_i\) is the discrimination parameter, \(m_i\) is the number of categories for item \(i\), and $$\sum \limits_{c = 0}^0 \beta_i (z - \beta_{ic}^*) \equiv 0.$$

If `constraint = "rasch"`

, then the discrimination parameter \(\beta_i\) is assumed equal for all items and fixed at one. If
`constraint = "1PL"`

, then the discrimination parameter \(\beta_i\) is assumed equal for all items but is estimated.
If `constraint = "gpcm"`

, then each item has its one discrimination parameter \(\beta_i\) that is estimated. See
**Examples** for more info.

If `IRT.param = FALSE`

, then the linear predictor is of the form \(\beta_i z + \beta_{ic}\).

The fit of the model is based on approximate marginal Maximum Likelihood, using the Gauss-Hermite quadrature rule for the approximation of the required integrals.

Masters, G. (1982). A Rasch model for partial credit scoring. *Psychometrika*, **47**, 149--174.

Muraki, E. (1992). A generalized partial credit model: application of an EM algorithm. *Applied Psychological
Measurement*, **16**, 159--176.

`coef.gpcm`

,
`fitted.gpcm`

,
`summary.gpcm`

,
`anova.gpcm`

,
`plot.gpcm`

,
`vcov.gpcm`

,
`GoF.gpcm`

,
`margins`

,
`factor.scores`

```
# NOT RUN {
## The Generalized Partial Credit Model for the Science data:
gpcm(Science[c(1,3,4,7)])
## The Generalized Partial Credit Model for the Science data,
## assuming equal discrimination parameters across items:
gpcm(Science[c(1,3,4,7)], constraint = "1PL")
## The Generalized Partial Credit Model for the Science data,
## assuming equal discrimination parameters across items
## fixed at 1:
gpcm(Science[c(1,3,4,7)], constraint = "rasch")
## more examples can be found at:
## http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:ltm#sample_analyses
# }
```

Run the code above in your browser using DataLab