[R] data.frame error using sem package
Hi there, I just saw your question on the help list and tough you could help me with some start-up info I just downloaded the R project software to try running SEM analysis and I also downloaded the SEM package. But it just sits there on the desktop and R does not know where it is...I can¹t figure out how to organize the files...When I type ?sem in R it says object sem not found...I can¹t seem to find help on the web on how to set-up the packages Well, thanks in advance __ Patrick Bedard Ph.D. Dept. of Neuroscience Brown University [[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] data.frame error using sem package
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 __ 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
Re: [R] data.frame error using sem package
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@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
[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
Re: [R] data.frame error using sem package
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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