Title: | Penalized Ordinal Regression |
---|---|
Description: | Fits ordinal regression models with elastic net penalty. Supported model families include cumulative probability, stopping ratio, continuation ratio, and adjacent category. These families are a subset of vector glm's which belong to a model class we call the elementwise link multinomial-ordinal (ELMO) class. Each family in this class links a vector of covariates to a vector of class probabilities. Each of these families has a parallel form, which is appropriate for ordinal response data, as well as a nonparallel form that is appropriate for an unordered categorical response, or as a more flexible model for ordinal data. The parallel model has a single set of coefficients, whereas the nonparallel model has a set of coefficients for each response category except the baseline category. It is also possible to fit a model with both parallel and nonparallel terms, which we call the semi-parallel model. The semi-parallel model has the flexibility of the nonparallel model, but the elastic net penalty shrinks it toward the parallel model. For details, refer to Wurm, Hanlon, and Rathouz (2021) <doi:10.18637/jss.v099.i06>. |
Authors: | Michael Wurm [aut, cre], Paul Rathouz [aut], Bret Hanlon [aut] |
Maintainer: | Michael Wurm <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.12 |
Built: | 2024-12-18 06:57:21 UTC |
Source: | CRAN |
Method to extract fitted coefficients from an "ordinalNet" object.
## S3 method for class 'ordinalNet' coef( object, matrix = FALSE, whichLambda = NULL, criteria = c("aic", "bic"), ... )
## S3 method for class 'ordinalNet' coef( object, matrix = FALSE, whichLambda = NULL, criteria = c("aic", "bic"), ... )
object |
An "ordinalNet" S3 object. |
matrix |
Logical. If |
whichLambda |
Optional index number of the desired |
criteria |
Selects the best |
... |
Not used. Additional coef arguments. |
The object returned depends on matrix
.
# See ordinalNet() documentation for examples.
# See ordinalNet() documentation for examples.
Fits ordinal regression models with elastic net penalty by coordinate descent. Supported model families include cumulative probability, stopping ratio, continuation ratio, and adjacent category. These families are a subset of vector glm's which belong to a model class we call the elementwise link multinomial-ordinal (ELMO) class. Each family in this class links a vector of covariates to a vector of class probabilities. Each of these families has a parallel form, which is appropriate for ordinal response data, as well as a nonparallel form that is appropriate for an unordered categorical response, or as a more flexible model for ordinal data. The parallel model has a single set of coefficients, whereas the nonparallel model has a set of coefficients for each response category except the baseline category. It is also possible to fit a model with both parallel and nonparallel terms, which we call the semi-parallel model. The semi-parallel model has the flexibility of the nonparallel model, but the elastic net penalty shrinks it toward the parallel model.
ordinalNet( x, y, alpha = 1, standardize = TRUE, penaltyFactors = NULL, positiveID = NULL, family = c("cumulative", "sratio", "cratio", "acat"), reverse = FALSE, link = c("logit", "probit", "cloglog", "cauchit"), customLink = NULL, parallelTerms = TRUE, nonparallelTerms = FALSE, parallelPenaltyFactor = 1, lambdaVals = NULL, nLambda = 20, lambdaMinRatio = 0.01, includeLambda0 = FALSE, alphaMin = 0.01, pMin = 1e-08, stopThresh = 1e-08, threshOut = 1e-08, threshIn = 1e-08, maxiterOut = 100, maxiterIn = 100, printIter = FALSE, printBeta = FALSE, warn = TRUE, keepTrainingData = TRUE )
ordinalNet( x, y, alpha = 1, standardize = TRUE, penaltyFactors = NULL, positiveID = NULL, family = c("cumulative", "sratio", "cratio", "acat"), reverse = FALSE, link = c("logit", "probit", "cloglog", "cauchit"), customLink = NULL, parallelTerms = TRUE, nonparallelTerms = FALSE, parallelPenaltyFactor = 1, lambdaVals = NULL, nLambda = 20, lambdaMinRatio = 0.01, includeLambda0 = FALSE, alphaMin = 0.01, pMin = 1e-08, stopThresh = 1e-08, threshOut = 1e-08, threshIn = 1e-08, maxiterOut = 100, maxiterIn = 100, printIter = FALSE, printBeta = FALSE, warn = TRUE, keepTrainingData = TRUE )
x |
Covariate matrix. It is recommended that categorical covariates are converted to a set of indicator variables with a variable for each category (i.e. no baseline category); otherwise the choice of baseline category will affect the model fit. |
y |
Response variable. Can be a factor, ordered factor, or a matrix where each row is a multinomial vector of counts. A weighted fit can be obtained using the matrix option, since the row sums are essentially observation weights. Non-integer matrix entries are allowed. |
alpha |
The elastic net mixing parameter, with |
standardize |
If |
penaltyFactors |
Optional nonnegative vector of penalty factors with
length equal to the number of columns in |
positiveID |
Logical vector indicating whether each coefficient should
be constrained to be non-negative. If |
family |
Specifies the type of model family. Options are "cumulative" for cumulative probability, "sratio" for stopping ratio, "cratio" for continuation ratio, and "acat" for adjacent category. |
reverse |
Logical. If |
link |
Specifies the link function. The options supported are logit,
probit, complementary log-log, and cauchit. Only used if |
customLink |
Optional list containing a vectorized link function |
parallelTerms |
Logical. If |
nonparallelTerms |
Logical. if |
parallelPenaltyFactor |
Nonnegative numeric value equal to one by
default. The penalty on all parallel terms is scaled by this factor (as well
as variable-specific |
lambdaVals |
An optional user-specified lambda sequence (vector). If |
nLambda |
Positive integer. The number of lambda values in the solution path.
Only used if |
lambdaMinRatio |
A factor greater than zero and less than one. Only used
if |
includeLambda0 |
Logical. If |
alphaMin |
|
pMin |
Value greater than zero, but much less than one. During the optimization routine, the Fisher information is calculated using fitted probabilities. For this calculation, fitted probabilities are capped below by this value to prevent numerical instability. |
stopThresh |
In the relative log-likelihood change between successive lambda values falls below this threshold, then the last model fit is used for all remaining lambda. |
threshOut |
Convergence threshold for the coordinate descent outer loop.
The optimization routine terminates when the relative change in the
penalized log-likelihood between successive iterations falls below this threshold.
It is recommended to set |
threshIn |
Convergence threshold for the coordinate descent inner loop. Each
iteration consists of a single loop through each coefficient. The inner
loop terminates when the relative change in the penalized approximate
log-likelihood between successive iterations falls below this threshold.
It is recommended to set |
maxiterOut |
Maximum number of outer loop iterations. |
maxiterIn |
Maximum number of inner loop iterations. |
printIter |
Logical. If |
printBeta |
Logical. If |
warn |
Logical. If |
keepTrainingData |
Logical. If |
The ordinalNet
function fits regression models for a categorical response
variable with levels. Conditional on the covariate vector
(the
row of
x
), each observation has a vector of
class probabilities
. These probabilities
sum to one, and can therefore be parametrized by
.
The probabilities are mapped to a set of
quantities
, which depends on the choice
of model
family
. The elementwise link
function maps
to a set of
linear predictors. Together, the
family
and link
specifiy a link function between and
.
Model families:
Let denote the random response variable for a single observation,
conditional on the covariates values of the observation. The random variable
is discrete with support {
}. The following model
families are defined according to these mappings between the class
probabilities and the values
:
Parallel, nonparallel, and semi-parallel model forms:
Models within each of these families can take one of three forms, which have
different definitions for the linear predictor . Suppose each
has length
. Let
be a length
vector of
regression coefficients. Let
be a
matrix of regression
coefficient. Let
be a vector of
intercept terms.
The three model forms are the following:
(
parallelTerms=TRUE
, nonparallelTerms=FALSE
)
(
parallelTerms=FALSE
, nonparallelTerms=TRUE
)
(
parallelTerms=TRUE
, nonparallelTerms=TRUE
)
The parallel form has the defining property of ordinal models, which is that
a single linear combination shifts the cumulative class probabilities
in favor of either higher or lower categories. The linear predictors
are parallel because they only differ by their intercepts (
). The nonparallel form
is a more flexible model, and it does not shift the cumulative probabilities together.
The semi-parallel model is equivalent to the nonparallel model, but the
elastic net penalty shrinks the semi-parallel coefficients toward a common
value (i.e. the parallel model), as well as shrinking all coefficients toward zero.
The nonparallel model, on the other hand, simply shrinks all coefficients toward zero.
When the response categories are ordinal, any of the three model forms could
be applied. When the response categories are unordered, only the nonparallel
model is appropriate.
Elastic net penalty:
The elastic net penalty is defined for each model form as follows.
and
are the usual elastic net tuning parameters, where
determines the degree to which coefficients are shrunk toward zero, and
specifies the amound of weight given to the L1 norm and squared L2 norm penalties.
Each covariate is allowed a unique penalty factor
, which is specified with the
penaltyFactors
argument. By default for all
.
The semi-parallel model has a tuning parameter
which determines the degree to
which the parallel coefficients are penalized. Small values of
will
result in a fit closer to the parallel model, and large values of
will result in a fit closer to the nonparallel model.
ordinalNet
minimizes the following objective function. Let be
the number of observations, which is defined as the sum of the
y
elements
when y
is a matrix.
An object with S3 class "ordinalNet". Model fit information can be accessed
through the coef
, predict
, and summary
methods.
Matrix of coefficient estimates, with each row corresponding to a lambda value.
(If covariates were scaled with standardize=TRUE
, the coefficients are
returned on the original scale).
Sequence of lambda values. If user passed a sequence to the
lambdaVals
, then it is this sequence. If lambdaVals
argument
was NULL
, then it is the sequence generated.
Log-likelihood of each model fit.
Number of nonzero coefficients of each model fit, including intercepts.
AIC, defined as -2*loglik + 2*nNonzero
.
BIC, defined as -2*loglik + log(N)*nNonzero
.
Percentage deviance explained, defined as ,
where
is the log-likelihood of the null model.
Number of coordinate descent outer loop iterations until convergence for each lambda value.
Number of coordinate descent inner loop iterations on last outer loop for each lambda value.
Relative improvement in objective function on last outer loop
for each lambda value. Can be used to diagnose convergence issues. If iterOut
reached maxiterOut
and dif
is large, then maxiterOut
should
be increased. If dif
is negative, this means the objective did not improve
between successive iterations. This usually only occurs when the model is
saturated and/or close to convergence, so a small negative value is not of concern.
(When this happens, the algorithm is terminated for the current lambda value,
and the coefficient estimates from the previous outer loop iteration are returned.)
Number of response categories.
Number of covariates in x
.
Covariate names.
List of arguments passed to the ordinalNet
function.
# Simulate x as independent standard normal # Simulate y|x from a parallel cumulative logit (proportional odds) model set.seed(1) n <- 50 intercepts <- c(-1, 1) beta <- c(1, 1, 0, 0, 0) ncat <- length(intercepts) + 1 # number of response categories p <- length(beta) # number of covariates x <- matrix(rnorm(n*p), ncol=p) # n x p covariate matrix eta <- c(x %*% beta) + matrix(intercepts, nrow=n, ncol=ncat-1, byrow=TRUE) invlogit <- function(x) 1 / (1+exp(-x)) cumprob <- t(apply(eta, 1, invlogit)) prob <- cbind(cumprob, 1) - cbind(0, cumprob) yint <- apply(prob, 1, function(p) sample(1:ncat, size=1, prob=p)) y <- as.factor(yint) # Fit parallel cumulative logit model fit1 <- ordinalNet(x, y, family="cumulative", link="logit", parallelTerms=TRUE, nonparallelTerms=FALSE) summary(fit1) coef(fit1) coef(fit1, matrix=TRUE) predict(fit1, type="response") predict(fit1, type="class") # Fit nonparallel cumulative logit model fit2 <- ordinalNet(x, y, family="cumulative", link="logit", parallelTerms=FALSE, nonparallelTerms=TRUE) fit2 coef(fit2) coef(fit2, matrix=TRUE) predict(fit2, type="response") predict(fit2, type="class") # Fit semi-parallel cumulative logit model (with both parallel and nonparallel terms) fit3 <- ordinalNet(x, y, family="cumulative", link="logit", parallelTerms=TRUE, nonparallelTerms=TRUE) fit3 coef(fit3) coef(fit3, matrix=TRUE) predict(fit3, type="response") predict(fit3, type="class")
# Simulate x as independent standard normal # Simulate y|x from a parallel cumulative logit (proportional odds) model set.seed(1) n <- 50 intercepts <- c(-1, 1) beta <- c(1, 1, 0, 0, 0) ncat <- length(intercepts) + 1 # number of response categories p <- length(beta) # number of covariates x <- matrix(rnorm(n*p), ncol=p) # n x p covariate matrix eta <- c(x %*% beta) + matrix(intercepts, nrow=n, ncol=ncat-1, byrow=TRUE) invlogit <- function(x) 1 / (1+exp(-x)) cumprob <- t(apply(eta, 1, invlogit)) prob <- cbind(cumprob, 1) - cbind(0, cumprob) yint <- apply(prob, 1, function(p) sample(1:ncat, size=1, prob=p)) y <- as.factor(yint) # Fit parallel cumulative logit model fit1 <- ordinalNet(x, y, family="cumulative", link="logit", parallelTerms=TRUE, nonparallelTerms=FALSE) summary(fit1) coef(fit1) coef(fit1, matrix=TRUE) predict(fit1, type="response") predict(fit1, type="class") # Fit nonparallel cumulative logit model fit2 <- ordinalNet(x, y, family="cumulative", link="logit", parallelTerms=FALSE, nonparallelTerms=TRUE) fit2 coef(fit2) coef(fit2, matrix=TRUE) predict(fit2, type="response") predict(fit2, type="class") # Fit semi-parallel cumulative logit model (with both parallel and nonparallel terms) fit3 <- ordinalNet(x, y, family="cumulative", link="logit", parallelTerms=TRUE, nonparallelTerms=TRUE) fit3 coef(fit3) coef(fit3, matrix=TRUE) predict(fit3, type="response") predict(fit3, type="class")
The data is divided into K folds. ordinalNet
is fit times, each time
leaving out one fold as a test set. For each of the
model fits, lambda
can be tuned by AIC or BIC, or cross validation. If cross validation is used,
the user can choose whether to user the best average out-of-sample log-likelihood,
misclassification rate, Brier score, or percentage of deviance explained.
The user can also choose the number of cross validation folds to use for tuning.
Once the model is tuned, the out of sample log-likelihood,
misclassification rate, Brier score, and percentage of deviance explained
are calculated on the held out test set.
ordinalNetCV( x, y, lambdaVals = NULL, folds = NULL, nFolds = 5, nFoldsCV = 5, tuneMethod = c("cvLoglik", "cvMisclass", "cvBrier", "cvDevPct", "aic", "bic"), printProgress = TRUE, warn = TRUE, ... )
ordinalNetCV( x, y, lambdaVals = NULL, folds = NULL, nFolds = 5, nFoldsCV = 5, tuneMethod = c("cvLoglik", "cvMisclass", "cvBrier", "cvDevPct", "aic", "bic"), printProgress = TRUE, warn = TRUE, ... )
x |
Covariate matrix. |
y |
Response variable. Can be a factor, ordered factor, or a matrix where each row is a multinomial vector of counts. A weighted fit can be obtained using the matrix option, since the row sums are essentially observation weights. Non-integer matrix entries are allowed. |
lambdaVals |
An optional user-specified lambda sequence (vector). If |
folds |
An optional list, where each element is a vector of row indices
corresponding to a different cross validation fold. Indices correspond to rows
of the |
nFolds |
Numer of cross validation folds. Only used if |
nFoldsCV |
Number of cross validation folds used to tune lambda for each
training set (i.e. within each training fold). Only used of |
tuneMethod |
Method used to tune lambda for each training set (ie. within
each training fold). The "cvLoglik", "cvMisclass", "cvBrier", and "cvDevPct"
methods use cross validation with |
printProgress |
Logical. If |
warn |
Logical. If |
... |
Other arguments (besides |
The fold partition splits can be passed by the user via the folds
argument. By default, the data are randomly divided into equally-sized partitions.
Note that if lambda is tuned by cross validation, the fold splits are
determined randomly and cannot be specified by the user. The set.seed
function should be called prior to ordinalNetCV
for reproducibility.
A sequence of lambda values can be passed by the user via the
lambdaVals
argument. By default, the sequence is generated by first
fitting the model to the full data set (this sequence is determined by the
nLambda
and lambdaMinRatio
arguments of ordinalNet
).
The standardize
argument of ordinalNet
can be modified through
the additional arguments (...). If standardize=TRUE
, then the data are scaled
within each cross validation fold. If standardize=TRUE
and lambda is tuned by
cross validation, then the data are also scaled within each tuning sub-fold.
This is done because scaling is part of the statistical procedure and should
be repeated each time the procedure is applied.
An S3 object of class "ordinalNetCV", which contains the following:
Vector of out-of-sample log-likelihood values. Each value corresponds to a different fold.
Vector of out-of-sample misclassificaton rates. Each value corresponds to a different fold.
Vector of out-of-sample Brier scores. Each value corresponds to a different fold.
Vector of out-of-sample percentages of deviance explained. Each value corresponds to a different fold.
The index of the value within the lambda sequence selected for each fold by the tuning method.
The sequence of lambda values used for all cross validation folds.
A list containing the index numbers of each fold.
An object of class "ordinalNet", resulting from fitting
ordinalNet
to the entire dataset.
## Not run: # Simulate x as independent standard normal # Simulate y|x from a parallel cumulative logit (proportional odds) model set.seed(1) n <- 50 intercepts <- c(-1, 1) beta <- c(1, 1, 0, 0, 0) ncat <- length(intercepts) + 1 # number of response categories p <- length(beta) # number of covariates x <- matrix(rnorm(n*p), ncol=p) # n x p covariate matrix eta <- c(x %*% beta) + matrix(intercepts, nrow=n, ncol=ncat-1, byrow=TRUE) invlogit <- function(x) 1 / (1+exp(-x)) cumprob <- t(apply(eta, 1, invlogit)) prob <- cbind(cumprob, 1) - cbind(0, cumprob) yint <- apply(prob, 1, function(p) sample(1:ncat, size=1, prob=p)) y <- as.factor(yint) # Evaluate out-of-sample performance of the cumulative logit model # when lambda is tuned by cross validation (best average out-of-sample log-likelihood) cv <- ordinalNetCV(x, y, tuneMethod="cvLoglik") summary(cv) ## End(Not run)
## Not run: # Simulate x as independent standard normal # Simulate y|x from a parallel cumulative logit (proportional odds) model set.seed(1) n <- 50 intercepts <- c(-1, 1) beta <- c(1, 1, 0, 0, 0) ncat <- length(intercepts) + 1 # number of response categories p <- length(beta) # number of covariates x <- matrix(rnorm(n*p), ncol=p) # n x p covariate matrix eta <- c(x %*% beta) + matrix(intercepts, nrow=n, ncol=ncat-1, byrow=TRUE) invlogit <- function(x) 1 / (1+exp(-x)) cumprob <- t(apply(eta, 1, invlogit)) prob <- cbind(cumprob, 1) - cbind(0, cumprob) yint <- apply(prob, 1, function(p) sample(1:ncat, size=1, prob=p)) y <- as.factor(yint) # Evaluate out-of-sample performance of the cumulative logit model # when lambda is tuned by cross validation (best average out-of-sample log-likelihood) cv <- ordinalNetCV(x, y, tuneMethod="cvLoglik") summary(cv) ## End(Not run)
The data is divided into K folds. ordinalNet
is fit times (
K=nFolds
),
each time leaving out one fold as a test set. The same sequence of lambda values is used
each time. The out-of-sample log-likelihood, misclassification rate, Brier score,
and percentage of deviance explained are obtained for each lambda value from
the held out test set. It is up to the user to determine how to tune the model
using this information.
ordinalNetTune( x, y, lambdaVals = NULL, folds = NULL, nFolds = 5, printProgress = TRUE, warn = TRUE, ... )
ordinalNetTune( x, y, lambdaVals = NULL, folds = NULL, nFolds = 5, printProgress = TRUE, warn = TRUE, ... )
x |
Covariate matrix. |
y |
Response variable. Can be a factor, ordered factor, or a matrix where each row is a multinomial vector of counts. A weighted fit can be obtained using the matrix option, since the row sums are essentially observation weights. Non-integer matrix entries are allowed. |
lambdaVals |
An optional user-specified lambda sequence (vector). If |
folds |
An optional list, where each element is a vector of row indices
corresponding to a different cross validation fold. Indices correspond to rows
of the |
nFolds |
Numer of cross validation folds. Only used if |
printProgress |
Logical. If |
warn |
Logical. If |
... |
Other arguments (besides |
The fold partition splits can be passed by the user via the folds
argument. By default, the data are randomly divided into equally-sized partitions.
The set.seed
function should be called prior to ordinalNetCV
for reproducibility.
A sequence of lambda values can be passed by the user via the
lambdaVals
argument. By default, the sequence is generated by first
fitting the model to the full data set (this sequence is determined by the
nLambda
and lambdaMinRatio
arguments of ordinalNet
).
The standardize
argument of ordinalNet
can be modified through
the additional arguments (...). If standardize=TRUE
, then the data are scaled
within each cross validation fold. This is done because scaling is part of
the statistical procedure and should be repeated each time the procedure is applied.
An S3 object of class "ordinalNetTune", which contains the following:
Matrix of out-of-sample log-likelihood values. Each row corresponds to a lambda value, and each column corresponds to a fold.
Matrix of out-of-sample misclassificaton rates. Each row corresponds to a lambda value, and each column corresponds to a fold.
Matrix of out-of-sample Brier scores. Each row corresponds to a lambda value, and each column corresponds to a fold.
Matrix of out-of-sample percentages of deviance explained. Each row corresponds to a lambda value, and each column corresponds to a fold.
The sequence of lambda values used for all cross validation folds.
A list containing the index numbers of each fold.
An object of class "ordinalNet", resulting from fitting
ordinalNet
to the entire dataset.
## Not run: # Simulate x as independent standard normal # Simulate y|x from a parallel cumulative logit (proportional odds) model set.seed(1) n <- 50 intercepts <- c(-1, 1) beta <- c(1, 1, 0, 0, 0) ncat <- length(intercepts) + 1 # number of response categories p <- length(beta) # number of covariates x <- matrix(rnorm(n*p), ncol=p) # n x p covariate matrix eta <- c(x %*% beta) + matrix(intercepts, nrow=n, ncol=ncat-1, byrow=TRUE) invlogit <- function(x) 1 / (1+exp(-x)) cumprob <- t(apply(eta, 1, invlogit)) prob <- cbind(cumprob, 1) - cbind(0, cumprob) yint <- apply(prob, 1, function(p) sample(1:ncat, size=1, prob=p)) y <- as.factor(yint) # Fit parallel cumulative logit model; select lambda by cross validation tunefit <- ordinalNetTune(x, y) summary(tunefit) plot(tunefit) bestLambdaIndex <- which.max(rowMeans(tunefit$loglik)) coef(tunefit$fit, whichLambda=bestLambdaIndex, matrix=TRUE) predict(tunefit$fit, whichLambda=bestLambdaIndex) ## End(Not run)
## Not run: # Simulate x as independent standard normal # Simulate y|x from a parallel cumulative logit (proportional odds) model set.seed(1) n <- 50 intercepts <- c(-1, 1) beta <- c(1, 1, 0, 0, 0) ncat <- length(intercepts) + 1 # number of response categories p <- length(beta) # number of covariates x <- matrix(rnorm(n*p), ncol=p) # n x p covariate matrix eta <- c(x %*% beta) + matrix(intercepts, nrow=n, ncol=ncat-1, byrow=TRUE) invlogit <- function(x) 1 / (1+exp(-x)) cumprob <- t(apply(eta, 1, invlogit)) prob <- cbind(cumprob, 1) - cbind(0, cumprob) yint <- apply(prob, 1, function(p) sample(1:ncat, size=1, prob=p)) y <- as.factor(yint) # Fit parallel cumulative logit model; select lambda by cross validation tunefit <- ordinalNetTune(x, y) summary(tunefit) plot(tunefit) bestLambdaIndex <- which.max(rowMeans(tunefit$loglik)) coef(tunefit$fit, whichLambda=bestLambdaIndex, matrix=TRUE) predict(tunefit$fit, whichLambda=bestLambdaIndex) ## End(Not run)
Plots the average out-of-sample log-likelihood, misclassification rate, Brier score, or percentage of deviance explained for each lambda value in the solution path. The averae is taken over all cross validation folds.
## S3 method for class 'ordinalNetTune' plot(x, type = c("loglik", "misclass", "brier", "devPct"), ...)
## S3 method for class 'ordinalNetTune' plot(x, type = c("loglik", "misclass", "brier", "devPct"), ...)
x |
An "ordinalNetTune" S3 object. |
type |
Which performance measure to plot. Either "loglik", "misclass", "brier", or "devPct". |
... |
Additional plot arguments. |
# See ordinalNetTune() documentation for examples.
# See ordinalNetTune() documentation for examples.
Obtains predicted probabilities, predicted class, or linear predictors.
## S3 method for class 'ordinalNet' predict( object, newx = NULL, whichLambda = NULL, criteria = c("aic", "bic"), type = c("response", "class", "link"), ... )
## S3 method for class 'ordinalNet' predict( object, newx = NULL, whichLambda = NULL, criteria = c("aic", "bic"), type = c("response", "class", "link"), ... )
object |
An "ordinalNet" S3 object. |
newx |
Optional covariate matrix. If NULL, fitted values will be obtained
for the training data, as long as the model was fit with the argument
|
whichLambda |
Optional index number of the desired lambda value within the solution path sequence. |
criteria |
Selects the best lambda value by AIC or BIC. Only used
if |
type |
The type of prediction required. Type "response" returns a matrix of fitted probabilities. Type "class" returns a vector containing the class number with the highest fitted probability. Type "link" returns a matrix of linear predictors. |
... |
Not used. Additional predict arguments. |
The object returned depends on type
.
# See ordinalNet() documentation for examples.
# See ordinalNet() documentation for examples.
Prints the data frame returned by the summary.ordinalNet()
method.
## S3 method for class 'ordinalNet' print(x, ...)
## S3 method for class 'ordinalNet' print(x, ...)
x |
An "ordinalNet" S3 object |
... |
Not used. Additional plot arguments. |
# See ordinalNet() documentation for examples.
# See ordinalNet() documentation for examples.
Prints the data frame returned by the summary.ordinalNetCV()
method.
## S3 method for class 'ordinalNetCV' print(x, ...)
## S3 method for class 'ordinalNetCV' print(x, ...)
x |
An "ordinalNetCV" S3 object |
... |
Not used. Additional print arguments. |
# See ordinalNetCV() documentation for examples.
# See ordinalNetCV() documentation for examples.
Prints the data frame returned by the summary.ordinalNetTune()
method.
## S3 method for class 'ordinalNetTune' print(x, ...)
## S3 method for class 'ordinalNetTune' print(x, ...)
x |
An "ordinalNetTune" S3 object. |
... |
Not used. Additional print arguments. |
# See ordinalNetTune() documentation for examples.
# See ordinalNetTune() documentation for examples.
Provides a data frame which summarizes the model fit at each lambda value in the solution path.model fit summary as a data frame.
## S3 method for class 'ordinalNet' summary(object, ...)
## S3 method for class 'ordinalNet' summary(object, ...)
object |
An "ordinalNet" S3 object |
... |
Not used. Additional summary arguments. |
A data frame containing a record for each lambda value in the solution path. Each record contains the following fields: lambda value, degrees of freedom (number of nonzero parameters), log-likelihood, AIC, BIC, and percent deviance explained.
# See ordinalNet() documentation for examples.
# See ordinalNet() documentation for examples.
Provides a data frame which summarizes the cross validation results, which can be used as an estimate of the out-of-sample performance of a model tuned by a particular method.
## S3 method for class 'ordinalNetCV' summary(object, ...)
## S3 method for class 'ordinalNetCV' summary(object, ...)
object |
An "ordinalNetCV" S3 object |
... |
Not used. Additional summary arguments. |
A data frame containing a record for each cross validation fold. Each record contains the following: lambda value, log-likelihood, misclassification rate, Brier score, and percentage of deviance explained.
# See ordinalNetCV() documentation for examples.
# See ordinalNetCV() documentation for examples.
Provides a data frame which summarizes the cross validation results and may be useful for selecting an appropriate value for the tuning parameter lambda.
## S3 method for class 'ordinalNetTune' summary(object, ...)
## S3 method for class 'ordinalNetTune' summary(object, ...)
object |
An "ordinalNetTune" S3 object. |
... |
Not used. Additional summary arguments. |
A data frame containing a record for each lambda value in the solution path. Each record contains the following: lambda value, average log-likelihood, average misclassification rate, average Brier score, and average percentage of deviance explained. Averages are taken across all cross validation folds.
# See ordinalNetTune() documentation for examples.
# See ordinalNetTune() documentation for examples.