| s {VGAM} | R Documentation |
s is used in the definition of (vector) smooth terms within
vgam formulae.
s(x, df = 4, spar = 0, ...)
In the following, 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.
x |
covariate (abscissae) to be smoothed.
|
df |
numerical vector of length r.
Effective degrees of freedom: must lie between 1 (linear fit)
and n (interpolation).
Thus one could say that df-1 is the
nonlinear degrees of freedom of the smooth.
Recycling of values will be used if df is not of length r.
|
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 df is used.
Recycling of values will be used if spar is not of length
r.
|
... |
Ignored for now. |
s, which is symbolic and does not perform any smoothing itself,
only handles a single covariate.
It differs from the S-PLUS s and also the one from
the mgcv library. They should not be mixed together.
S-PLUS's s allowed spar to be negative;
VGAM does not allow this.
A vector with attributes that are used by vgam.
The x argument of s() must be a single variable
and not a function of a variable.
For example, s(x) is fine but s(log(x)) will fail.
In this case, let logx <- log(x), say, and use
s(logx).
The vector cubic smoothing spline which s() represents is
computationally demanding for large M. The cost is approximately
O(M^3).
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
data(hunua)
fit = vgam(agaaus ~ s(altitude, df=2), binomialff, hunua)
## Not run:
plot(fit, se=TRUE)
## End(Not run)
# Bivariate logistic model with artificial data
n = 300
mydf = data.frame(x1=runif(n), x2=runif(n))
mydf = transform(mydf,
y1 = ifelse(runif(n) < 1/(1+exp(-sin(2*x2))), 1, 0),
y2 = ifelse(runif(n) < 1/(1+exp(-sin(2*x2))), 1, 0))
fit = vgam(cbind(y1,y2) ~ x1 + s(x2, 3), trace=TRUE,
binom2.or(exchangeable = TRUE ~ s(x2,3)), data=mydf)
coef(fit, matrix=TRUE)
## Not run:
plot(fit, se=TRUE, which.term= 2, scol="blue")
## End(Not run)