全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
10391 7
2011-06-07
悬赏 100 个论坛币 已解决
在模型 gam(y~s(x,k=...,))
不同的k
y随x的变化趋势不同。见附件。
第一个图模型中用k=10
因变量随着自变量的增加而呈现先下降后上升的趋势。
第二个图模型中用k=15
因变量随着自变量的增加而一直呈现下降的趋势。
请问如何选取k值。最好有例题说明。
对任何回复 或者提示 或者任何意见 表示衷心的感谢并予以评分!
最佳答案悬赏100论坛币。

最佳答案

epoh 查看完整内容

Package 'mgcv' mgcv.pdf page12 -page14 choose.k Basis dimension choice for smooths 里面的说明及各种范例 已经说明的非常清楚 楼主看了,自当了然. 1. fit your model and extract the deviance residuals; 2. for each smooth term in your model, fit an equivalent, single, smooth to the residuals, using a substantially increased k to see if there is pattern in the residuals that could pote ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-6-7 20:49:08
Package 'mgcv'
mgcv.pdf page12 -page14
choose.k    Basis dimension choice for smooths
里面的说明及各种范例
已经说明的非常清楚
楼主看了,自当了然.
1. fit your model and extract the deviance residuals;
2. for each smooth term in your model, fit an equivalent, single,
   smooth to the residuals, using a substantially increased k to
   see if there is pattern in the residuals that could potentially
   be explained by increasing k.

###########
## Simulate some data ....
library(mgcv)
set.seed(0)
dat <- gamSim(1,n=400,scale=2)
## fit a GAM with quite low 'k'
b<-gam(y~s(x0,k=6)+s(x1,k=6)+s(x2,k=6)+s(x3,k=6),data=dat)
plot(b,pages=1)
## Economical tactic (see below for more obvious approach)....
## check for residual pattern, removeable by increasing 'k'
## typically 'k', below, chould be substantially larger than
## the original, 'k' but certainly less than n/2.
## Note use of cheap "cs" shrinkage smoothers, and gamma=1.4
## to reduce chance of overfitting...
rsd <- residuals(b)
gam(rsd~s(x0,k=40,bs="cs"),gamma=1.4,data=dat) ## fine
gam(rsd~s(x1,k=40,bs="cs"),gamma=1.4,data=dat) ## fine
gam(rsd~s(x2,k=40,bs="cs"),gamma=1.4,data=dat) ## `k' too low
gam(rsd~s(x3,k=40,bs="cs"),gamma=1.4,data=dat) ## fine
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-6-7 21:09:35
欢迎大家讨论。任何回复都有评分:)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-6-8 16:07:14
No answers?
No idea?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-6-10 13:52:25
等待answer,我基本上都不设定的!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-6-10 15:03:00
等得我们花都谢了,希望有经验的童鞋,留下点什么。谢谢。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群