Comment in-line

On 18/09/2015 11:04, thanoon younis wrote:
Hi,


I need you help to correct the code below please
I have this error
Error in if (v[j] >= 0) yo[i, j] <- 1 else yo[i, j] <- 0 :
   missing value where TRUE/FALSE needed





library(mvtnorm)   #Load mvtnorm package
N<-200;P<-9
W=matrix(NA, nrow=N, ncol=2)
xi=matrix(NA, nrow=N, ncol=2)
Eta=numeric(N)
phi<-matrix(data=c(1.0,0.3,0.3,1.0),ncol=2)
yo<-matrix(data=NA,nrow=N1,ncol=P); p<-numeric(P); v<- numeric(P)

When I try your code it fails here because it does not know what N1 is. Please post code which is self-contained.

for (t in 1:25) {
   for (i in 1:N) {
     xi1[i,]=rmvnorm(1, c(0,0), phi)
     delta1<-rnorm(1,0,sqrt(0.3))
eps<-rnorm(3,0,1)

Eta[i]=0.6*W[i,1]+0.6*W[i,1]*xi[i,1]+0.6*W[i,2]*xi[i,2]+0.6*W[i,2]*xi[i,2]*xi[i,2]+0.6*xi[i,1]+0.6*xi[i,2]+0.6*xi[i,1]*xi[i,1]+delta
     v[1]<-1.0+xi[i,1]; v1[2]<-1.0+0.8*xi1[i,1]; v1[3]<- 1.0+0.8*xi1[i,1]
     v[4]<-1.0+xi[i,2]; v1[5]<-1.0+0.8*xi1[i,2]; v1[6]<- 1.0+0.8*xi1[i,2]
     v[7]<-1.0+Eta[i]+eps[1]; v[8]<-1.0+0.8*Eta[i]+eps[2];
     v[9]<-1.0+0.8*Eta[i]+eps[3]

         for (j in 1:9) { if (v[j]>=0) yo[i,j]<-1 else yo[i,j]<-0 } }

}#end




Any help would be appreciated.


Regards



--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to