Re: [R] data.frame error using sem package

From: John Fox <jfox_at_mcmaster.ca>
Date: Fri 07 Oct 2005 - 06:47:45 EST


Dear Suzanne,

Take a look at your model specification:

> p.ram

     [,1] [,2] [,3]

[1,] "LM1 -> LSMA"   "LM1 -> LSMA"   NA  
[2,] "LSMA -> RSMA"  "LSMA -> RSMA"  NA  
[3,] "RSMA -> RM1"   "RSMA -> RM1"   NA  
[4,] "LSMA <-> LSMA" "LSMA <-> LSMA" NA  
[5,] "RSMA <-> RSMA" "RSMA <-> RSMA" NA  
[6,] "RM1 <-> RM1"   "RM1 <-> RM1"   NA  

>

This matrix should have three columns, the first giving the path, the second the name of the corresponding parameter, and the third the start value for the parameter (or NA if you want sem() to compute a start value). You've apparently left out the parameter names. Please see the sem examples for details and the paper at
<http://socserv.socsci.mcmaster.ca/jfox/sem-package.pdf>.

I hope this helps,
 John



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Suzanne Witt
> Sent: Thursday, October 06, 2005 2:55 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] data.frame error using sem package
>
> I am trying to use sem to measure effective connectivity
> among four brain regions. I have pasted the code that I am
> trying to run since that seems easier than trying to come up
> with another example.
>
> The input data is time series data taken from SPM; they are each
> 1x121 columns of numbers. I get the error either when I
> source the whole code, or if I enter it line by line when I
> go to get the summary.
>
> Thanks,
>
> Suzanne
>
> library(sem)
>
> # Load the region timecourses.
>
> lsma1 <- read.table("/Users/witt/parkinsons/rmrkm010905/R_files/
> 010905_lcomf_LSMA.dat")
> rsma1 <- read.table("/Users/witt/parkinsons/rmrkm010905/R_files/
> 010905_lcomf_RSMA.dat")
> lmc1 <- read.table("/Users/witt/parkinsons/rmrkm010905/R_files/
> 010905_lcomf_LM1.dat")
> rmc1 <- read.table("/Users/witt/parkinsons/rmrkm010905/R_files/
> 010905_lcomf_RM1.dat")
>
> # Combine all the timecourses from each session into a single
> data frame and name the columns appropriately.
>
> lcomf <- cbind(lsma1, rsma1, lmc1, rmc1)
> names(lcomf) <- c("LSMA", "RSMA", "LM1", "RM1")
>
> # Type this at the command line to see a summary of your data
>
> str(lcomf)
>
> # Set up the structural equation model.
>
> p.ram <<- matrix(c( 'LM1 -> LSMA', 'LM1 -> LSMA', NA,
> 'LSMA -> RSMA', 'LSMA -> RSMA', NA,
> 'RSMA -> RM1', 'RSMA -> RM1', NA,
> 'LSMA <-> LSMA', 'LSMA <-> LSMA', NA,
> 'RSMA <-> RSMA', 'RSMA <-> RSMA', NA,
> 'RM1 <-> RM1', 'RM1 <-> RM1', NA),
> ncol = 3, byrow = TRUE)
>
> # Tell which variables are exogenous ('fixed').
>
> p.fixed <- c('LM1')
>
> # Do the fitting for session 1.
>
> C <- cor(lcomf)
> nt <- dim(lcomf)[1]
> #attach(lcomf)
> lcomf.results <- sem(p.ram, C, nt, obs.variables =
> rownames(C), fixed.x = p.fixed)
>
> # Check out the results using the summary function
>
> summary(lcomf.results)
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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



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 Received on Fri Oct 07 06:54:08 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:26:57 EST