log(Pr(G = k | x) / Pr(G = K | x)) = beta_k0 + beta_k' x with the last sorted
class as baseline (ESL eqs 4.17-4.18), fitted by Newton-Raphson with step
halving; standard errors from the inverse information.
Usage
morie_esl_multinomial_logit(
X,
g,
query = NULL,
max_iter = 100,
tol = 1e-10,
weights = NULL
)
Arguments
- X
Predictors, N by p.
- g
Class labels.
- query
Points for prob (default X).
- max_iter, tol
Newton controls.
- weights
Optional non-negative case weights (the local fit of ESL
eq 6.19).
Value
Named list: coefficients and se ((K - 1) by (p + 1)), loglik,
classes, baseline, prob, iterations, converged.
References
Hastie, Tibshirani & Friedman (2009), sec. 4.4.
Examples
i <- 1:40
X <- cbind(sin(i), cos(3 * i))
morie_esl_multinomial_logit(X, (i * 7) %% 3)$coefficients
#> [,1] [,2] [,3]
#> [1,] -0.0000330781 -0.008522039 -0.3134191
#> [2,] 0.0777564276 0.033362941 -0.1602228