[R] data.frame error using sem package

From: Suzanne Witt <stwitt_at_wisc.edu>
Date: Fri 07 Oct 2005 - 05:54:42 EST


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

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:38 EST