简体   繁体   中英

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.

Is there any way to make a cyclic spline (bs = 'cc' or 'cp') adaptive? ... or, equivalently, make an adaptive spline (bs = 'ad') cyclic?

Yes; this is already allowed for in the adaptive spline basis in mgcv .

The default basis in the adaptive spline is a P spline. 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.

For the cyclic P spline you would do

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. The fs basis is similar, where xt allows you to control the basis used for the random smooths.

The other argument to look at is 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 .

These details are discussed in ?smooth.construct.ad.smooth.spec (or ?adaptive.smooth as a simpler shortcut to that page.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM