🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 18 (from laksa096)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
2 months ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH2.3 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution
Last Crawled2026-02-05 06:52:31 (2 months ago)
First Indexed2016-06-16 14:20:27 (9 years ago)
HTTP Status Code200
Meta Titler - Simulate from a zero-inflated poisson distribution - Cross Validated
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
You can get the probability of zero-inflation by p <- predict ( object , ... , type = "zero" ) and the mean of the count distribution by lambda <- predict ( object , ... , type = "count" ) See Appendix C of vignette("countreg", package = "pscl") for a few more details. To simulate the distribution, you can either do it manually with ifelse ( rbinom ( n , size = 1 , prob = p ) > 0 , 0 , rpois ( n , lambda = lambda ) ) or you can use rzipois() from the VGAM package library ( "VGAM" ) rzipois ( n , lambda = lambda , pstr0 = p ) which essentially also does an ifelse() as above but adds a few sanity checks etc.
Markdown
# ![site logo](https://stackoverflow.com/Content/Img/SE-logo75.png) By clicking “Sign up”, you agree to our [terms of service](https://stats.stackexchange.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://stats.stackexchange.com/legal/privacy-policy). # OR Already have an account? [Log in](https://stats.stackexchange.com/users/login) [Skip to main content](https://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution#content) #### Stack Exchange Network Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. [Visit Stack Exchange](https://stackexchange.com/) 1. - [Tour Start here for a quick overview of the site](https://stats.stackexchange.com/tour) - [Help Center Detailed answers to any questions you might have](https://stats.stackexchange.com/help) - [Meta Discuss the workings and policies of this site](https://stats.meta.stackexchange.com/) - [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/) 2. ### [current community](https://stats.stackexchange.com/) - [Cross Validated](https://stats.stackexchange.com/) [help](https://stats.stackexchange.com/help) [chat](https://chat.stackexchange.com/?tab=site&host=stats.stackexchange.com) - [Cross Validated Meta](https://stats.meta.stackexchange.com/) ### your communities [Sign up](https://stats.stackexchange.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fstats.stackexchange.com%2Fquestions%2F189005%2Fsimulate-from-a-zero-inflated-poisson-distribution) or [log in](https://stats.stackexchange.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fstats.stackexchange.com%2Fquestions%2F189005%2Fsimulate-from-a-zero-inflated-poisson-distribution) to customize your list. ### [more stack exchange communities](https://stackexchange.com/sites) [company blog](https://stackoverflow.blog/) 3. [Log in](https://stats.stackexchange.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fstats.stackexchange.com%2Fquestions%2F189005%2Fsimulate-from-a-zero-inflated-poisson-distribution) 4. [Sign up](https://stats.stackexchange.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fstats.stackexchange.com%2Fquestions%2F189005%2Fsimulate-from-a-zero-inflated-poisson-distribution) [![Cross Validated](https://stats.stackexchange.com/Content/Sites/stats/Img/logo.svg?v=60d6be2c448d)](https://stats.stackexchange.com/) 1. 1. [Home](https://stats.stackexchange.com/) 2. [Questions](https://stats.stackexchange.com/questions) 3. [Unanswered](https://stats.stackexchange.com/unanswered) 4. [AI Assist](https://stackoverflow.com/ai-assist) 5. [Tags](https://stats.stackexchange.com/tags) 6. [Chat](https://chat.stackexchange.com/) 7. [Users](https://stats.stackexchange.com/users) 2. Stack Internal Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work. [Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stats-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stats-community&utm_campaign=side-bar&utm_content=explore-teams) 3. [Stack Internal]() 4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stats-community&utm_campaign=side-bar&utm_content=explore-teams-compact) **Stack Internal** Knowledge at work Bring the best of human thought and AI automation together at your work. [Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stats-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover) # [Simulate from a zero-inflated poisson distribution](https://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution) [Ask Question](https://stats.stackexchange.com/questions/ask) Asked 10 years, 1 month ago Modified [5 years, 8 months ago](https://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution?lastactivity "2020-05-26 11:19:14Z") Viewed 9k times This question shows research effort; it is useful and clear 12 Save this question. Show activity on this post. I am trying to simulate from observed data that I have fit to a zero-inflated Poisson regression model. I fit the data in R using `zeroinfl()` from the package `pscl`, but I am having trouble figuring out how to derive the ZIP distribution from the coefficient estimates. I know how to derive the predicted counts from these coefficient estimates (more information here: <http://www.ats.ucla.edu/stat/stata/faq/predict_zip.htm>), but can anyone help me understand how to find/derive estimates for my distribution parameters (i.e. lambda for the Poisson distribution, p for the Bernoulli distribution) that I can then sample from? - [r](https://stats.stackexchange.com/questions/tagged/r "show questions tagged 'r'") - [simulation](https://stats.stackexchange.com/questions/tagged/simulation "show questions tagged 'simulation'") - [poisson-regression](https://stats.stackexchange.com/questions/tagged/poisson-regression "show questions tagged 'poisson-regression'") - [zero-inflation](https://stats.stackexchange.com/questions/tagged/zero-inflation "show questions tagged 'zero-inflation'") [Share](https://stats.stackexchange.com/q/189005 "Short permalink to this question") Share a link to this question Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") Cite [Improve this question](https://stats.stackexchange.com/posts/189005/edit) Follow Follow this question to receive notifications [edited May 26, 2020 at 11:19](https://stats.stackexchange.com/posts/189005/revisions "show all edits to this post") [![Kim's user avatar](https://i.sstatic.net/UHv0F.jpg?s=64)](https://stats.stackexchange.com/users/180771/kim) [Kim](https://stats.stackexchange.com/users/180771/kim) 17988 bronze badges asked Jan 2, 2016 at 22:00 [![lhz's user avatar](https://www.gravatar.com/avatar/3a7966fb2017f658ee268d1d6c2a38fb?s=64&d=identicon&r=PG&f=y&so-version=2)](https://stats.stackexchange.com/users/99561/lhz) [lhz](https://stats.stackexchange.com/users/99561/lhz) 12311 silver badge44 bronze badges [Add a comment](https://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \| ## 1 Answer 1 Sorted by: [Reset to default](https://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution?answertab=scoredesc#tab-top) This answer is useful 25 Save this answer. Show activity on this post. You can get the probability of zero-inflation by ``` p <- predict(object, ..., type = "zero") ``` and the mean of the count distribution by ``` lambda <- predict(object, ..., type = "count") ``` See Appendix C of `vignette("countreg", package = "pscl")` for a few more details. To simulate the distribution, you can either do it manually with ``` ifelse(rbinom(n, size = 1, prob = p) > 0, 0, rpois(n, lambda = lambda)) ``` or you can use `rzipois()` from the `VGAM` package ``` library("VGAM") rzipois(n, lambda = lambda, pstr0 = p) ``` which essentially also does an `ifelse()` as above but adds a few sanity checks etc. [Share](https://stats.stackexchange.com/a/189052 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0") Cite [Improve this answer](https://stats.stackexchange.com/posts/189052/edit) Follow Follow this answer to receive notifications [edited Jan 3, 2016 at 16:44](https://stats.stackexchange.com/posts/189052/revisions "show all edits to this post") answered Jan 3, 2016 at 9:53 [![Achim Zeileis's user avatar](https://i.sstatic.net/CrqQ0.jpg?s=64)](https://stats.stackexchange.com/users/60261/achim-zeileis) [Achim Zeileis](https://stats.stackexchange.com/users/60261/achim-zeileis) 16\.9k22 gold badges4343 silver badges6565 bronze badges 0 [Add a comment](https://stats.stackexchange.com/questions/189005/simulate-from-a-zero-inflated-poisson-distribution "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| Start asking to get answers Find the answer to your question by asking. [Ask question](https://stats.stackexchange.com/questions/ask) Explore related questions - [r](https://stats.stackexchange.com/questions/tagged/r "show questions tagged 'r'") - [simulation](https://stats.stackexchange.com/questions/tagged/simulation "show questions tagged 'simulation'") - [poisson-regression](https://stats.stackexchange.com/questions/tagged/poisson-regression "show questions tagged 'poisson-regression'") - [zero-inflation](https://stats.stackexchange.com/questions/tagged/zero-inflation "show questions tagged 'zero-inflation'") See similar questions with these tags. - The Overflow Blog - [What’s new at Stack Overflow: February 2026](https://stackoverflow.blog/2026/02/02/what-s-new-at-stack-overflow-february-2026/?cb=1) - Featured on Meta - [Results of the January 2026 Community Asks Sprint: Community Badges](https://meta.stackexchange.com/questions/417043/results-of-the-january-2026-community-asks-sprint-community-badges?cb=1) - [All users on Stack Exchange can now participate in chat](https://meta.stackexchange.com/questions/417109/all-users-on-stack-exchange-can-now-participate-in-chat?cb=1) #### Linked [4](https://stats.stackexchange.com/questions/570321/generate-values-from-a-zero-inflated-negative-binomial-fit?lq=1 "Question score (upvotes - downvotes)") [Generate values from a zero inflated negative binomial fit](https://stats.stackexchange.com/questions/570321/generate-values-from-a-zero-inflated-negative-binomial-fit?noredirect=1&lq=1) [1](https://stats.stackexchange.com/questions/228883/how-to-model-demographics?lq=1 "Question score (upvotes - downvotes)") [How to model demographics](https://stats.stackexchange.com/questions/228883/how-to-model-demographics?noredirect=1&lq=1) #### Related [11](https://stats.stackexchange.com/questions/45262/zero-inflated-count-models-in-r-what-is-the-real-advantage?rq=1 "Question score (upvotes - downvotes)") [Zero-inflated count models in R: what is the real advantage?](https://stats.stackexchange.com/questions/45262/zero-inflated-count-models-in-r-what-is-the-real-advantage?rq=1) [4](https://stats.stackexchange.com/questions/81040/why-am-i-not-able-to-fit-a-zero-inflated-poisson-distribution?rq=1 "Question score (upvotes - downvotes)") [Why am I not able to fit a zero inflated poisson distribution?](https://stats.stackexchange.com/questions/81040/why-am-i-not-able-to-fit-a-zero-inflated-poisson-distribution?rq=1) [9](https://stats.stackexchange.com/questions/116007/when-to-use-zero-inflated-poisson-regression-and-negative-binomial-distribution?rq=1 "Question score (upvotes - downvotes)") [When to use zero-inflated poisson regression and negative binomial distribution](https://stats.stackexchange.com/questions/116007/when-to-use-zero-inflated-poisson-regression-and-negative-binomial-distribution?rq=1) [8](https://stats.stackexchange.com/questions/143407/zero-inflated-poisson-and-gibbs-sampling-proofs-and-sampling?rq=1 "Question score (upvotes - downvotes)") [Zero-inflated Poisson and Gibbs sampling, proofs and sampling](https://stats.stackexchange.com/questions/143407/zero-inflated-poisson-and-gibbs-sampling-proofs-and-sampling?rq=1) [0](https://stats.stackexchange.com/questions/446929/how-to-correctly-include-offset-in-bayesian-zero-inflated-poisson-model-in-winbu?rq=1 "Question score (upvotes - downvotes)") [How to correctly include offset in Bayesian Zero-Inflated Poisson model in winbugs](https://stats.stackexchange.com/questions/446929/how-to-correctly-include-offset-in-bayesian-zero-inflated-poisson-model-in-winbu?rq=1) [0](https://stats.stackexchange.com/questions/469035/zero-inflated-model-in-r-building-the-model-with-pscl-not-understanding-use-of?rq=1 "Question score (upvotes - downvotes)") [zero inflated model in R, building the model with pscl, not understanding use of ' \| 1'](https://stats.stackexchange.com/questions/469035/zero-inflated-model-in-r-building-the-model-with-pscl-not-understanding-use-of?rq=1) #### [Hot Network Questions](https://stackexchange.com/questions?tab=hot) - [Recreating Python's f-strings in TypeScript](https://codereview.stackexchange.com/questions/301219/recreating-pythons-f-strings-in-typescript) - [What could be the area of this right triangle inscribed in an equilateral triangle?](https://math.stackexchange.com/questions/5123025/what-could-be-the-area-of-this-right-triangle-inscribed-in-an-equilateral-triang) - [Which was the first game that included a boss rush?](https://gaming.stackexchange.com/questions/417769/which-was-the-first-game-that-included-a-boss-rush) - [Angry space-ship Captain fights the scary alien 'fish…' then gets to run the UN](https://scifi.stackexchange.com/questions/303136/angry-space-ship-captain-fights-the-scary-alien-fish-then-gets-to-run-the-un) - [Possible typo in Bach Flute Partita in A minor](https://music.stackexchange.com/questions/143167/possible-typo-in-bach-flute-partita-in-a-minor) - [Which “status” should a lecturer choose when registering on arXiv?](https://academia.stackexchange.com/questions/225810/which-status-should-a-lecturer-choose-when-registering-on-arxiv) - [Rejection at a top mathematics journal after serious consideration](https://academia.stackexchange.com/questions/225828/rejection-at-a-top-mathematics-journal-after-serious-consideration) - [Scope: how to measure fast (1 µs rise time) signals at high (320 V) voltages?](https://electronics.stackexchange.com/questions/765362/scope-how-to-measure-fast-1-%C2%B5s-rise-time-signals-at-high-320-v-voltages) - [Identify two actors from Knight Rider pilot](https://movies.stackexchange.com/questions/131420/identify-two-actors-from-knight-rider-pilot) - [Component footprint confusion](https://electronics.stackexchange.com/questions/765354/component-footprint-confusion) - [What does מה"ר stand for?](https://judaism.stackexchange.com/questions/155013/what-does-%D7%9E%D7%94%D7%A8-stand-for) - [What does 中 signify in 中国?](https://chinese.stackexchange.com/questions/63903/what-does-%E4%B8%AD-signify-in-%E4%B8%AD%E5%9B%BD) - [Where is training for the Space Station Remote Manipulator System conducted?](https://space.stackexchange.com/questions/70304/where-is-training-for-the-space-station-remote-manipulator-system-conducted) - [How to make particles in a geometry node particle system randomly fade on and off](https://blender.stackexchange.com/questions/344924/how-to-make-particles-in-a-geometry-node-particle-system-randomly-fade-on-and-of) - [Fractions with the systeme package](https://tex.stackexchange.com/questions/759225/fractions-with-the-systeme-package) - [What does "Allow custom filters requiring trust" mean in uBlock Origin](https://superuser.com/questions/1934505/what-does-allow-custom-filters-requiring-trust-mean-in-ublock-origin) - [Co-authorship invite to a paper with a researcher of questionable reputation](https://academia.stackexchange.com/questions/225824/co-authorship-invite-to-a-paper-with-a-researcher-of-questionable-reputation) - [Word order when combining a name with a noun](https://german.stackexchange.com/questions/82096/word-order-when-combining-a-name-with-a-noun) - [How did Eve manage to guess the password?](https://scifi.stackexchange.com/questions/303118/how-did-eve-manage-to-guess-the-password) - [What sort of distinction in mathematical reference is this?](https://philosophy.stackexchange.com/questions/135928/what-sort-of-distinction-in-mathematical-reference-is-this) - [Particle on a circle](https://physics.stackexchange.com/questions/868709/particle-on-a-circle) - [Generating integer compositions with some zeros allowed](https://mathematica.stackexchange.com/questions/318670/generating-integer-compositions-with-some-zeros-allowed) - [Naked Pairs Sudoku Mechanic](https://puzzling.stackexchange.com/questions/136962/naked-pairs-sudoku-mechanic) - [Who is the Pro?](https://puzzling.stackexchange.com/questions/136960/who-is-the-pro) [Question feed](https://stats.stackexchange.com/feeds/question/189005 "Feed of this question and its answers") # Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. ![](https://stats.stackexchange.com/posts/189005/ivc/bcd5?prg=a5d1305f-ed95-4e48-847d-8640d072ce65) lang-r # Why are you flagging this comment? It contains harassment, bigotry or abuse. This comment attacks a person or group. Learn more in our [Abusive behavior policy](https://stats.stackexchange.com/conduct/abusive-behavior). It's unfriendly or unkind. This comment is rude or condescending. Learn more in our [Code of Conduct](https://stats.stackexchange.com/conduct/abusive-behavior). Not needed. This comment is not relevant to the post. ``` ``` Enter at least 6 characters Something else. A problem not listed above. Try to be as specific as possible. ``` ``` Enter at least 6 characters Flag comment Cancel You have 0 flags left today # ![Illustration of upvote icon after it is clicked](https://stats.stackexchange.com/Content/Img/modal/img-upvote.png?v=fce73bd9724d) # Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation) Instead, you can save this post to reference later. Save this post for later Not now ##### [Cross Validated](https://stats.stackexchange.com/) - [Tour](https://stats.stackexchange.com/tour) - [Help](https://stats.stackexchange.com/help) - [Chat](https://chat.stackexchange.com/?tab=site&host=stats.stackexchange.com) - [Contact](https://stats.stackexchange.com/contact) - [Feedback](https://stats.meta.stackexchange.com/) ##### [Company](https://stackoverflow.co/) - [Stack Overflow](https://stackoverflow.com/) - [Stack Internal](https://stackoverflow.co/internal/) - [Stack Data Licensing](https://stackoverflow.co/data-licensing/) - [Stack Ads](https://stackoverflow.co/advertising/) - [About](https://stackoverflow.co/) - [Press](https://stackoverflow.co/company/press/) - [Legal](https://stackoverflow.com/legal) - [Privacy Policy](https://stackoverflow.com/legal/privacy-policy) - [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public) - Cookie Settings - [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy) ##### [Stack Exchange Network](https://stackexchange.com/) - [Technology](https://stackexchange.com/sites#technology) - [Culture & recreation](https://stackexchange.com/sites#culturerecreation) - [Life & arts](https://stackexchange.com/sites#lifearts) - [Science](https://stackexchange.com/sites#science) - [Professional](https://stackexchange.com/sites#professional) - [Business](https://stackexchange.com/sites#business) - [API](https://api.stackexchange.com/) - [Data](https://data.stackexchange.com/) - [Blog](https://stackoverflow.blog/?blb=1) - [Facebook](https://www.facebook.com/officialstackoverflow/) - [Twitter](https://twitter.com/stackoverflow) - [LinkedIn](https://linkedin.com/company/stack-overflow) - [Instagram](https://www.instagram.com/thestackoverflow) Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.2.3.39385
Readable Markdown
You can get the probability of zero-inflation by ``` p <- predict(object, ..., type = "zero") ``` and the mean of the count distribution by ``` lambda <- predict(object, ..., type = "count") ``` See Appendix C of `vignette("countreg", package = "pscl")` for a few more details. To simulate the distribution, you can either do it manually with ``` ifelse(rbinom(n, size = 1, prob = p) > 0, 0, rpois(n, lambda = lambda)) ``` or you can use `rzipois()` from the `VGAM` package ``` library("VGAM") rzipois(n, lambda = lambda, pstr0 = p) ``` which essentially also does an `ifelse()` as above but adds a few sanity checks etc.
Shard18 (laksa)
Root Hash8045678284012640218
Unparsed URLcom,stackexchange!stats,/questions/189005/simulate-from-a-zero-inflated-poisson-distribution s443