0
set.seed(123456)
reps<-20
n.iter<-188
n<-90
t.Z1_30=matrix(NA,nrow=600,ncol=1)
t.Z2_30=matrix(NA,nrow=600,ncol=1)
t.Z3_30=matrix(NA,nrow=600,ncol=1)

for(i in 1:n){
  for(j in 1:reps){
 `n<-90`
 `nc<-3`
X<-rep(1:nc, each=n/nc)
b0<-5
b1<-0.3
Y<-b0+b1*X+rnorm(n,0,2)
}

group<-split(Y,X)

t.Z1_30[i]<-((group$'1')-5.3)/2
t.Z2_30[i]<-((group$'2')-5.6)/2
t.Z3_30[i]<-((group$'3')-5.9)/2
t.Z.frame<-rbind(t.Z1_30, t.Z2_30, t.Z3_30)
}

I want to simulate my design in r. my IV is (balanced, unbalanced in sample) and (subsample size: 30, 50, 100, 150, 200). I am so beginner level in r.

so I want to set my simulation in case of (blanced) and (subsample size: 30, subgroup=3, reps=20). so I applied for loop() and nested for loop and I expected that I would get total 1800 simulation (3 X 30 X 20) but I can get 1800 simulation I only just gets 90 simulation.

What is wrong with my r code?

halfer
  • 19,824
  • 17
  • 99
  • 186
yuri jung
  • 1
  • 1

0 Answers0