generate_tirt_lavaan_syntax: Generate lavaan Syntax for Thurstonian Models

View source: R/generate_tirt_lavaan_syntax.R

generate_tirt_lavaan_syntaxR Documentation

Generate lavaan Syntax for Thurstonian Models

Description

Generates the syntax required to fit either a Second-Order Thurstonian Factor Model or a First-Order Thurstonian IRT Model in lavaan.

Usage

generate_tirt_lavaan_syntax(
  n_blocks,
  block_size,
  key_matrix,
  trait_col,
  key_col,
  cor_matrix = NULL,
  model_type = c("TFM", "TIRT"),
  force_positive_variances = TRUE,
  more_constraints = ""
)

Arguments

n_blocks

Integer. Number of blocks in the questionnaire.

block_size

Integer. Number of items per block.

key_matrix

A data.frame indicating item trait and item sign.

trait_col

Character string. The name of the column in key_matrix indicating the trait measured by the item.

key_col

Character string. The name of the column in key_matrix indicating the keying direction of the item (e.g., positive/negative).

cor_matrix

Optional matrix. Starting values for trait correlations.

model_type

Character. Either "TFM" (Second-Order Thurstonian Factor Model) or "IRT" (First-Order).

force_positive_variances

Logical. If TRUE, prevents Heywood cases. In "Factor" models, utility variances > 0.0001. In "IRT" models, utility variances and derived correlated errors > 0.0001. Defaults to TRUE.

more_constraints

Additional lavaan syntax strings for constraining certain parameters if needed.

Value

A character string containing the lavaan model syntax.


autoFC documentation built on July 14, 2026, 5:07 p.m.