Hello,

there is a variable named quad take values from 1 to 9 ( 400 points)

I'm trying to simulate a z variable as follows:

fo for example if I have 30 points of quad=1 , i simulate 30 Z values with mean =0

the if I have 15 points of quad=2,I simulate 15 Z value with mean = 2

....

and so on

is the below code is correct??

there is a variable named quad take values from 1 to 9 ( 400 points)

I'm trying to simulate a z variable as follows:

fo for example if I have 30 points of quad=1 , i simulate 30 Z values with mean =0

the if I have 15 points of quad=2,I simulate 15 Z value with mean = 2

....

and so on

is the below code is correct??

Code:

```
for(j in 1:9)
{
if (mydata$quad[j]==j){
for(i in 1:length(mydata$quad)){
mydata$z[i]=rnorm(n=length(mydata$quad),mean=c(0,2,1,3,7,9,10,11,2),1)
}
}
}
```

Last edited: