logitchoice: Fit a logit choice model with l2 regularization on the...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/logitchoice.r

Description

The regularization path is computed along a grid of values for the regularization parameter lambda. No standardization is applied to any of the inputs prior to estimation. Unless the model is fit without regularization (lambda = 0), we recommend that the user performs some kind of standardization.

Usage

1
2
logitchoice(X, Y, grouping, lambda=NULL, nLambda=50, lambdaMinRatio=0.01,
tol=1e-3, alpha=0.8, maxIter=5000, verbose=FALSE, numCores=1)

Arguments

X

Matrix of features or predictors with dimension nobs x nvars; each row is an observation vector for a particular alternative. Thus if there are k alternatives for an observation, this observation consists of k rows in X.

Y

Target variable of length nobs. Must contain a single 1 for each choice situation, so that sum(Y) = number of observations

grouping

Grouping information that identifies the choice situations, i.e. if an observation consists of k alternatives, all those k rows in X are assigned to the same group.

lambda

A user supplied lambda sequence. Typical usage is to have the program compute its own lambda sequence based on nLambda and lambdaMinRatio. Supplying a value of lambda overrides this.

nLambda

The number of lambda values. Default is 50.

lambdaMinRatio

Smallest value for lambda, as a fraction of lambdaMax. The default is 0.01.

tol

Convergence tolerance in the adaptive FISTA algorithm.

alpha

Backtracking parameter in majorization-minimization scheme.

maxIter

Maximum number of iterations in adaptive FISTA. Default 5000.

verbose

Prints progress. False by default.

numCores

Number of threads to run. For this to work, the package must be installed with OpenMP enabled. Default is 1 thread.

Details

The sequence of models implied by lambda is fit by FISTA (fast iterative soft thresholding) with adaptive step size and adaptive momentum restart.

Value

An object of class logitchoice with the components

call

The user function call.

betahat

The fitted coefficients, with dimension nVars x nLambda.

yhat

The fitted values, with dimension nobs x nLambda.

residual

Residuals for each lambda.

lambda

The actual lambda sequence used.

objValues

Objective values for each lambda.

numIters

Number of algorithm iterations taken for each fitted lambda value.

Author(s)

Michael Lim
Maintainer: Michael Lim michael626@gmail.com

See Also

predict.logitchoice, coef.logitchoice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
groupSizes = sample(6:18, 100, replace=TRUE)
numGroups = length(groupSizes)
n = sum(groupSizes)
p = 20 
X = matrix(rnorm(n*p), nrow=n)
X = scale(X)
Y = rep(0, n)
Y[cumsum(groupSizes)] = 1
grouping = rep(1:numGroups, groupSizes)
fit = logitchoice(X, Y, grouping)
max(abs(fit$yhat - predict(fit, X, grouping)))

logitchoice documentation built on May 29, 2017, 11:56 a.m.