[R] hi! l have a question please help me
leepama
butchman at hanmail.net
Fri Jul 30 07:14:56 CEST 2010
1)
dmatrix1<-function(n,p,rho,sigma,k){
muvec1=zeros(1,p)
truep<-as.matrix(c(3,1.5,0,0,2,0,0,0))
A=eye(p)
for(i in 1:p){
for(j in 1:p){
A[i,j]=rho^(abs(i-j))
X=mvrnorm(n,muvec1,A)
y=X%*%truep+as.matrix(rnorm(n,0,sigma))
Y=X[1:k,]
w=y[1:k]
Z=X[(k+1):n,]
z=y[(k+1):n]}}
return(list(X,Y,w,Z,z))
}
I made this code which performs design matrix..
Can you help me how to make several data set....??
the code i made compute only one data set...
2) we generate 50 data with 30 variables. The true regression
vector is such that
bj = 3 − 0.1j j = 1, . . . , 10,
bj = −5 + 0.3j j = 20, . . . , 25,
bj = 0 for the others j.
The noise is such that sigma = 9 and the correlations are such that (j, k) =
exp (−|j−k|/2 for (j, k) ∈ {11, . . . , 25}2 and the others variables are
i.i.d. N(0, 1),
also independent from x11, . . . , x25
how to simulate this data set....
3)we simulated 50 data sets and 40 predictors.
β=(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
and σ=15. The predictors X were generated as follows:
xi=Z1+"xi
, Z1∼N.(0,1), i=1, . . . ,5,
xi=Z2+"xi
, Z2∼N.(0,1), i=6, . . . ,10,
xi=Z3+"xi
, Z3∼N.(0,1), i=11, . . . ,15,
xi∼N.(0,1), xi independent identically distributed, i=16, : : : , 40
how to simulate this data set....
--
View this message in context: http://r.789695.n4.nabble.com/hi-l-have-a-question-please-help-me-tp2307569p2307569.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list