On Tue, 11 Oct 2011, Akram Khaleghei Ghosheh balagh wrote:
Hello ; I am doing a regression of count data (number of award and there are some covariates) I have estiamted the parameters of negative binomial distribuion (lambda is a function of covaraites, GLM model) by glm.nb function and training dataset. Now I want to predict the number of award (for example y=0, y=1, y=2,) or testing dataset. I dont know how to calculate this numbers?
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
I would be very grateful if anybody could help me. thanks [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.