Last chance! 50% off unlimited learning
Sale ends in
s
is used in the definition of (vector) smooth terms within
vgam
formulae.s(x, df = 4, spar = 0, ...)
x
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
df-1
is the
nonlinear degrees of freedom of the smooth.
Recycling of values wildf
is used.
Recyclvgam
.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 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
,
vsmooth.spline
.# Nonparametric logistic regression
fit = vgam(agaaus ~ s(altitude, df=2), binomialff, hunua)
plot(fit, se=TRUE)
# 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
plot(fit, se=TRUE, which.term= 2, scol="blue")
Run the code above in your browser using DataLab