memy memy - 1 year ago 119
R Question

mgcv: How to set number and / or locations of knots for splines

I want to use function


x <- seq(0,60, len =600)
y <- seq(0,1, len=600)
prova <- gam(y ~ s(x, bs='cr')

can I set the number of knots in
? and then can I know where are the knots that the spline used? Thanks!

Answer Source

knots are k

gam(y ~ s(x, bs='cr', k=5))

if you want the number of knots to be fixed, then

gam(y ~ s(x, bs='cr', k=5, fx=TRUE))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download