design_cfg_cfa: Designmatrix for log linear CFA models

View source: R/design_cfg_cfa.R

design_cfg_cfaR Documentation

Designmatrix for log linear CFA models

Description

Calculates the designmatrix corresponding to a dataset with length(kat) columns (variables).

Usage

design_cfg_cfa(
  kat,
  form = paste("~", paste(paste("V", 1:length(kat), sep = ""), collapse = " + ")),
  ...
)

Arguments

kat

a numerical vector containing kardinal numbers, giving the number of categories for each variable of a dataset (in the respective order of the variables in such a dataset) which corresponds to the requested designmatrix. So the length of this numerical vector represents the number of variables.

form

a character string which can be coerced into a model formulae with the function as.formula in the package stats. If this argument is left empty the function design_cfg_cfa() will return a designmatrix coding only main effects and no interactions – for a designmatrix refering to three variables for example, leaving the argument form empty will be equivalent to assigning the character "~ V1 + V2 + V3" to the argument (form="~ V1 + V2 + V3").

A special Case is to define a null-model or rather a cfa model of order zero. In such a model no (main) effects are considered. This can be achieved bei passing the character expression "null" to the argument form – so: form = "null"

...

additional parameters passed through to function model.matrix in package stats.

Details

This function internaly calls the function pos_cfg_cfa.

For further information on designmatrices see decription on function model.matrix in the package stats.

Value

A designmatrix - an object of class c("matrix","design_cfg_cfa") - for the formula therm given in argumentform.

References

No references in the moment

Examples

#######################################
# designmatrix with three main effects.
# three variables with two categories each.
design_cfg_cfa(kat=c(2,2,2))
# two variables with two categories each and one variable
# with 7 categories (Lienert LSD example).
design_cfg_cfa(kat=c(2,2,7))
###########
# designmatrix with three main effects an three interactions.
# three variables with two categories each.
design_cfg_cfa(kat=c(2,2,2),form="~ V1 + V2 + V3 + V1:V2 + V1:V3 + V2:V3")
# two variables with two categories each and one variable
# with 7 categories (e.g. The Krauth & Lienert suicide Data).
design_cfg_cfa(kat=c(2,2,7),form="~ V1 + V2 + V3 + V1:V2 + V1:V3 + V2:V3")
#######################################

confreq documentation built on Nov. 13, 2022, 9:05 a.m.