s {VGAM} | R Documentation |
s
is used in the definition of (vector) smooth terms within
vgam
formulae.
s(x, df = 4, spar = 0, ...)
x |
covariate (abscissae) to be smoothed.
Note that |
df |
numerical vector of length r.
Effective degrees of freedom: must lie between 1 (linear fit)
and n (interpolation).
Thus one could say that |
spar |
numerical vector of length r.
Positive smoothing parameters (after scaling) .
Larger values mean more smoothing so that the solution approaches
a linear fit for that component function.
A zero value means that |
... |
Ignored for now. |
In this help file M is the number of additive predictors
and r is the number of component functions to be
estimated (so that r is an element from the set
{1,2,...,M}).
Also, if n is the number of distinct abscissae, then
s
will fail if n < 7.
s
, which is symbolic and does not perform any smoothing itself,
only handles a single covariate.
Note that s
works in vgam
only.
It has no effect in vglm
(actually, it is similar to the identity function I
so that s(x2)
is the same as x2
in the LM model matrix).
It differs from the s
of the gam and mgcv packages;
they should not be mixed together.
Also, terms involving s
should be simple additive terms, and not
involving interactions and nesting etc.
For example, myfactor:s(x2)
is not a good idea.
It also differs from the S-PLUS s
which
allows spar
to be negative;
VGAM does not allow this.
A vector with attributes that are (only) used by vgam
.
The vector cubic smoothing spline which s()
represents is
computationally demanding for large M.
The cost is approximately O(M^3).
An alternative to using
s
with vgam
is
bs
and/or ns
with vglm
.
The latter implements half-stepping, which is helpful if
convergence is difficult.
Thomas W. Yee
Yee, T. W. and Wild, C. J. (1996) Vector generalized additive models. Journal of the Royal Statistical Society, Series B, Methodological, 58, 481–493.
# Nonparametric logistic regression fit = vgam(agaaus ~ s(altitude, df=2), binomialff, hunua) ## Not run: plot(fit, se=TRUE) ## End(Not run) # Bivariate logistic model with artificial data nn = 300 mydf = data.frame(x1=runif(nn), x2=runif(nn)) mydf = transform(mydf, y1 = rbinom(nn, size=1, prob=logit(sin(2*x2), inv=TRUE)), y2 = rbinom(nn, size=1, prob=logit(sin(2*x2), inv=TRUE))) fit = vgam(cbind(y1,y2) ~ x1 + s(x2, 3), trace=TRUE, binom2.or(exchangeable = TRUE ~ s(x2,3)), data=mydf) coef(fit, matrix=TRUE) # Hard to interpret ## Not run: plot(fit, se=TRUE, which.term= 2, scol="blue") ## End(Not run)