rhurdle1d_pms: Generates samples from the pms parametrization.

Description Usage Arguments Details Value Examples

View source: R/zero_gen.R

Description

Generates samples from the pms parametrization.

Usage

1
rhurdle1d_pms(n, log_odds, mu, sigmasq)

Arguments

n

The number of observations to be drawn.

log_odds

The log odds, the p parameter.

mu

The conditional mean of the Gaussian part, the m parameter.

sigmasq

The conditional variance of the Gaussian part, the s parameter.

Details

Generates samples from the Hurdle 1d distribution, with probability 1-p for y == 0, and density p*dnorm(x, m, sqrt(s)) for y != 0.

Value

A vector of size n.

Examples

1
2
3
4
5
6
7
8
set.seed(1)
log_odds <- stats::rnorm(1)
mu <- stats::rnorm(1)
sigmasq <- abs(stats::rnorm(1))
x <- rhurdle1d_pms(1e5, log_odds, mu, sigmasq)
c(mean(x != 0), exp(log_odds) / (exp(log_odds) + 1))
hist(x[x != 0], freq=FALSE, breaks=200)
curve(dnorm(x, mu, sqrt(sigmasq)), from=min(x), to=max(x), add=TRUE, col="red")

sqyu/ZiDAG documentation built on Jan. 19, 2021, 4:11 p.m.