gssanova1 {gss} | R Documentation |
Fit smoothing spline ANOVA models to responses from selected
exponential families with cubic spline, linear spline, or thin-plate
spline marginals for numerical variables. Factors are also
accepted. The symbolic model specification via formula
follows the same rules as in lm
and glm
.
gssanova1(formula, family, type="cubic", data=list(), weights, subset, offset, na.action=na.omit, partial=NULL, alpha=NULL, nu=NULL, id.basis=NULL, nbasis=NULL, seed=NULL, random=NULL, ext=.05,order=2)
formula |
Symbolic description of the model to be fit. |
family |
Description of the error distribution. Supported
are exponential families "binomial" , "poisson" ,
"Gamma" , and "nbinomial" . Also supported are
accelerated life model families "weibull" ,
"lognorm" , and "loglogis" . |
type |
Type of numerical marginals to be used. Supported
are type="cubic" for cubic spline marginals,
type="linear" for linear spline marginals, and
type="tp" for thin-plate spline marginals. |
data |
Optional data frame containing the variables in the model. |
weights |
Optional vector of weights to be used in the fitting process. |
subset |
Optional vector specifying a subset of observations to be used in the fitting process. |
offset |
Optional offset term with known parameter 1. |
na.action |
Function which indicates what should happen when the data contain NAs. |
partial |
Optional extra unpenalized terms in partial spline models. |
alpha |
Tuning parameter defining cross-validation; larger
values yield smoother fits. Defaults are alpha=1 for
family="binomial" and alpha=1.4 for
family="poisson" and family="Gamma" . |
nu |
Input for future support of accelerated life model families. |
id.basis |
Index designating selected "knots". |
nbasis |
Number of "knots" to be selected. Ignored when
id.basis is supplied. |
seed |
Seed for reproducible random selection of "knots".
Ignored when id.basis is supplied. |
random |
Input for parametric random effects in nonparametric
mixed-effect models. See mkran for details. |
ext |
For cubic spline and linear spline marginals, this option
specifies how far to extend the domain beyond the minimum and
the maximum as a percentage of the range. The default
ext=.05 specifies marginal domains of lengths 110 percent
of their respective ranges. Prediction outside of the domain
will result in an error. Ignored if type="tp" is
specified. |
order |
For thin-plate spline marginals, this option specifies
the order of the marginal penalties. Ignored if
type="cubic" or type="linear" are specified. |
gssanova1
implements an alternative approach to the fitting of
gssanova
models. It works in some q-dimensional
function space determined by a set of "knots" typically through
random selection; the default dimension (nbasis
) is set to be
q=10n^(2/9), adequate for cubic splines. The algorithms are
of the order O(nq^2), scaling much better than the
O(n^3) of ssanova
; the memory requirements are
O(nq) versus O(n^2).
gssanova1
adopts direct cross-validation instead of the
indirect cross-validation of gssanova
. Currently, only three
families are supported, "binomial"
, "poisson"
, and
"Gamma"
. Other families of gssanova
shall be added in
the future.
Only one link is implemented for each family
. It is
the logit link for "binomial"
, and the log link for
"poisson"
, and "Gamma"
.
See ssanova
for details and notes concerning smoothing
spline ANOVA models.
gssanova1
returns a list object of class
"gssanova1"
which inherits from the classes
"ssanova1"
, "gssanova"
, and "ssanova"
.
The method summary
is used to obtain summaries of the
fits. The method predict
can be used to evaluate the
fits at arbitrary points, along with the standard errors to be used
in Bayesian confidence intervals, both on the scale of the link.
The methods residuals
and fitted.values
extract the respective traits from the fits.
For family="binomial"
, the response can be specified either
as two columns of counts or as a column of sample proportions plus a
column of total counts entered through the argument weights
,
as in glm
.
Chong Gu, chong@stat.purdue.edu
gssanova
and methods predict.ssanova1
,
summary.gssanova1
, and fitted.gssanova
.
## Fit a cubic smoothing spline logistic regression model test <- function(x) {.3*(1e6*(x^11*(1-x)^6)+1e4*(x^3*(1-x)^10))-2} x <- (0:100)/100 p <- 1-1/(1+exp(test(x))) y <- rbinom(x,3,p) logit.fit <- gssanova1(cbind(y,3-y)~x,family="binomial") ## The same fit logit.fit1 <- gssanova1(y/3~x,"binomial",weights=rep(3,101), id.basis=logit.fit$id.basis) ## Obtain estimates and standard errors on a grid est <- predict(logit.fit,data.frame(x=x),se=TRUE) ## Plot the fit and the Bayesian confidence intervals plot(x,y/3,ylab="p") lines(x,p,col=1) lines(x,1-1/(1+exp(est$fit)),col=2) lines(x,1-1/(1+exp(est$fit+1.96*est$se)),col=3) lines(x,1-1/(1+exp(est$fit-1.96*est$se)),col=3) ## Fit a mixed-effect logistic model data(bacteriuria) bact.fit <- gssanova1(infect~trt+time,family="binomial",data=bacteriuria, id.basis=(1:820)[bacteriuria$id%in%c(3,38)],random=~1|id) ## Predict fixed effects predict(bact.fit,data.frame(time=2:16,trt=as.factor(rep(1,15))),se=TRUE) ## Estimated random effects bact.fit$b ## Clean up ## Not run: rm(test,x,p,y,logit.fit,logit.fit1,est,bacteriuria,bact.fit) dev.off() ## End(Not run)