Category Archives: Uncategorized

Latent Iteractions in Structural Equation Models

I was eager to know how to modelling latent interactions for structural equation models in lavaan. There is this lavaan google group https://groups.google.com/forum/#!forum/lavaan where one can find a lot of comments by searching for “latent interactions”.  Basicly there is one paper from Mash (2004) and one from Lin (2010) explaining the methods in detail. Inspired by https://rpubs.com/mkearney/103098 (data not available) I compiled a script summarizing the methods developed by Marsh (2004) and Lin (2010) by using the HolzingerSwineford1939 data.

See  http://rpubs.com/candrea/latintsem .

 

CFA with a single factor

Fit values for a CFA with a single factor can only be computed with models with more than 3 observed variables. With 3 obeserved variables and one factor you have to compute 6 free parameters (with one fixed). But your covariance matrix has also 6 nonredundant elements. Hence you get df=0 degress of freedom. A chi-squared distribution with df=0 is constant 0, hence we can expect the test statistic to be 0.

CFA single factor

20151216121756

Little letters are also important

In the PISA 2012 Technical Report on page 312 (chapter 16), the formula (16.3) for the Partial Credit Model is printed for computing scale parameters. Looking at it twice, one can see that something must be wrong with the subscribs used for the sumations.

P_{x_i}(\theta_n) = \frac{\displaystyle\exp\sum_{k=0}^x(\theta_n-\delta_i+\tau_{ij})}{\displaystyle\sum_{h=0}^{m_i}\exp\displaystyle\sum_{k=0}^h(\theta_n-\delta_i+\tau_{ik})}

 

By consulting the chapter “Polytomous Rasch Models and their Estimation” in the book “Rasch Models” (Fischer, 1995), and combining the formulas (15.3) with (15.8) there, we get

P(X_{vi}=h) = \frac{\displaystyle\exp(\phi_h\theta_v + \sum_{l=0}^{h}\alpha_{il})}{\displaystyle\sum_{l=0}^m \exp(\phi_h\theta_v + \sum_{j=0}^{l}\alpha_{ij})}

 

Now by comparing the meaning of all the symbols and applying it on the formula from PISA Technical Report – by respecting as much as possible of the notations used by them – we get

P_{x_i}(\theta_n) = \frac{\displaystyle\exp\sum_{k=0}^{x_i}(\theta_n-\delta_i+\tau_{ik})}{\displaystyle\sum_{h=0}^{m_i}\exp\displaystyle\sum_{k=0}^h(\theta_n-\delta_i+\tau_{ik})}

 

We see that we have to change \tau_{ij} in the numerator of the very first formula above to \tau_{ik}, and x to x_i.

That makes sense!

Installing JAGS 3.4.0 under OS X 10.9 Maverick

First of all see the excellent installation manual by Martyn Plummer and Bill Northcott (JAGS Version 3.4.0 installation manual) at section 2 “Mac OS X”.

For the rest of us (me included) thinking  ./configure without any options will do the job are getting the following error:

configure: error: "You need to install the LAPACK library"

(It will not work even with the  –with-lapack=’-framework vecLib’ option.)

Do not follow this instruction! You do not have to install the LAPACK library because on OS X 10.9 the optimized (accelerated by Apple engineers) version of LAPACK is allready installed, see the LAPACK(7) Mac OS X Manual Page.

From now on just type the slightly modified commands in your bash-shell (terminal):

export CC=/usr/bin/clang

export CXX=/usr/bin/clang++

export CFLAGS="-g -Os -mmacosx-version-min=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -arch i386 -arch x86_64"

export CXXFLAGS="-g -Os -mmacosx-version-min=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -arch i386 -arch x86_64"

export FFLAGS="-g -Os -mmacosx-version-min=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -arch i386 -arch x86_64"

export LDFLAGS="-mmacosx-version-min=10.6 -arch i386 -arch x86_64"

./configure --disable-dependency-tracking --with-included-ltdl

make -j 8

sudo make install

Of course, make sure you have installed all the required tools before executing the commands.

Happy ./configuring!