[R] smoothing binary data

Simon Wood snw at mcs.st-and.ac.uk
Thu Dec 14 11:35:37 CET 2000


You could also try the gam function in package mgcv (latest version
0.3-2). The following uses a penalized regression spline and chooses the
degrees of freedom by GCV:

> library(MASS)
> data(birthwt)
> attach(birthwt)
> library(mgcv)
> gam(low~s(age),family=binomial())

Family: binomial 
Link function: logit 

Formula:
low ~ s(age)

Estimated degrees of freedom:
 4.236948 

Alternatively, if you want more control over the degrees of freedom then
you could use an un-penalized regression spline (although these don't
give such "nice" smooths):

> b<-gam(low~s(age,4|f),family=binomial()) # 4 knot regression spline 
> plot(b)

Simon

  ______________________________________________________________________
> Simon Wood  snw at st-and.ac.uk  http://www.ruwpa.st-and.ac.uk/simon.html
> The Mathematical Institute, North Haugh, St. Andrews, Fife KY16 9SS UK
> Direct telephone: (0)1334 463799          Indirect fax: (0)1334 463748 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list