| shapeselect | R Documentation |
Fits an additive model by selecting variables with shape or order constraints for each predictor using Cone Information Bayesian Criterion (CBIC). The function can perform forward selection or stepwise (forward/backward) updates over a set of candidate shapes appropriate to each predictor type.
shapeselect(
xmat,
y,
types = NULL,
direction = c("both", "forward"),
type = "stepwise",
infocrit = c("CBIC", "CAIC"),
family = gaussian,
control = list(),
...
)
xmat |
A data frame of predictors. Columns may be numeric or factors.
Column names are used in output when available. If x is numeric, then the shape options are
increasing, decreasing, convex, concave or combination of monotonicity and convexity; if x is a
factor, then it can have monotonic or convex ordering options; if x is a factor, the option can also be "in" or "out-of" the model, or "in", "out-of" the model, or
following a "tree" ordering, depending on the |
y |
A response vector of length |
types |
Optional character vector of length |
direction |
Direction of the search. |
type |
Search strategy. |
infocrit |
Information criterion used to decide adding or removing a predictor, and shape updates. Currently supports
|
family |
A GLM family. May be a family function or a character string naming one. Available families are |
control |
A list of control parameters. Any entries not supplied fall back to
|
... |
Additional control parameters (passed as overrides). These are merged into |
The algorithm begins with an intercept-only fit, then evaluates each inactive predictor under
a set of allowable shapes (depending on types). At each step it selects the predictor/shape
combination that improves the chosen information criterion. When direction = "both", it
checks non-chosen shapes for already-selected predictors via backward steps.
Shape and order choices in this implementation include
smooth effects: monotone increasing/decreasing, convex/concave when set4 = TRUE, and combinations set4 = FALSE, if the corresponding value
in types is "num"/"numeric" (x is continuous).
non-smooth effects: monotone increasing/decreasing and convex/concave (when set4 = TRUE), or their combinations (when set4 = FALSE),
if the corresponding value in types is "ord"/"ordinal" (i.e., x is ordinal, categorical, or numeric but treated as
discrete with an inherent ordering).
in types is "ord"/"ordinal" (x is ordinal/categorical/having numeric values but treated as discrete values with ordering).
in or out-of the model, if the corresponding value in types is "nom"/"nominal" (x is categorical)
in, out-of the model or following a tree ordering, if the corresponding value in types is "tree" (i.e., x is categorical or numeric but treated as
discrete with a tree ordering).
An object of class c("shapeselect","cgam"), a list containing (among others):
A matrix recording the selection path (chosen shapes, criterion values, adding or removing a predictor).
Numeric shape codes for each predictor (0 indicates excluded/flat).
Character labels for the selected shapes.
Fitted linear predictor values.
Fitted mean response on the data scale (family$linkinv(etahat)).
Matrix of fitted component contributions by predictor (rows).
Criterion values along the path.
Shrinkage/selection vector (used when type = "classo").
Stored design/basis components for numeric and categorical predictors used for prediction and plotting.
library(MASS)
data("Rubber", package = "MASS")
y <- Rubber[, 1]
xmat <- Rubber[, -1]
ans <- shapeselect(xmat, y, types = c("num", "num"), pnt = FALSE)
print (ans$shapes)
plot(ans)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.