prep.loadings: Recipe function to quickly create factor loadings

View source: R/dynrRecipe.R

prep.loadingsR Documentation

Recipe function to quickly create factor loadings

Description

Recipe function to quickly create factor loadings

Usage

prep.loadings(map, params = NULL, idvar, exo.names = character(0),
  intercept = FALSE)

Arguments

map

list giving how the latent variables map onto the observed variables

params

parameter numbers

idvar

names of the variables used to identify the factors

exo.names

names of the exogenous covariates

intercept

logical. Whether to include freely esimated intercepts

Details

The default pattern for 'idvar' is to fix the first factor loading for each factor to one. The variable names listed in 'idvar' have their factor loadings fixed to one. However, if the names of the latent variables are used for 'idvar', then all the factor loadings will be freely estimated and you should fix the factor variances in the noise part of the model (e.g. prep.noise).

This function does not have the full set of features possible in the dynr package. In particular, it does not have any regime-swtiching. Covariates can be included with the exo.names argument, but all covariate effects are freely estimated and the starting values are all zero. Likewise, intercepts can be included with the intercept logical argument, but all intercept terms are freely estimated with zero as the starting value. For complete functionality use prep.measurement.

Value

Object of class 'dynrMeasurement'

Examples

#Single factor model with one latent variable fixing first loading
prep.loadings(list(eta1=paste0('y', 1:4)), paste0("lambda_", 2:4))

#Single factor model with one latent variable fixing the fourth loading
prep.loadings(list(eta1=paste0('y', 1:4)), paste0("lambda_", 1:3), idvar='y4')

#Single factor model with one latent variable freeing all loadings
prep.loadings(list(eta1=paste0('y', 1:4)), paste0("lambda_", 1:4), idvar='eta1')

#Single factor model with one latent variable fixing first loading
# and freely estimated intercept
prep.loadings(list(eta1=paste0('y', 1:4)), paste0("lambda_", 2:4),
 intercept=TRUE)

#Single factor model with one latent variable fixing first loading
# and freely estimated covariate effects for u1 and u2
prep.loadings(list(eta1=paste0('y', 1:4)), paste0("lambda_", 2:4),
 exo.names=paste0('u', 1:2))

# Two factor model with simple structure
prep.loadings(list(eta1=paste0('y', 1:4), eta2=paste0('y', 5:7)), 
paste0("lambda_", c(2:4, 6:7)))

#Two factor model with repeated use of a free parameter
prep.loadings(list(eta1=paste0('y', 1:4), eta2=paste0('y', 5:8)), 
paste0("lambda_", c(2:4, 6:7, 4)))

#Two factor model with a cross loading
prep.loadings(list(eta1=paste0('y', 1:4), eta2=c('y5', 'y2', 'y6')), 
paste0("lambda_", c("21", "31", "41", "22", "62")))

dynr documentation built on May 29, 2024, 2:49 a.m.