rhurdle1d_abk: Generates samples from the abk parametrization.

Description Usage Arguments Details Value Examples

View source: R/zero_gen.R

Description

Generates samples from the abk parametrization.

Usage

1
rhurdle1d_abk(n, a, b, k)

Arguments

n

The number of observations to be drawn.

a

The a parameter.

b

The b parameter.

k

The k parameter.

Details

Generates samples from the Hurdle 1d distribution, whose log density with abk parametrization with respect to the sum of the Lebesgue measure and a point mass at 0 is a*v+b*y-y^2*k/2-log(1+sqrt(2pi/k)*exp(a+b^2/(2k))) where v = (y != 0).

Value

A vector of size n.

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
a <- stats::rnorm(1)
b <- stats::rnorm(1)
k <- abs(stats::rnorm(1))
x <- rhurdle1d_abk(1e5, a, b, k)
c(mean(x != 0), 1 - 1 / (1 + sqrt(2*pi/k) * exp(a+b^2/(2*k))))
hist(x[x != 0], freq=FALSE, breaks=200)
curve(exp(b*x-x^2*k/2)/(1+sqrt(2*pi/k)*exp(a+b^2/(2*k))),
   from=min(x), to=max(x), add=TRUE, col="red")

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