[R] simulation data in SEM
David Winsemius
dwinsemius at comcast.net
Sun Sep 14 23:05:03 CEST 2014
Adding back the list address:
On Sep 14, 2014, at 9:53 AM, thanoon younis wrote:
> thank you for your help but i still have error after putting semicolon "Error: unexpected symbol in:
> "Ro<-matrix(data=c(7.0,2.1,2.1,7.0), ncol=2)
> yo<-matrix(data=NA,nrow=N,ncol=P) p""
The error message shows no semicolon in the location I pointed at that was missing one. Furthermore the error message is now attaching the prior line which should not have thrown an error. Since you didn't include the actual code block that was your revision we can only guess (and I do not have a good guess why that is now occurring unless perhaps your font has two different encodings for semi-colon glyphs.)
You typed (or at least that is what I see in my mail client):
yo<-matrix(data=NA,nrow=N,ncol=P) p<-numeric(P); v<-numeric(P)
I suggested:
yo<-matrix(data=NA,nrow=N,ncol=P); p<-numeric(P); v<-numeric(P)
PLEASE read the Posting Guide. I will not respond to offlist messages from you in the future.
--
David.
>
>
> many thanks again
>
> On 14 September 2014 19:37, David Winsemius <dwinsemius at comcast.net> wrote:
>
> 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
>
>
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list