Description Usage Arguments Details Value Author(s) References Examples
Fit models with multinomial response (including ordinal regression) with structured penalties.
1 2 3 4 5 6 7 8 | MRSP(formula, data, class.names = NULL, model = multinomlogit(), constr = NULL,
offset = NULL, weights = NULL, penweights = NULL, standardize = TRUE,
nrlambda = 50, lambdamin = 0.01, lambdamax = NULL, control = NULL,
penalty = TRUE, group.classes = TRUE, group.dummies = TRUE,
sparse.groups = FALSE, adaptive = FALSE, threshold = FALSE, refit = FALSE,
lambda, lambdaR = 0, lambdaF = 0, gamma = 1, psi = 1, fusion = FALSE,
nonneg = FALSE, y = NULL, X = NULL, Z = NULL, penindex = NULL,
grpindex = NULL, mlfit = NULL, perform.fit = TRUE, ...)
|
formula |
A symbolic description of the model to be fitted. The left-hand
side specifies the response, which must be a categorical variable with |
data |
A data frame containing the variables in |
class.names |
An optional character vector of length |
model |
An object of class |
constr |
The identifiability constraint to be used. The coefficients of
predictors which do not vary over categories (i.e. global/individual-specific
predictors) are not identifiable in (unpenalized) multinomial logit models.
Either an integer in |
offset |
An optional vector of offsets. Must be of appropriate length. |
weights |
An optional vector of observations weights. Must be of appropriate length. |
penweights |
An object containing weights that modify the penalty terms
on different parameters. See |
standardize |
If |
nrlambda, lambdamin, lambdamax |
If a sequence of |
control |
An object of class |
penalty |
Specifies the general type of penalty to be applied. FALSE
means no penalty is used. |
group.classes |
If |
group.dummies |
If entries on the rhs of |
sparse.groups, gamma |
If |
adaptive |
Should adaptive weights be used? Use |
threshold |
If |
refit |
Should refitting be performed? If |
lambda |
Tuning parameter(s) to be used. Can be a nonnegative scalar or
vector. If missing, |
lambdaR |
Lambda value(s) for ridge penalties. Same structure as
|
lambdaF |
Lambda values(s) for fusion penalties. Same structure as
|
psi |
A numeric that balances the weighting of penalties on global and
class-/category-/alternative-specific predictors (if present) in multinomial
logit models. Penalties on global predictors are weighted with |
fusion |
If fusion penalties are used, this specifies the type of fusion.
Not yet supported for end-users of |
nonneg |
If |
y, X, Z, penindex, grpindex, mlfit |
These optional arguments allow to
supply the corresponding objects directly to |
perform.fit |
If TRUE, the model is fitted. If FALSE, function |
... |
Further arguments to be passed. |
For model = multinomlogit()
, a formula of the form
“Y ~ x | z1 | z2
” yields linear predictors
eta_r = beta_0r + x ' beta_r + z1_r ' gamma + z2_r ' delta_r
for r=1,…,K, which are connected to probabilities by the multinomial logit link, also known as softmax function:
P(Y = r | x, z1, z2) = exp(eta_r) / sum[ exp(eta_s)]_{s=1,...,K}.
This means that the x
-variables have global values that are class-/category-/alternative-unspecific.
The coefficients belonging to those global variables are not identifiable in the
generic form of the multinomial logit model as given above. Therefore, an identifiability
constraint can be specified with argument constr
: By setting constr = r
(with r in [1,K]),
category r
is chosen as reference category. Technically, this means setting beta_r = 0.
Alternatively, constr="symmetric"
specifies a so-called symmetric side constraint, which technically
means imposing that
sum[ beta_sj ]_{s=1,...,K} = 0,
for all j=1,…,p.
If constr = "none"
, no constraint is used for penalized parameter groups and
identifiability is ensured by the penalty term (see Friedman, Hastie and Tibshirani, 2010).
Coefficients of an unpenalized x
-variable are subject to a symmetric side constraint in this case.
The z1
- and z2
-variables are class-/category-/alternative-specific. The z1
-variables
have a global effect while the category-specific z2
-variables are equipped with coefficients
that are also category-specific. Note that no identifiability constraints are required for category-specific variables.
For model = sequentiallogit()
, a formula of the form “Y ~ x1 | x2
”
yields linear predictors of the form
eta_r = beta_0r + x1 ' alpha + x2 ' beta_r
for r=1,…,K-1, which are connected to conditional probabilities via the logit link in the following way:
P(Y = r | Y >= r, x1, x2) = exp(eta_r) / (1 + exp(eta_r))
for r=1,…,K-1.
Note that in the sequential case, slot "mu"
of an MRSP-class
object
contains the unconditional class probabilities P(Y = r). If you want to get the
“discrete” hazard rates P(Y = r | Y >= r), use methods fitted
or
predict
with argument convert2hazard=TRUE
.
Depending on nrlambda
, either an object of class MRSP
or of
class MRSP.list
, which are lists of length
nrlambda
whose elements are MRSP
objects. Additionally, the
attributes “topcall”, “call” and “dat” store, respectively, the call to
MRSP
, the call to MRSP.fit
which was prepared by MRSP
and
the data object to be supplied to MRSP.fit
. Note that
dat
contains the standardized covariates if standardize = TRUE
.
Wolfgang Poessnecker
Tutz, G., Poessnecker, W. and Uhlmann, L. (2015):
Variable Selection in General Multinomial Logit Models
Computational Statistics and Data Analysis, Vol. 82, 207-222.
http://www.sciencedirect.com/science/article/pii/S0167947314002709
Friedman, J., Hastie, T. and Tibshirani, R. (2010):
Regularization Paths for Generalized Linear Models via Coordinate
Descent, http://www.stanford.edu/~hastie/Papers/glmnet.pdf
Journal of Statistical Software, Vol. 33(1), 1-22.
http://www.jstatsoft.org/v33/i01/
Yuan, M. and Lin, Y. (2006):
Model selection and estimation in regression with grouped variables
Journal of the Royal Statistical Society Series B, Vol. 68(1), 49-67.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ## load data
data(TravelMode, package="MRSP")
## bring the response variable to the form required by MRSP
TravelMode$choice <- ifelse(TravelMode$choice=="yes",1,0)
## construct a list of fitted models for different lambda values.
## income is a global predictor, wait is a class-specific predictor with global
## coefficients, vcost and travel are specified as class-specific predictors
## with class-specific coefficients. The fourth category ("car") is chosen as
## reference.
fit <- MRSP(choice~income|wait|vcost+travel, data=TravelMode, constr=4,
class.names=levels(TravelMode$mode), lambdamax=150, nrlambda=10,
group.classes=TRUE, sparse.groups=FALSE, adaptive="ML")
fit
## slots can be extracted from all elements via function 'extract':
BICs <- extract(fit, "BIC")
lambdagrid <- extract(fit, "lambda")
## to select a concrete lambda/model, one can use function 'select'. Here, we
## chose the best model according to its AIC value
bestfit <- select(fit, "AIC")
bestfit
## some methods:
summary(bestfit)
BIC(bestfit)
fitted(bestfit)[1:6,]
bestfit@coef
## get the coefficients belonging to standardized predictors:
coef(bestfit, type="stand")
residuals(bestfit)
predict(bestfit, newdata = TravelMode[1:40,c(4,5,6,8)])
## plot some coefficient paths:
par(mfrow=c(1,2))
## you can either specify the number of the variable...
plot(fit, 2, legendpars=list(x="bottomright"))
## ... or its name as a character string. lcex is the cex parameter for legends.
## set it to zero to disable legend plotting.
plot(fit,"travel", lambda = bestfit@lambda, lcex=0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.