我需要有人给我一些有关自动回归时间序列模型的自适应套索的R编程的提示:
Y_{t}=\phi_{1}Y_{t-1}+\epsilon_{t}, where \phi_{1}=0.5 and \epsilon_{t } \sim N(0,1)
我知道在回归模型的情况下该怎么做。
我已经发布了我所做的回归分析。
library(glmnet)
set.seed(100)
beta_{1} = 2
beta_{2}=3
n=50
epsilon =rnorm(n,0,1)
x = (rnorm(n,0,9))
y =(beta_{1 }+ beta_{2} * x + epsilon)
d=data.frame(x,y)
ols<-lm(y\sim x, data=d)
best.ols.coef=coef(ols)
alasso1.cv <- cv.glmnet(x = cbind(0,x), y = y,
type.measure = "mse",
nfold = 10,
alpha = 1,
penalty.factor = 1 / abs(best.ols.coef),
keep = TRUE)
alasso1.cv$lambda.min
best.alasso.coef <- coef(alasso1.cv, s = alasso1.cv$lambda.min)
best.alasso.coef