Description Usage Arguments Details Value Examples
Fitting logit regression models.
1 2 3 4 5 6 7 |
formula |
a formula expression of the form |
data |
an optional data frame containing the variables occurring in the formulas. |
subset |
an optional vector specifying a subset of observations to be used for fitting. |
na.action |
a function which indicates what should happen when the data
contain |
model |
logical. If |
x, y |
for |
... |
arguments to be used to form the default |
control, maxit, start |
a list of control parameters passed to |
hessian |
logical or character. Should a numeric approximation of the
(negative) Hessian matrix be computed? Either |
logitr
fits logit regression models using maximum likelihood
estimation. The model assumes an underlying latent binomial variable.
logitr_fit
is the lower level function where the actual fitting takes place.
A set of standard extractor functions for fitted model objects is available for
objects of class "logitr"
, including methods to the generic functions
print
, summary
, coef
,
vcov
, logLik
, residuals
,
predict
, terms
,
model.frame
, model.matrix
, update
.
This is a simpler implementation of glm
only modeling
the "family = binomial"
used for logistic regression.
logitr
was written for the sole purpose of learning how to write packages
and is not recommended to ever be used instead of glm
.
logitr
returns an object of class "logitr"
, i.e., a list with components as follows.
logitr_fit
returns an unclassed list with components up to df
.
coefficients |
a list containing the coefficients, |
counts |
count of function and gradient evaluations from |
convergence |
convergence code from |
message |
optional further information from |
vcov |
covariance matrix of all parameters in the model, |
residuals.pearson |
a vector containing the Pearson Residuals of the model, |
fitted.values |
a list containing the latent fitted values, |
method |
the method argument passed to the |
nobs |
number of observations, |
df |
number of estimated parameters, |
call |
the original function call, |
formula |
the original formula, |
terms |
a list containing the terms objects for the model, |
model |
the full model frame (if |
y |
the numeric response vector (if |
x |
a list containing the model matrices
(if |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## quick randomly generated dataset. Comparison package vs glm
set.seed(123)
x1 <- rnorm(30,3,2) + 0.1 * c(1:30)
x2 <- rbinom(30,1,0.3)
x3 <- rpois(n=30,lambda = 4)
x3[16:30] <- x3[16:30] - rpois(n=15, lambda = 2)
xdat <- cbind(x1,x2,x3)
ydat <- c(rbinom(5,1,0.1), rbinom(10,1,0.25), rbinom(10,1,0.75), rbinom(5,1,0.9))
(m0 <- logitr(ydat~xdat))
(m1 <- glm(ydat~xdat, family = "binomial"))
## comparing AIC and BIC
AIC(m0)
AIC(m1)
BIC(m0)
BIC(m1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.