Re: [R] solving a structural equation model using sem or other package

2007-01-24 Thread David Barron
This is an extract from the sem help page, which deals with your situation:

S covariance matrix among observed variables; may be input as a
symmetric matrix, or as a lower- or upper-triangular matrix. S may
also be a raw (i.e., ``uncorrected'') moment matrix — that is, a
sum-of-squares-and-products matrix divided by N. This form of input is
useful for fitting models with intercepts, in which case the moment
matrix should include the mean square and cross-products for a unit
variable all of whose entries are 1; of course, the raw mean square
for the unit variable is 1. Raw-moment matrices may be computed by
raw.moments.

On 24/01/07, Daniel Nordlund [EMAIL PROTECTED] wrote:
 I am trying to work my way through the book Singer, JD and Willett, JB, 
 Applied Longitudinal Data Analysis. Oxford University Press, 2003  using R.  
 I have the SAS code and S-Plus code from the UCLA site (doesn't include 
 chapter 8 or later problems).  In chapter 8, there is a structural 
 equation/path model which can be specified for the sem package as follows

 S - cov(al2) #al2 contains the variables alc1, alc2, alc3, and cons
 N - 1122

 modelA.ram - specify.model()
   f1- alc1,  NA,  1
   f1- alc2,  NA,  1
   f1- alc3,  NA,  1
   f2- alc1,  NA,  0
   f2- alc2,  NA,  .75
   f2- alc3,  NA,  1.75
   cons  - f1,p0,  1
   cons  - f2,p1,  1
   alc1 - alc1,  u1,  1
   alc2 - alc2,  u2,  1
   alc3 - alc3,  u3,  1
   cons - cons,  u4,  1
   f1   - f1,s1,  1
   f2   - f2,s2,  1
   f1   - f2,s3,  1

 modelA - sem(modelA.ram, S, N, analytic.gradient=FALSE)

 An equivalent specification in SAS produces the solution presented in the 
 book.  The variable cons is a constant vector of 1's.  The problem with the 
 sem package is that the covariance matrix which includes the variable cons is 
 singular and sem says so and will not continue.  Is there an alternative way 
 to specify this problem for sem to obtain a solution?  If not, is there 
 another package that would produce a solution?

 Thanks,

 Dan Nordlund
 Bothell, WA

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] solving a structural equation model using sem or other package

2007-01-24 Thread Daniel Nordlund
David,

Thanks for the help.  I missed the significance of the section you quoted below 
from the help.  That does indeed solve the problem.

Dan

Dan Nordlund
Bothell, WA  USA

 -Original Message-
 From: David Barron [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, January 24, 2007 3:32 AM
 To: Daniel Nordlund; r-help
 Subject: Re: [R] solving a structural equation model using sem or other 
 package
 
 This is an extract from the sem help page, which deals with your situation:
 
 S covariance matrix among observed variables; may be input as a
 symmetric matrix, or as a lower- or upper-triangular matrix. S may
 also be a raw (i.e., ``uncorrected'') moment matrix — that is, a
 sum-of-squares-and-products matrix divided by N. This form of input is
 useful for fitting models with intercepts, in which case the moment
 matrix should include the mean square and cross-products for a unit
 variable all of whose entries are 1; of course, the raw mean square
 for the unit variable is 1. Raw-moment matrices may be computed by
 raw.moments.
 
 On 24/01/07, Daniel Nordlund [EMAIL PROTECTED] wrote:
  I am trying to work my way through the book Singer, JD and Willett, JB, 
  Applied
 Longitudinal Data Analysis. Oxford University Press, 2003  using R.  I have 
 the SAS
 code and S-Plus code from the UCLA site (doesn't include chapter 8 or later
 problems).  In chapter 8, there is a structural equation/path model which can 
 be
 specified for the sem package as follows
 
snip
  An equivalent specification in SAS produces the solution presented in the 
  book.  The
 variable cons is a constant vector of 1's.  The problem with the sem package 
 is that the
 covariance matrix which includes the variable cons is singular and sem says 
 so and
 will not continue.  Is there an alternative way to specify this problem for 
 sem to obtain
 a solution?  If not, is there another package that would produce a solution?
 
  Thanks,
 
  Dan Nordlund
  Bothell, WA
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 =
 David Barron
 Said Business School
 University of Oxford
 Park End Street
 Oxford OX1 1HP

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] solving a structural equation model using sem or other package

2007-01-23 Thread Daniel Nordlund
I am trying to work my way through the book Singer, JD and Willett, JB, 
Applied Longitudinal Data Analysis. Oxford University Press, 2003  using R.  I 
have the SAS code and S-Plus code from the UCLA site (doesn't include chapter 8 
or later problems).  In chapter 8, there is a structural equation/path model 
which can be specified for the sem package as follows 

S - cov(al2) #al2 contains the variables alc1, alc2, alc3, and cons
N - 1122

modelA.ram - specify.model()
  f1- alc1,  NA,  1
  f1- alc2,  NA,  1
  f1- alc3,  NA,  1
  f2- alc1,  NA,  0
  f2- alc2,  NA,  .75
  f2- alc3,  NA,  1.75
  cons  - f1,p0,  1
  cons  - f2,p1,  1
  alc1 - alc1,  u1,  1
  alc2 - alc2,  u2,  1
  alc3 - alc3,  u3,  1
  cons - cons,  u4,  1
  f1   - f1,s1,  1
  f2   - f2,s2,  1
  f1   - f2,s3,  1 

modelA - sem(modelA.ram, S, N, analytic.gradient=FALSE)

An equivalent specification in SAS produces the solution presented in the book. 
 The variable cons is a constant vector of 1's.  The problem with the sem 
package is that the covariance matrix which includes the variable cons is 
singular and sem says so and will not continue.  Is there an alternative way to 
specify this problem for sem to obtain a solution?  If not, is there another 
package that would produce a solution?

Thanks,

Dan Nordlund
Bothell, WA

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.