Title: | Boosting Conditional Logit Model |
---|---|
Description: | A set of functions to fit a boosting conditional logit model. |
Authors: | Haolun Shi and Guosheng Yin |
Maintainer: | Haolun Shi <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1 |
Built: | 2025-03-25 03:03:42 UTC |
Source: | https://github.com/cran/clogitboost |
Fit a boosting conditional logit model using componentwise smoothing spline.
clogitboost(y, x, strata, iter, rho)
clogitboost(y, x, strata, iter, rho)
y |
vector of binary outcomes. |
x |
matrix or data frame with each column being a covariate. |
strata |
vector of group membership, i.e., items in the same group have the same value. |
iter |
number of iterations. |
rho |
learning rate parameter in the boosting algorithm. |
The function clogitboost
returns the following list of values:
call |
original function call. |
func |
list of fitted spline functions. |
index |
list of indices indicating which covariate is used as input for the smoothing spline. |
theta |
list of fitted coefficients in the conditional logit models. |
loglike |
sequence of fitted values of log-likelihood. |
infscore |
relative influence score for each covariate. |
rho |
learning rate parameter, which typically takes a value of 0.05 or 0.1. |
xmax |
maximal element of each covariate. |
xmin |
minimal element of each covariate. |
Haolun Shi [email protected]
Guosheng Yin [email protected]
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05)
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05)
marginal
function for the clogitboost
objects, which produces the marginal utility values of a covariate.
marginal(x, grid, d)
marginal(x, grid, d)
x |
output object from the |
d |
integer indicating which covariate is used. |
grid |
grid of values for predicting the marginal utilities. |
The method marginal
returns a vector of predicted marginal utilities based on the grid input.
Haolun Shi [email protected]
Guosheng Yin [email protected]
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) marginal(fit, grid = seq(0, 10, by = 1), d = 1)
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) marginal(fit, grid = seq(0, 10, by = 1), d = 1)
plot
methods for the clogitboost
objects, which produce marginal plots of the covariate effects.
## S3 method for class 'clogitboost' plot(x, d, grid = NULL, ...)
## S3 method for class 'clogitboost' plot(x, d, grid = NULL, ...)
x |
output object from the |
d |
integer indicating which covariate is used. |
grid |
grid of values for plotting. If it is not specified, the minimal and maximal elements of the covariate are used as the two endpoints of the grid. |
... |
other options for plotting. |
Haolun Shi [email protected]
Guosheng Yin [email protected]
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) plot(fit, d = 1, xlab = "x", ylab = "f(x)", main = "TTIME", type = "l")
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) plot(fit, d = 1, xlab = "x", ylab = "f(x)", main = "TTIME", type = "l")
predict
methods for the clogitboost
objects, which produce marginal predictions of the covariate effects.
## S3 method for class 'clogitboost' predict(object, x, strata, ...)
## S3 method for class 'clogitboost' predict(object, x, strata, ...)
object |
output object from the |
x |
new matrix or data frame with each column being a covariate. |
strata |
new vector of group memberships, i.e., items in the same group have the same value. |
... |
not currently used. |
The method predict
returns the following list of values:
prob |
probability of the outcome equal to 1. |
utility |
predicted utility. |
prediction |
0-1 prediction of the outcome variable. |
Haolun Shi [email protected]
Guosheng Yin [email protected]
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) predict(fit, x = travel[-train, 3:6], strata = travel$Group[-train])
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) predict(fit, x = travel[-train, 3:6], strata = travel$Group[-train])
summary
methods for the clogitboost
objects.
## S3 method for class 'clogitboost' summary(object, ...)
## S3 method for class 'clogitboost' summary(object, ...)
object |
output object from the |
... |
not currently used. |
The function clogitboost()
returns the following list of values:
call |
original function call. |
infscore |
relative influence score for each covariate. |
loglike |
sequence of the fitted values of log-likelihood. |
Haolun Shi [email protected]
Guosheng Yin [email protected]
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) summary(fit)
data(travel) train <- 1:504 y <- travel$MODE[train] x <- travel[train, 3:6] strata <- travel$Group[train] fit <- clogitboost(y = y, x = x, strata = strata, iter = 10, rho = 0.05) summary(fit)
The dataset is a survey result of 210 individuals' choices of travel mode between Sydney, Melbourne and New South Wales. There are four alternative choices, along with four choice-specific covaraites for each choice.
data("travel")
data("travel")
A data frame with 840 observations on the following 6 variables.
Group
index of the group membership.
MODE
binary outcome of whether the item is chosen.
TTME
terminal time.
INVC
in-vehicle cost.
INVT
amount of time spent traveling.
GC
genearlized cost of travel.
Greene W (2008). Econometric Analysis, 6th edition. Prentice Hall.