| regCompTest | R Documentation |
This function compares a given regression model to a base model using the Likelihood Ratio (LR) test, Akaike Information Criterion (AIC), and Bayesian Information Criterion (BIC).
regCompTest(
model,
data = NULL,
basemodel = "Poisson",
variables = FALSE,
print = FALSE,
...
)
model |
A fitted regression model object. |
data |
An options data frame containing the variables in the model. If not supplied, the original data used to estimate the model will be used. |
basemodel |
A character string specifying the family of base model to
compare against (options include the family from |
variables |
Logical. If |
print |
Logical. If |
... |
Additional arguments to be passed to the base model fitting
function - options are any argument from the |
The function performs the following steps:
Fits the base model, either a Poisson regression or another specified model.
Computes the log-likelihoods of both the provided model and the base model.
Calculates the AIC and BIC for both models.
Conducts a Likelihood Ratio test to compare the models (if the provided model has more parameters than the base model).
Computes McFadden's Pseudo R^2.
The Likelihood-Ratio test is computed as
LR = -2 (LL_{base \
model}-LL_{model})
. The test is chi-squared with degrees of freedom
dof=N_{model \ params}-N_{base \ mode \ params}
. The AIC is calculated as
AIC = -2 \cdot LL + 2 \cdot nparam
, and the BIC is calculated as
BIC = -2 \cdot LL + nparam \cdot \log(n)
.
A list containing the following components:
LL |
Log-likelihood of the provided model. |
LLbase |
Log-likelihood of the base model. |
LR |
Likelihood Ratio statistic. |
LRdof |
Degrees of freedom for the Likelihood Ratio test. |
AIC |
Akaike Information Criterion for the provided model. |
AICbase |
Akaike Information Criterion for the base model. |
BIC |
Bayesian Information Criterion for the provided model. |
BICbase |
Bayesian Information Criterion for the base model. |
LR_pvalue |
P-value for the Likelihood Ratio test. |
PseudoR2 |
McFadden's Pseudo R^2. |
statistics |
A tibble format summary of the results. |
gtTable |
A gt table object summarizing the results. |
latexTable |
Latex code for a table summarizing the results. |
htmlTable |
HTML table summarizing the results. |
# Comparing the NBP model with the NB2 model
data("washington_roads")
washington_roads$AADTover10k <- ifelse(washington_roads$AADT>10000,1,0)
nbp.base <- countreg(Total_crashes ~ lnaadt + lnlength + speed50 +
ShouldWidth04 + AADTover10k,
data=washington_roads, family = 'NBP', method = 'NM',
max.iters=3000)
regCompTest(nbp.base, washington_roads, basemodel="NB2", print=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.