Checks the fit on the two- and three-way margins for `grm`

, `ltm`

, `rasch`

and `tpm`

objects.

`margins(object, …)`# S3 method for gpcm
margins(object, type = c("two-way", "three-way"), rule = 3.5, …)

# S3 method for grm
margins(object, type = c("two-way", "three-way"), rule = 3.5, …)

# S3 method for ltm
margins(object, type = c("two-way", "three-way"), rule = 3.5,
nprint = 3, …)

# S3 method for rasch
margins(object, type = c("two-way", "three-way"), rule = 3.5,
nprint = 3, …)

# S3 method for tpm
margins(object, type = c("two-way", "three-way"), rule = 3.5,
nprint = 3, …)

object

an object inheriting either from class `gpcm`

, class `grm`

, class `ltm`

or class `rasch`

.

type

the type of margins to be used. See **Details** for more info.

rule

the rule of thumb used in determining the indicative goodness-of-fit.

nprint

a numeric value determining the number of margins with the largest Chi-squared residuals
to be printed; only for `ltm`

and `rasch`

objects.

…

additional argument; currently none is used.

An object of either class `margins.ltm`

if `object`

inherits from class `ltm`

, class `rasch`

or class `tpm`

,
or an object of class `margins.grm`

if `object`

inherits from class `grm`

, with components,

for `margins.ltm`

is an array containing the values of chi-squared residuals;
for `margins.gpcm`

and `margins.grm`

is a list of length either the number of all possible pairs or all possible
triplets of items, containing the observed and expected frequencies, the values of chi-squared
residuals, the value of the total residual and the value of the rule of thumb times the product of
the number of categories of the items under consideration.

the type of margins that were calculated.

the value of the `nprint`

argument; returned only from `margins.ltm`

.

all possible two- or three-way combinations of the items; returned only from `margins.ltm`

.

the value of the `rule`

argument; returned only from `margins.ltm`

.

the number of items in `object`

; returned only from `margins.grm`

.

the names of items in `object`

; returned only from `margins.grm`

.

a copy of the matched call of `object`

.

Rather than looking at the whole set of response patterns, we can look at the two- and three-way margins.
For the former, we construct the \(2 \times 2\) contingency tables obtained by taking
the variables two at a time. Comparing the observed and expected two-way margins is analogous to comparing
the observed and expected correlations when judging the fit of a factor analysis model. For Bernoulli and
Ordinal variates, the comparison is made using the so called Chi-squared residuals. As a rule of thumb residuals
greater than 3.5 are indicative of poor fit. For a more strict rule of thumb use the `rule`

argument.
The analogous procedure is followed for the three-way margins.

Bartholomew, D. (1998) Scaling unobservable constructs in social science.
*Applied Statistics*, **47**, 1--13.

Bartholomew, D. and Knott, M. (1999) *Latent Variable Models
and Factor Analysis*, 2nd ed. London: Arnold.

Bartholomew, D., Steel, F., Moustaki, I. and Galbraith, J. (2002)
*The Analysis and Interpretation of Multivariate Data for
Social Scientists*. London: Chapman and Hall.

Rizopoulos, D. (2006) **ltm**: An R package for latent variable modelling and item response theory analyses.
*Journal of Statistical Software*, **17(5)**, 1--25. URL http://www.jstatsoft.org/v17/i05/

```
# NOT RUN {
## Two- and Three-way residuals for the Rasch model
fit <- rasch(LSAT)
margins(fit)
margins(fit, "three")
## Two- and Three-way residuals for the one-factor model
fit <- ltm(WIRS ~ z1)
margins(fit)
margins(fit, "three")
## Two- and Three-way residuals for the graded response model
fit <- grm(Science[c(1,3,4,7)])
margins(fit)
margins(fit, "three")
# }
```

Run the code above in your browser using DataLab