On Monday 25 June 2007 13:26, Bill Wheeler wrote:> I would like to fit a logistic regression using a smothing spline, where
> the spline is a piecewise cubic polynomial. Is the knots option used to
> define the subintervals for each piece of the cubic spline?
- if you use something like
gam(y~s(x,bs="cr",k=5),family=binomial,knots=list(x=c(0,.1,.3,.4,.8))
then yes, k is the number of knots and the `knots' list specifies where they
occur. If you use the default `bs="tp"' then the spline basis
functions are
not really `knot' based, being instead an ordered set of eigenfunctions,
that
are optimal in a defined sense (see Wood, 2003, JRSSB).
> If yes and
> there are k knots, then why does the coefficients field in the returned
> object from gam only list k coefficients? Shouldn't there be 4k -4
> coefficients?
A k knot natural cubic spline only has k free coefficients, so that is all
that mgcv:gam reports. If you are thinking about sections of cubic, then the
other 3 coefficients of each section are determined by the spline continuity
conditions + the conditions of having zero second derivative at the end
knots. Exact details of the `mgcv' "cr" basis are given in section
4.1.2 of
my 2006 book (see ?gam), but all you really need to know is that it's a
natural cubic spline basis parameterized in terms of function heights at the
knots (although there is a gam identifiability constraint absorbed into the
parameterization which muddies this neat interpretability a little).
best,
Simon
> Sincerely,
>
> Bill
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.
-- > Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603 www.maths.bath.ac.uk/~sw283