Description Usage Arguments Details Value Author(s) References Examples
View source: R/berg_fit_function.R
Fit of the BerG regression model via maximum likelihood for a new parameterization of this distribution that is indexed by the mean and the dispersion index.
1 2 3 4 5 6 7 8 9 10 11 12 |
formula |
a simbolic description of the model, of type
|
data |
an optional data frame containing the variables in the formula. By default the variables are taken from environment(formula). |
link, link.phi |
character; specification of the link function in the
mean and dispersion index submodels. The links |
disp.test |
logical; if |
optimizer |
character; specification of the optimization algorithm.
By default, estimates are obtained using sequential quadratic programming
method via nloptr package ( |
y, x |
logicals; if |
control |
a list of control arguments specified via |
... |
arguments passed to |
The basic formula is of type y ~ x1 + x2 + ... + xp
which
specifies the model for the mean response only with p
explanatory
variables. Following the syntax of the betareg
package
(Cribari-Neto and Zeileis, 2010), the model for the dispersion index, say in terms of
z1, z2, ..., zk, is specified as y ~ x1 + x2 + ... + xp | z1 + z2 +
... +zk
using functionalities inherited from package Formula
(Zeileis and Croissant, 2010).
The bergreg
function returns an object of class "bergreg",
which consists of a list with the following components:
a list containing the elements "mean" and "dispersion," which consists of the estimates of the coefficients associated with the mean and the dispersion index, respectively.
a vector with the fitted means.
a vector with the fitted dispersion indexes.
a vector of raw residuals (observed - fitted)
.
a list with elements "mean
" and "dispersion
"
containing the link objects for the respective submodels.
asymptotic covariance matrix of the maximum likelihood estimator of the model parameters vector. Specifically, the inverse of the Fisher information matrix.
log-likelihood of the fitted model.
expected frequencies after fitting the BerG regression.
the number of observations in the sample.
residual degrees of freedom in the null model
(constant mean and dispersion), that is, n - 2
.
residual degrees of freedom in the fitted model.
logical; if TRUE
, the estimates satisfy the constraints.
the function call.
the formula used to specify the model in bergreg
.
a list with elements "mean", "dispersion" and "full" containing the terms objects for the respective models.
the response vector (if y = TRUE
).
a list with elements "mean" and "dispersion" containing the
model matrices from the respective models (if X = TRUE
).
Rodrigo M. R. Medeiros <rodrigo.matheus@live.com>
Bourguignon, M. & Medeiros, R. (2021). A simple and useful regression model for fitting count data.
Cribari-Neto F, Zeileis A (2010). Beta regression in R. Journal of Statistical Software, 34, 1–24
Zeileis A, Croissant Y (2010). Extended model formulas in R: multiple parts and multiple responses. Journal of Statistical Software, 34, 1–13.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Not run:
# Dataset: grazing
data(grazing)
head(grazing)
layout(matrix(c(1, 2, 1, 3), 2, 2))
# Response variable (Number of understorey birds)
barplot(table(grazing$birds), xlab = "Number of understorey birds", ylab = "Frequency")
# Explanatory variables
boxplot(birds ~ when, grazing, ylab = "Number of understorey birds",
xlab = "When the bird count was conduct", pch = 16)
boxplot(birds ~ grazed, grazing, ylab = "Number of understorey birds",
xlab = " Which side of the stockproof fence", pch = 16)
layout(1)
# Fit of the BerG regression model with varying dispersion
fit_disp <- bergreg(birds ~ when + grazed | when + grazed, data = grazing)
summary(fit_disp)
# Fit of the BerG regression model with constant dispersion
fit <- bergreg(birds ~ when + grazed, data = grazing, link.phi = "identity")
summary(fit)
# Diagnostic
layout(matrix(c(1, 3, 5, 2, 4, 5), 3, 2))
plot(fit, which = 1:5, ask = FALSE)
layout(1)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.