发布网友 发布时间:2023-06-12 00:03
共1个回答
热心网友 时间:2024-12-02 14:51
(1)plot(lm.ridge(GDP~Consume+Investment+IO+Population+Jobless+Goods,data=dat,lambda=seq(0,0.3,0.001)))#和线性回归类似,这个plot可以画出岭迹图,lambda=seq(0,0.3,0.001)设置范围和间隔,可以观察岭迹图,人工选择,但是这样主观性较强。(2)select(lm.ridge(GDP~Consume+Investment+IO+Population+Jobless+Goods,data=dat,lambda=seq(0,0.3,0.001)))#利用select函数找出最优岭参数lambda,会有三个值,任选一个即可。lm.ridge(GDP~Consume+Investment+IO+Population+Jobless+Goods,data=dat,lambda=0.09)#通过(1)或(2)把选取的lmbda参数写到岭回归函数中去,在这里lambda=0.09。