ps {VGAM} | R Documentation |
ps
is used in the definition of P-spline smooth terms within
vgam
formulas.
ps(x, ..., ps.intervals = NULL, lambda = 0, degree = 2, order = 2, ridge.adj = 1e-5, ridge.inv = 0.0001, spillover = 0.01, maxlambda = 1e4)
x |
covariate (abscissae) to be smoothed.
Also called the regressor.
If the |
... |
Used to accommodate the other M-1 covariates
when the |
ps.intervals |
the number of equally-spaced B-spline intervals.
Note that the number of knots is equal to
|
lambda, maxlambda |
|
degree |
degree of B-spline basis. Usually this will be 2 or 3; and the values 1 or 4 might possibly be used. |
order |
order of difference penalty (0 is the ridge penalty). |
ridge.adj, ridge.inv |
small positive numbers to stabilize linear dependencies among B-spline bases. |
spillover |
small positive proportion of the range used on the outside of the boundary values. |
This function is currently used by vgam
to
allow automatic smoothing parameter selection based on
P-splines and minimizing an UBRE quantity.
It is recommended above s
also because backfitting
is not required.
Unlike s
, which is symbolic and does not perform any smoothing itself,
this function does compute the penalized spline when
used by vgam
.
When this function is used within vgam
, automatic
smoothing parameter selection is implemented by calling
magic
after the necessary link-ups are done.
This function is smart; it can be used for smart prediction (Section 18.6 of Yee (2015)).
A matrix with attributes that are (only) used by vgam
.
The number of rows of the matrix is length(x)
and
the number of columns is ps.intervals + degree - 1
.
This function is currently under development and
may change in the future.
In particular, the default for ps.intervals
is
subject to change.
B. D. Marx wrote the original function. Subsequent edits were made by T. W. Yee and C. Somchit.
Eilers, P. H. C. and Marx, B. D. (2002). Generalized Linear Additive Smooth Structures. Journal of Computational and Graphical Statistics, 11(4): 758–783.
Marx, B. D. and Eilers, P. H. C. (1998). Direct generalized linear modeling with penalized likelihood. CSDA, 28(2): 193–209.
Eilers, P. H. C. and Marx, B. D. (1996). Flexible smoothing with B-splines and penalties (with comments and rejoinder). Statistical Science, 11(2): 89–121.
Wood, S. N. (2004). Stable and efficient multiple smoothing parameter estimation for generalized additive models. J. Amer. Statist. Assoc., 99(467): 673–686.
vgam
,
s
,
smartpred
,
is.smart
,
splineDesign
,
bs
,
magic
.
ps(runif(10)) ps(runif(10), ps.intervals = 5) ## Not run: data("TravelMode", package = "AER") # Need to install "AER" first air.df <- subset(TravelMode, mode == "air") # Form 4 smaller data frames bus.df <- subset(TravelMode, mode == "bus") trn.df <- subset(TravelMode, mode == "train") car.df <- subset(TravelMode, mode == "car") TravelMode2 <- data.frame(income = air.df$income, wait.air = air.df$wait - car.df$wait, wait.trn = trn.df$wait - car.df$wait, wait.bus = bus.df$wait - car.df$wait, gcost.air = air.df$gcost - car.df$gcost, gcost.trn = trn.df$gcost - car.df$gcost, gcost.bus = bus.df$gcost - car.df$gcost, wait = air.df$wait) # Value is unimportant TravelMode2$mode <- subset(TravelMode, choice == "yes")$mode # The response TravelMode2 <- transform(TravelMode2, incom.air = income, incom.trn = 0, incom.bus = 0) set.seed(1) TravelMode2 <- transform(TravelMode2, junkx2 = runif(nrow(TravelMode2))) tfit2 <- vgam(mode ~ ps(gcost.air, gcost.trn, gcost.bus) + ns(junkx2, 4) + ps(incom.air, incom.trn, incom.bus) + wait , crit = "coef", multinomial(parallel = FALSE ~ 1), data = TravelMode2, xij = list(ps(gcost.air, gcost.trn, gcost.bus) ~ ps(gcost.air, gcost.trn, gcost.bus) + ps(gcost.trn, gcost.bus, gcost.air) + ps(gcost.bus, gcost.air, gcost.trn), ps(incom.air, incom.trn, incom.bus) ~ ps(incom.air, incom.trn, incom.bus) + ps(incom.trn, incom.bus, incom.air) + ps(incom.bus, incom.air, incom.trn), wait ~ wait.air + wait.trn + wait.bus), form2 = ~ ps(gcost.air, gcost.trn, gcost.bus) + ps(gcost.trn, gcost.bus, gcost.air) + ps(gcost.bus, gcost.air, gcost.trn) + wait + ps(incom.air, incom.trn, incom.bus) + ps(incom.trn, incom.bus, incom.air) + ps(incom.bus, incom.air, incom.trn) + junkx2 + ns(junkx2, 4) + incom.air + incom.trn + incom.bus + gcost.air + gcost.trn + gcost.bus + wait.air + wait.trn + wait.bus) par(mfrow = c(2, 2)) plot(tfit2, se = TRUE, lcol = "orange", scol = "blue", ylim = c(-4, 4)) ## End(Not run)