User Tools

Site Tools


lab:zhang:generate_complete_data_for_linear_model
library(mvtnorm)

grm.linear<-function(N, T, R){
## Constants and parameters
mL<-50
vL<-100
mS<-1
vS<-25
vLS<-0
vE<-25

mu<-c(mL,mS)
sigma<-array(c(vL,vLS,vLS,vS), dim=c(2,2))

y<-array(NA, dim=c(N, T))
LS<-array(NA, dim=c(N, 2))

for (i in 1:N){
  LS[i,]<-rmvnorm(1, mu, sigma)
  for (j in 1:T){
    y[i, j] <- LS[i,1] + LS[i,2]*(j-1)/(T-1) + rnorm(1, 0, sqrt(vE))
  }
}

#data.file<-paste('H:\\Private\\LongPower\\type1\\data\\N-',N,'-T-',T,'-',1000+R,'.txt',sep='')
data.file<-paste('LS-N-',N,'-T-',T,'-',1000+R,'.txt',sep='')
write.table(cbind(y,LS), data.file, row.names=F, col.names=F)
}


for (i in 1:100000){
  grm.linear(500,5,i)
}
lab/zhang/generate_complete_data_for_linear_model.txt · Last modified: 2016/01/24 09:48 by 127.0.0.1