[R-sig-ME] Natural spline (i.e. ns() ) with glmer()/lmer()
John Maindonald
john@m@|ndon@|d @end|ng |rom @nu@edu@@u
Sat May 22 23:16:58 CEST 2021
It is worth checking how the choice of basis and end conditions (if any)
affects the range of shapes that can be fitted. Try
lattice::xyplot(ns(1:10,2)[,1]+ns(1:10,2)[,2] ~ I(1:10))
The basis is well suited to modeling a cup up or cup down shape with the
mode shifted somewhat to the right or left of center.
John Maindonald email: john.maindonald using anu.edu.au<mailto:john.maindonald using anu.edu.au>
On 23/05/2021, at 00:35, Lenth, Russell V <russell-lenth using uiowa.edu<mailto:russell-lenth using uiowa.edu>> wrote:
Regardless of what kind of model is used, a natural cubic spline hwo end conditions -- that the second derivative is zero at each end. If there are no interior knots, then that forces it to be a straight line. (Consider a cubic polynomial has four parameters, and we have imposed two constraints, reducing it to two parameters, the slope and the intercept).
With one interior knot, you do get two cubic polynomials, but with the condition that each end is an inflection point.
Russell V. Lenth - Professor Emeritus
Department of Statistics and Actuarial Science
The University of Iowa - Iowa City, IA 52242 USA
Voice (319)335-0712 (Dept. office) - FAX (319)335-3017
-----Original Message-----
Just a clarification, when I say "third degree polynomial" I mean, it generates a basis matrix for representing the family of piecewise-cubic splines with the specified sequence of interior knots, and the natural boundary conditions.
-----------
I would like to double check my understanding with the followings:
1 - In a linear mixed model if I use ns() for a continuous variable with for example one knot then I'll have two pieces of natural splines (i.e. third degree polynomial) one before the knot and one after the knot.
2 - But if I run the same ns() in a linear mixed model without any knots, does that mean I am fitting one 3rd degree polynomial between the boundaries (i.e. over the range of my continuous variable)?
Best,
Hedyeh Ahmadi, Ph.D.
Applied Statistician
Keck School of Medicine
Department of Preventive Medicine
University of Southern California
Postdoctoral Scholar
Institute for Interdisciplinary Salivary Bioscience Research (IISBR)
University of California, Irvine
_______________________________________________
R-sig-mixed-models using r-project.org<mailto:R-sig-mixed-models using r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list