I keep getting this error when I try to use the sem package. I and
another person who has successfully used the sem package for similar
analysis (fMRI effective connectivity) cannot figure out what is
wrong with my code. I would appreciate any suggestions.
The error message:
Error in data.frame(object$coeff, se, z, 2 * (1 - pnorm(abs(z))),
par.code) :
arguments imply differing number of rows: 6, 0
In addition: Warning message:
Could not compute QR decomposition of Hessian.
Optimization probably did not converge.
in: sem.default(ram = ram, S = S, N = N, param.names = pars,
var.names = vars,
Thank you,
Suzanne
Suzanne Witt wrote:> I keep getting this error when I try to use the sem package. I and > another person who has successfully used the sem package for similar > analysis (fMRI effective connectivity) cannot figure out what is > wrong with my code. I would appreciate any suggestions.It is almost impossible to help if you do not specify a toy example that shows how you produced that error message. Please read the psoting guide which tells you how to specify such examples most appropriately in order to get a good answer. Uwe Ligges> The error message: > > Error in data.frame(object$coeff, se, z, 2 * (1 - pnorm(abs(z))), > par.code) : > arguments imply differing number of rows: 6, 0 > In addition: Warning message: > Could not compute QR decomposition of Hessian. > Optimization probably did not converge. > in: sem.default(ram = ram, S = S, N = N, param.names = pars, > var.names = vars, > > > Thank you, > > Suzanne > > ______________________________________________ > R-help at 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
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]]