EMzeropoisson_mat {ZIPFA} | R Documentation |
Zero Inflated Possion Regression
Description
The zero inflated possion regression model.
Usage
EMzeropoisson_mat(data, tau = 0.1, initial = NULL, initialtau = 'iteration',
tol = 1e-4, maxiter = 100, Madj = FALSE, m = NULL,
display = TRUE, intercept = TRUE)
Arguments
data |
A matrix with the first columns is y and the rest columns are x. |
tau |
Initial tau value to fit. Will be overwritten by the first value in |
initial |
A list of initial values for the fitting. |
initialtau |
A character specifying the way to choose the initial value of tau at the beginning of EM iteration. |
tol |
Percentage of l2 norm change of [tau beta]. |
maxiter |
Max iteration number. |
Madj |
If TRUE then adjust for relative library size M. |
m |
A vector containing relative library size M. |
display |
If TRUE display the fitting procedure. |
intercept |
If TRUE then the model contains an intercept. |
Details
The function estimates the coefficients in a new type of zero-inflated Poisson regression where the underlying Poisson rate is negatively associated with true zero probability.
Value
The function turns a matrix. Each row is fitted value in each iteration. The last row the final result. The first column is fitted tau. If intercept
is ture, then the second column is the intercept, and the rest columns are other coefficients. If intercept
is false, the rest columns are other coefficients.
Author(s)
Tianchen Xu
Examples
n = 5000;
x1 = rnorm(n);
x2 = rnorm(n);
lam = exp(x1 - 2*x2 + 1.5);
y = rpois(n, lam)
tau = .75
p = 1/(1+lam^tau);
Z = rbinom(n, 1, p);
y[as.logical(Z)] = 0;
res = EMzeropoisson_mat(matrix(c(y,x1,x2),ncol=3), Madj = FALSE, intercept = TRUE)