Skip to content
Prev 274138 / 398506 Next

Count model prediction

On Tue, 11 Oct 2011, Akram Khaleghei Ghosheh balagh wrote:

            
Do you want the expected probabilities of observing 0, 1, 2, etc.? Then 
you can use the convenience function predprob() in package "pscl". For 
example:

## package and data
library("pscl")
data("bioChemists", package = "pscl")

## NB model
m <- glm.nb(art ~ ., data = bioChemists)

## predicted probabilities for counts 0, 1, ..., 19 per observation
p <- predprob(m)

## sums across all observations
colSums(p)

which yields:

           0           1           2           3           4           5
277.7900354 249.1239076 164.7450252  97.2999696  54.7265588  30.2456638
           6           7           8           9          10          11
  16.7394187   9.4002205   5.4081462   3.2096223   1.9731828   1.2584834
          12          13          14          15          16          17
   0.8320010   0.5686597   0.4003506   0.2891672   0.2134580   0.1604948
          18          19
   0.1225642   0.0948470

hth,
Z