User Tools

Site Tools


lab:projects:15fexible_error:r_code_for_t_data
###############################
## t data
mL<-5
mS<-2
vL<-2
vS<-1
vLS<-0
vE<-1/3
df<-3

TT<-5
N<-1000

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

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

error<-NULL
for (t in 1:TT){
	error<-cbind(error, rst(N,0,sqrt(vE),df=df))
}

for (i in 1:N){
  LS[i,]<-rmvnorm(1, mu, sigma)
  for (j in 1:TT){
    y[i, j] <- LS[i,1] + LS[i,2]*j + error[i,j]
  }
}

dset<-cbind(rep(1:TT, each=N),rep(1:N,TT),c(y))
write.table(dset,'tdata.txt',row.names=F,col.names=F)
lab/projects/15fexible_error/r_code_for_t_data.txt · Last modified: 2016/01/24 09:48 by 127.0.0.1