[R] simulation data in SEM
David Winsemius
dwinsemius at comcast.net
Sun Sep 14 18:37:44 CEST 2014
On Sep 14, 2014, at 8:48 AM, Don McKenzie wrote:
> cc’ing to list, as requested in the posting guide, so that others
> may be able to help you.
>
> On Sep 14, 2014, at 8:45 AM, thanoon younis <thanoon.younis80 at gmail.com
> > wrote:
>
>> Thank you very much for your reply
>>
>> the output is
>>
>>> #Do simulation for 100 replications
>>> N<-1000; P<-10
>>>
>>> phi<-matrix(data=c(1.0,0.3,0.3,1.0),ncol=2) #The covariance matrix
>>> of xi
>>> Ro<-matrix(data=c(7.0,2.1,2.1,7.0), ncol=2)
>>> yo<-matrix(data=NA,nrow=N,ncol=P) p<-numeric(P); v<-numeric(P)
>> Error: unexpected symbol in "yo<-matrix(data=NA,nrow=N,ncol=P) p"
Almost any time you see an error message that says " : unexpected
_something_" it means you submitted a malformed expression to the
interpreter that was missing a paren or a bracket or a comma or
_something_. You always need to go back to the left of where the
error was discovered. In this case you are missing a semicolon about
here:
yo<-matrix(data=NA,nrow=N,ncol=P) p<-numeric(P); v<-numeric(P)
^
--
David.
>>>
>>> for (t in 1:100) {
>> + #Generate the data for the simulation study
>> + for (i in 1:N) {
>> + #Generate xi
>> + xi<-mvrnorm(1,mu=c(0,0),phi)
>> + #Generate the fixed covariates
>> + co<-rnorm(1,0,1)
snipped
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list