Learn R Programming

logitchoice (version 0.9.4)

predict.logitchoice: Make predictions from a "logitchoice" object.

Description

Similar to other predict methods, this function returns fitted values on the response scale.

Usage

"predict"(object, X, grouping, lambda=NULL, ...)

Arguments

object
Fitted "logitchoice" model object.
X
Matrix of new values for which to make predictions. Must have the same number of variables as during training the model.
grouping
Grouping information for choice situations as in logitchoice.
lambda
User input lambda sequence. Must be subset of the lambdas used in fitting. If NULL (the default), predict at all the lambdas used during fitting.
...
Not used. Other arguments to predict.

Value

fitted model.

Details

If lambda is not specified, makes predictions at all the fitted lambda values. Users may provide their own lambda sequence, but this must be a subset of the values used to fit the models.

See Also

logitchoice, predict.logitchoice

Examples

Run this code
  groupSizes = sample(6:18, 100, replace=TRUE)
  numGroups = length(groupSizes)
  n = sum(groupSizes)
  p = 10
  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)))

Run the code above in your browser using DataLab