Learn R Programming

VGAM (version 0.7-5)

s: Defining smooths in VGAM formulae

Description

s is used in the definition of (vector) smooth terms within vgam formulae.

Usage

s(x, df = 4, spar = 0, ...)

Arguments

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 wil
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. Recycl
...
Ignored for now.

Value

  • A vector with attributes that are used by vgam.

Details

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.

References

Yee, T. W. and Wild, C. J. (1996) Vector generalized additive models. Journal of the Royal Statistical Society, Series B, Methodological, 58, 481--493.

See Also

vgam, vsmooth.spline.

Examples

Run this code
# Nonparametric logistic regression
data(hunua)
fit = vgam(agaaus ~ s(altitude, df=2), binomialff, hunua)
plot(fit, se=TRUE)


# 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)
plot(fit, se=TRUE, which.term= 2, scol="blue")

Run the code above in your browser using DataLab