[英]Cyclic adaptive spline in mgcv
I want to fit a GAM to data with a cyclic predictor and where most of the wiggliness in a specific part of the cycle.我想使用循环预测器将 GAM 拟合到数据中,并且在循环的特定部分中大部分摆动。
Is there any way to make a cyclic spline (bs = 'cc' or 'cp') adaptive?有没有办法使循环样条(bs = 'cc' 或 'cp')自适应? ... or, equivalently, make an adaptive spline (bs = 'ad') cyclic?
...或者,等效地,使自适应样条 (bs = 'ad') 循环?
Yes;是的; this is already allowed for in the adaptive spline basis in mgcv .
这在mgcv的自适应样条基础中已经允许。
The default basis in the adaptive spline is a P spline.自适应样条中的默认基础是 P 样条。 You can switch to a cyclic version of that type of spline or use a cyclic cubic spline.
您可以切换到该类型样条的循环版本或使用循环三次样条。
To get this to work, you have to pass information to the xt
argument of the smooth function, while leaving bs = "ad"
for the adaptive basis.要使其工作,您必须将信息传递给平滑函数的
xt
参数,同时将bs = "ad"
作为自适应基础。
For the cyclic P spline you would do对于循环 P 样条,你会做
y ~ s(x, bs = "ad", xt = list(bs = "cp"))
and for a cyclic cubic spline you would use对于循环三次样条,您将使用
y ~ s(x, bs = "ad", xt = list(bs = "cc"))
The xt
argument is often used for this sort of thing where a basis has other options that can be configured. xt
参数通常用于此类事情,其中基础具有可以配置的其他选项。 The fs
basis is similar, where xt
allows you to control the basis used for the random smooths. fs
基础类似,其中xt
允许您控制用于随机平滑的基础。
The other argument to look at is m
;要查看的另一个参数是
m
; where k
specifies the basis dimension for the actual smooth, you can use m
to set the basis for the adaptive part, with higher m
indicating more potential variation in the penalty over the range of x
, just as k
allows for more wiggliness in the smooth over x
.其中
k
指定了实际平滑的基础维度,您可以使用m
来设置自适应部分的基础,更高的m
表示在x
范围内惩罚的潜在变化更大,就像k
允许平滑中的更多摆动一样在x
。
These details are discussed in ?smooth.construct.ad.smooth.spec
(or ?adaptive.smooth
as a simpler shortcut to that page.)这些细节在
?smooth.construct.ad.smooth.spec
(或?adaptive.smooth
作为该页面的更简单快捷方式)中讨论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.