bergrm: BerG Regression for Count Data

Description Usage Arguments Details Value Author(s) References Examples

View source: R/berg_methods.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
glm.bg(
  formula,
  data,
  link = c("log", "sqrt", "identity"),
  link.phi = NULL,
  disp.test = FALSE,
  control = berg_control(...),
  ...
)

berg_fit(
  y,
  X,
  Z = NULL,
  link = "log",
  link.phi = "log",
  control = berg_control(...),
  ...
)

Arguments

formula

a symbolic description of the model, of type y ~ x or y ~ x | z.See details below.

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 model. The links "log", "sqrt", and "identity" can be used. For the mean model, the default link function is "log". For the dispersion index model, the default link function is also "log" unless formula is of type y ~ x where the default is "identity".

disp.test

logical; if TRUE, the function glm.bg returns the test for constant dispersion.

control

a list of control arguments specified via berg_control (under development).

...

arguments passed to berg_control (under development).

y

a numeric vector of the response variable, in counts. This argument is used only in the berg_fit function.

X, Z

model matrices associated with the mean and the dispersion index parameters, respectively, which are used only in the berg_fit function.

Details

The basic formula is of type y ~ x1 + x2 + ... + xp which specifies the model for the mean response only. 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).

Value

The glm.bg function returns an object of class "bergrm", which consists of a list with the following components. berg_fit is an auxiliary function that returns an unclassed list formed by some of the components below. This function can be used to fit the BerG regression in terms of the y, X, and Z objects instead of the formula.

coefficients

a list containing the elements "mean" and "dispersion" that consist of the estimates of the coefficients associated with the mean and the dispersion index, respectively.

link, link.phi

the link function used for the mean model, and for the dispersion index model, respectively.

vcov

asymptotic covariance matrix of the maximum likelihood estimator of the model parameters vector. Specifically, the inverse of the Fisher information matrix.

logLik

log-likelihood of the fitted model.

AIC

model Akaike information criteria.

BIC

model bayesian information criteria.

n.obs, p, k

Sample size, number of coefficients in the mean model, and number of coefficients in the dispersion index model, respectively.

feasible

Logical. If TRUE, the estimates obtained belong to the parametric space.

pearson.residuals

a vector with the Pearson residuals.

residuals

a vector with the randomized quantile residuals.

fitted.values

a vector with the fitted means.

phi.hat

a vector with the fitted dispersion indexes.

linear.predictors

a list containing the elements "eta1" and "eta2" that consist of the fitted linear predictor for the mean and the dispersion index.

response

the vector of the response.

X, Z

model matrices associated with the mean and the dispersion parameter, respectively.

call

the function call.

formula

the formula used to specify the model in glm.bg.

Author(s)

Rodrigo M. R. Medeiros <rodrigo.matheus@live.com>

References

Bourguignon, M. & Medeiros, R. (2020). 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.

Examples

 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
# Dataset: grazing

data(grazing)
attach(grazing); head(grazing)

# Response variable (Number of understorey birds)
plot(table(birds), xlab = "Number of understorey birds", ylab = "Frequency")

# Explanatory variables
boxplot(split(birds, when), ylab = "Number of understorey birds",
        xlab = "When the bird count was conduct", pch = 16)
boxplot(split(birds, grazed), ylab = "Number of understorey birds",
        xlab = " Which side of the stockproof fence", pch = 16)


# Fit of the BerG regression model with varying dispersion
fit_disp <- glm.bg(birds ~ when + grazed | when + grazed, data = grazing)
summary(fit_disp)

# Fit of the BerG regression model with constant dispersion
fit <- glm.bg(birds ~ when + grazed, data = grazing, link.phi = "identity")
summary(fit)

# Diagnostic
plot(fit)
envel_berg(fit)

detach(grazing)

rdmatheus/bergrm documentation built on Oct. 1, 2020, 4:38 a.m.