Description Usage Arguments Details Value Author(s) Examples
k-fold cross-validation to select the polynomial degree and penalization
factor for a polywog
model.
1 2 |
formula |
model formula specifying the response and input variables. |
... |
other arguments to be passed to |
degrees.cv |
vector of polynomial degrees to examine via cross-validation. |
nfolds |
number of folds to use in cross-validation. |
model |
logical: whether to include the model frame in the
|
X |
logical: whether to include the raw model matrix (i.e., the
matrix of input variables prior to taking their polynomial expansion) in
the |
y |
logical: whether to include the response variable in the
|
When fitting with method = "scad"
, different fold assignments are
used for each polynomial degree specified, because cv.ncvreg
does not allow for custom fold assignments. This may affect the accuracy
of the estimated cross-validation error for each degree. When
method = "scad"
, the calls to polywog
made by
cv.polywog
will issue warnings that the foldid
argument is
being ignored.
An object of class "cv.polywog"
, a list containing:
results
A table of each degree tested, the optimal penalization factor λ for that degree, and its cross-validation error.
degree.min
The polynomial degree giving the lowest cross-validation error.
polywog.fit
A polywog
model, fit at the
polynomial degree giving the lowest cross-validation error.
Because the returned object contains the fitted polywog model for the
optimal degree, no additional runs of polywog
are necessary
to estimate coefficients or the penalization factor λ.
However, bootstrap results must be obtained by running
bootPolywog
on the "polywog.fit"
element of the
returned object, as in the examples below.
Brenton Kenkel and Curtis S. Signorino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Using occupational prestige data
data(Prestige, package = "carData")
Prestige <- transform(Prestige, income = income / 1000)
## Examine degrees 1 through 4
## (note: using low convergence threshold to shorten computation time of the
## example, *not* recommended in practice!)
set.seed(39)
cv1 <- cv.polywog(prestige ~ education + income + type,
data = Prestige,
degrees.cv = 1:4,
nfolds = 10,
thresh = 1e-4)
print(cv1)
## Extract best model and bootstrap
fit1 <- cv1$polywog.fit
fit1 <- bootPolywog(fit1, nboot = 5)
summary(fit1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.