Code:

```
for(i in 1:400)
{
if (mydata$quad[i]==1){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==1),mean=1,1)
} else
if (mydata$quad[i]==2){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==2),mean=9,1)
} else
if (mydata$quad[i]==3){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==3),mean=6,1)
} else
if (mydata$quad[i]==4){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==4),mean=4,1)
}else
if (mydata$quad[i]==5){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==5),mean=1,1)
}else
if (mydata$quad[i]==6){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==6),mean=0,1)
}else
if (mydata$quad[i]==7){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==7),mean=0,1)
}else
if (mydata$quad[i]==8){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==8),mean=2,1)
}else
if (mydata$quad[i]==9){
mydata$z[i]=rnorm(n=sum(mydata$quad[i]==9),mean=6,1)
}}
```