Dear all, I am trying to create multiple SEM models in a loop - so that if I change the data they can easily be re-created rather than re-creating each RAM model line by line - therein lies my problem. I have a dataframe set out as follows1 Duration -> RC1 cov1 -0.2563002 MMSE -> RC1 cov2 -0.0309003 RC1 -> Aggression npi1 0.2310004 RC1 -> Apathy npi2 0.1043005 RC1 -> Disinhibition npi3 0.279800 ... the specifyModel() and specifyEquations() methods need you to manually input each line individually. Can I simply supply the SEM method with a matrix like the one I have above? Thanks,George [[alternative HTML version deleted]]
Dear George, I am not very used to sem package, but it seems to me that you can use a file as an argument of specifyModel() or specifyEquations() functions, instead of input each line individually on the shell. see the first argument on ?specifyEquations Maybe you could write such matrix inside a file that will be used when defining the model... Bernardo Niebuhr Em Quarta-feira, 4 de Junho de 2014 17:17, George Parish <george_parish@hotmail.co.uk> escreveu: Dear all, I am trying to create multiple SEM models in a loop - so that if I change the data they can easily be re-created rather than re-creating each RAM model line by line - therein lies my problem. I have a dataframe set out as follows1 Duration -> RC1 cov1 -0.2563002 MMSE -> RC1 cov2 -0.0309003 RC1 -> Aggression npi1 0.2310004 RC1 -> Apathy npi2 0.1043005 RC1 -> Disinhibition npi3 0.279800 ... the specifyModel() and specifyEquations() methods need you to manually input each line individually. Can I simply supply the SEM method with a matrix like the one I have above? Thanks,George [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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. [[alternative HTML version deleted]]
Dear George, It's not entirely clear to me what you're trying to do, and where the loop comes in. As has already been suggested, you can store the model specification in a file or files. Also, the "RAM" form of the model can be specified as a character matrix, a numeric matrix, or a "semmod" object. These are documented in ?sem. You could look at the internal structure of a "semmod" object produced by specifyEquations() or specifyModel() to see how it works. I hope that this helps, John ------------------------------------------------ John Fox, Professor McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 4 Jun 2014 15:45:44 +0100 George Parish <george_parish at hotmail.co.uk> wrote:> Dear all, > I am trying to create multiple SEM models in a loop - so that if I change the data they can easily be re-created rather than re-creating each RAM model line by line - therein lies my problem. > I have a dataframe set out as follows1 Duration -> RC1 cov1 -0.2563002 MMSE -> RC1 cov2 -0.0309003 RC1 -> Aggression npi1 0.2310004 RC1 -> Apathy npi2 0.1043005 RC1 -> Disinhibition npi3 0.279800 ... > the specifyModel() and specifyEquations() methods need you to manually input each line individually. Can I simply supply the SEM method with a matrix like the one I have above? > Thanks,George > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.