## Example 1. Special values for theta (or eta, accordingly) ##
m.lambda <- c(0, 0.5, 1, 10, 20, 25, 1e2, 1e3, Inf, -Inf, NaN, NA)
# The 'posPoiMlink' transformation and the first two derivatives.
print(rbind(m.lambda,
deriv1 = posPoiMlink(theta = m.lambda, inverse = FALSE, deriv = 1),
deriv2 = posPoiMlink(theta = m.lambda, inverse = FALSE, deriv = 2)),
digits = 2)
# The inverse of 'posPoiMlink' and the first two derivatives.
print(rbind(m.lambda,
Invderiv1 = posPoiMlink(theta = m.lambda, inverse = TRUE, deriv = 1),
Invderiv2 = posPoiMlink(theta = m.lambda, inverse = TRUE, deriv = 2)),
digits = 2)
## Example 2. The inverse of 'posPoiMlink' ##
m.lambda <- c(0, 1, 5, 10, 1e2, 1e3)
posPoiMlink(theta = posPoiMlink(m.lambda, inverse = TRUE))
pospoi.inv <- posPoiMlink(posPoiMlink(m.lambda, inverse = TRUE)) - m.lambda
summary(pospoi.inv) ## Should be zero.
## Example 3. Plot of 'posPoiMlink' and its first two derivatives ##
## inverse = FALSE, deriv = 0, 1, 2. ##
# \donttest{
m.lambda <- seq(0, 35, by = 0.01)[-1]
y.lambda <- posPoiMlink(theta = m.lambda, deriv = 0)
der.1 <- posPoiMlink(theta = m.lambda, deriv = 1)
der.2 <- posPoiMlink(theta = m.lambda, deriv = 2)
plot(y.lambda ~ m.lambda, col = "black",
main = "log(mu), mu = E[Y], Y ~ pospoisson(lambda).",
ylim = c(-1, 10), xlim = c(-1, 26),
lty = 1, type = "l", lwd = 3)
abline(v = 0, h = 0, col = "gray50", lty = "dashed")
lines(m.lambda, der.1, col = "blue", lty = 5, lwd = 3)
lines(m.lambda, der.2, col = "chocolate", lty = 4, lwd = 3)
legend(5, 9, legend = c("posPoiMlink", "deriv = 1", "deriv = 2"),
col = c("black", "blue", "chocolate"), lty = c(1, 5, 4), lwd = c(3, 3, 3))
# }
Run the code above in your browser using DataLab