EMzeropoisson_mat: Zero Inflated Possion Regression

Description Usage Arguments Details Value Author(s) Examples

View source: R/ZIPFA.R

Description

The zero inflated possion regression model.

Usage

1
2
3
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 argument.

initial

A list of initial values for the fitting. c(tau beta).

initialtau

A character specifying the way to choose the initial value of tau at the beginning of EM iteration. stable: estimate tau from fitted beta in last round; initial: always use the initially assigned tau in tau or initial. Use the default tau = 0.1 if 'initial' is empty. iteration: use fitted tau in last round.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

ZIPFA documentation built on April 1, 2020, 1:07 a.m.