expected | R Documentation |
The hP_expected
and CMP_expected
functions calculate the
probability distribution of the count response variable Y for each observation
and obtain the corresponding expected frequencies. It is an informal way of
assessing the fit of the hP or CMP model by comparing the predicted
distribution of counts with the observed distribution.
hP_expected(object)
CMP_expected(object)
object |
a fitted object of class inheriting from |
The average expected probabilities are computed as
\bar(Pr)(y=k) =
\frac{1}{n} \sum_{i=1}^n \widehat{Pr}(y_i = k | x_i)
The expected frequencies are obtained by multiplying by n.
Two measures are offered for summarizing the comparison between expected and observed frequencies: the sum of the absolute value of differences and the sum of the square of differences (similar to the Pearson statistic of goodness of fit).
A list containing the following components:
frequencies |
the expected counts for the hP or CMP fit. |
observed_freq |
the observed distribution. |
probabilities |
the expected distribution for the hP or CMP fit. |
dif |
sum of the absolute value of differences between
|
chi2 |
sum of the
square of differences between |
J. M. Hilbe (2011). Negative Binomial Regression. (2nd ed.). Cambridge University Press.
M. Scott Long and Jeremy Freese (2014). Regression Models for Categorical Dependent Variables using STATA. (3rd ed.). Stata Press.
## Fit a hyper-Poisson model
Bids$size.sq <- Bids$size ^ 2
hP.fit <- glm.hP(formula.mu = numbids ~ leglrest + rearest + finrest +
whtknght + bidprem + insthold + size + size.sq + regulatn,
formula.gamma = numbids ~ 1, data = Bids)
## Compute the expected probabilities and the frequencies
hP_expected(hP.fit)
## Estimate a COM-Poisson model
Bids$size.sq <- Bids$size ^ 2
CMP.fit <- glm.CMP(formula.mu = numbids ~ leglrest + rearest + finrest +
whtknght + bidprem + insthold + size + size.sq + regulatn,
formula.nu = numbids ~ 1, data = Bids)
## Compute the expected probabilities and the frequencies
CMP_expected(CMP.fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.