add_M2: Attach the margin-based fit indices to a fitted model

View source: R/24_M2.R

add_M2R Documentation

Attach the margin-based fit indices to a fitted model

Description

Computes M2 for the model and for the independence baseline, and returns the fitted object with a TestFitIndicesM2 component added. The print method then shows the response-pattern indices and the margin-based ones side by side.

This is a separate step rather than part of the fit because it is expensive: the cost is the Cholesky factorisation of a dense matrix whose size grows with the square of the item count (see M2).

Usage

add_M2(x, ...)

## Default S3 method:
add_M2(x, ...)

## S3 method for class 'nominalLCA'
add_M2(x, verbose = TRUE, gc = TRUE, ...)

## S3 method for class 'ratedLCA'
add_M2(x, verbose = TRUE, gc = TRUE, ...)

## S3 method for class 'LRAordinal'
add_M2(x, verbose = TRUE, gc = TRUE, ...)

## S3 method for class 'ordinalBiclustering'
add_M2(x, verbose = TRUE, gc = TRUE, ...)

## S3 method for class 'nominalBiclustering'
add_M2(x, verbose = TRUE, gc = TRUE, ...)

Arguments

x

A fitted model object of class "exametrika".

...

Additional arguments passed to methods.

verbose

Logical; if TRUE (default), reports the size of the margin covariance matrix before computing it when that matrix is large.

gc

Logical; if TRUE (default), releases the workspace before returning. See M2.

Value

The fitted object with TestFitIndicesM2 added.

Examples


dat <- dataFormat(J20S600, response.type = "nominal")
fit <- LCA(dat, ncls = 3)
fit <- add_M2(fit)
fit
print(fit, fit_indices = "margin")



exametrika documentation built on Aug. 20, 2026, 5:08 p.m.