Return to Construction guide / CAMSIS home

 

5.2 Row-column association modelling using LEM: commands

The first step is to use the latest version of the SPSS data file to output a simple data file which can be read by LEM. In this example, we export the title-by-status and title-only units as well as the indicator of the title frequency, running the model on the title-by-status units. Appropriate SPSS syntax is below :

get file="revisions1.sav".
write out="mdat1.dat"
   / hbst4 wbst4 hocc4 wocc4 freq  (5 (F8.0)).
execute.
The order in which the variables are exported from SPSS is important!

That data can then be read and analysed in LEM by entering appropriate arguments for the RC model commands. The LEM manual, freely available on the web, explains the model options in further detail. An appropriate annotated command file, named eg model1.inp, is shown below :

CONTENTS OF MODEL1.INP :
man 2
* indicates 2 'manifest' variables, ie a 2-d crosstab is analysed

dim 560 560
* there are 560 different values in each manifest variable, ie 
* 560 (square autorecoded) male and female title-by-status units

lab H W
* Labels the 2 variables H and W

mod {H,W,ass2(H,W,5a),ass2(H,W,5a,3,3),fac(HW,220)}
* Specifies the model : We crosstabulate H and W with a loglinear 
* model, with the addition of first a dimension using 
* an RC2 association term between 
* the H and W units which is unconstrained (ie ass2(H,W,5a)), 
* then second a (subsidiary) dimension using an RC2 association 
* term between the H and W units which is constrained to just three 
* different values (ie ass2(H,W,5a,3,3)) 
* (for a one-dimensional model, delete the second ass2() term).
* Lastly, we also specify that we define specific parameters for 
* up to 220 husband-wife pseudo-diagonal combinations (specified in the design
* matrix), using the fac(HW,220) term
* (in the derivation of the design matrix, we would have seen that 
* the max value of the 'lagwend' variable was =220).

rec 43514
* Specifies that the data file is 43514 records long (43514 HW combs)

ski [3 4]
* Specifies how the data will be read : skip the contents of 3rd and 4th column. 

rco 
* Specifies we are using a 'table' file and therefore the last column
* of data ('freq') will be used as a weighting variable.

des des560r1u1p2.txt
* Names the design matrix to be used (a separate plain text file). 
* In this example, because of the fac(220) command the design matrix
* must by a square 560 X 560 table with all values equal to 0 except 
* for the appropriate combinations of pseudo-diagonals which are 
* numbered consecutively from 1 to 220. 
* Additionally, because we have specified a second dimension with
* constraints on its form, (ie ass2(H,W,5a,3,3)), the design matrix must
* also have on its end two horizontal rows of 520 indicators (one for men then 
* one for women) which show whether the corresponding occupational unit is 
* in the 1st, 2nd or 3rd group, indicated by values 1, 2 or 3.


dat mdat1.dat
* Names the data file to be read.

nco
* Suppresses some of the output from the output file.

wco temp2.out
wda das2.out
wfi fis2.out
wfr frs2.out
* Various options on how to collect output files. 
* Of relevance here, the command will create the file fis2.out 
* which will contain expected frequencies under the model of each
* combination, and das2.out, which will contain unit names and observed frequencies
* of every combination in the model. 

Subsequently, such a command file and variants of it can be called through an MSDOS batch file with a form as those below :

CONTENTS OF COMFILE.BAT :
# LEM command file

# (hash symbols indicate comments)

# Info on : [Country] [Year] [Version] [base unit]

# Update 1

#lem95 modelold.inp modelold.out e:\camsis\country\version\etc\ modelold.log -log

lem95 model1.inp model1.out e:\camsis\country\version\etc\ model1.log -log

lem95 model2.inp model2.out e:\camsis\country\version\etc\ model2.log -log


# (this batch file runs the model1.inp and model2.inp input files 
#  after skipping the modelold.inp file) 

# The named directory must be the one which contains the input files, 
#  data files and design matrices, and will be where the output 
#  files are deposited. 

This command file itself can be called from the MSDOS prompt as follows (the path command is used to name whichever directory on your machine contains the lemwin executable files. :

MSDOS> 
MSDOS> path e:\programme files\lemwin\
MSDOS> comfile.bat
MSDOS> 


Return to Construction guide