> p=8
> n=200
> tbeta=c(3,1.5,2,rep(0,p-3))
> Sig=matrix(rep(1,p*p),p)
> for (ii in 1:p) for (jj in 1:p) if (ii!=jj) Sig[ii,jj] = 0.5^(abs(ii-jj))
> x = mvrnorm(n, rep(0,p), Sig)
> y = x%*%tbeta + rnorm(n,0,3)
> cv.out<-cv.glmnet(x,y,nfolds=5)
> tbetahat<-coef(cv.out)[2:9]
> yhat = x%*%tbetahat + rnorm(n,0,3)
> a = y-yhat
> pse=sum(a^2)/n
> pse
[1] 17.4298
我想把这段代码重复50次,得到50个这个值,该怎么用for语句,尝试过很多次,总是不行