James Rudge
2012-Nov-28 05:30 UTC
[R] generating sets of parameters, when some parameters are vectors
Hello, I'm trying to generate N lists of randomly selected parameter values. Some of the parameters are vectors while other are single values. I've tried to use the approach below but it doesn't work for parameter x, which should be a vector. Thanks in advance! James #Define names of parameters in the list, parms<- list( x=c(0,0), y=0) #Create N sets of randomly selected parameter values N<- 10 set<-rep(list(parms),N) for (i in 1:N) { set[[i]]["x"]=c(runif(1,1,2), runif(1,2,3)) ###Problem here set[[i]]["y"]=runif(1,5,10) } [[alternative HTML version deleted]]
James Rudge
2012-Nov-28 06:28 UTC
[R] generating sets of parameters when some parameters are vectors
I'm trying to generate N lists of randomly selected parameter values. Some of the parameters are vectors while other are single values. I've tried to use the approach below but it doesn't work for parameter x, which should be a vector. Thanks in advance! James #Define names of parameters in the list, parms<- list( x=c(0,0), y=0) #Create N sets of randomly selected parameter values N<- 10 set<-rep(list(parms),N) for (i in 1:N) { set[[i]]["x"]=c(runif(1,1,2), runif(1,2,3)) ###Problem here set[[i]]["y"]=runif(1,5,10) } [[alternative HTML version deleted]]