rTweedie(mu,p=1.5,phi=1)
mu
.mu
to the power p
. p
must
be between 1 and 2. 1 is Poisson like (exactly Poisson if phi=1
), 2 is gamma. phi*mu^p
.mu
, variance vector phi*mu^p
.
N gamma random variables
where N
has a Poisson distribution, with mean mu^(2-p)/((2-p)*phi)
. The Gamma random variables
that are summed have shape parameter (2-p)/(p-1)
and scale parameter phi*(p-1)*mu^(p-1)
(note that
this scale parameter is different from the scale parameter for a GLM with Gamma errors).
This is a restricted, but faster, version of rtweedie
from the tweedie
package.
ldTweedie
, Tweedie
library(mgcv)
f2 <- function(x) 0.2 * x^11 * (10 * (1 - x))^6 + 10 *
(10 * x)^3 * (1 - x)^10
n <- 300
x <- runif(n)
mu <- exp(f2(x)/3+.1);x <- x*10 - 4
y <- rTweedie(mu,p=1.5,phi=1.3)
b <- gam(y~s(x,k=20),family=Tweedie(p=1.5))
b
plot(b)
Run the code above in your browser using DataLab