poissonirr: Incidence rate ratios for a Poisson regression.

Description Usage Arguments Details Value See Also Examples

View source: R/poissonirr.R

Description

This function estimates a negative binomial regression model and calculates the corresponding incidence rate ratios.

Usage

1
2
poissonirr(formula, data, robust = FALSE, clustervar1 = NULL, 
           clustervar2 = NULL, start = NULL, control = list())

Arguments

formula

an object of class “formula” (or one that can be coerced to that class).

data

the data frame containing these data. This argument must be used.

robust

if TRUE the function reports White/robust standard errors.

clustervar1

a character value naming the first cluster on which to adjust the standard errors.

clustervar2

a character value naming the second cluster on which to adjust the standard errors for two-way clustering.

start

starting values for the parameters in the glm model.

control

see glm.control.

Details

If both robust=TRUE and !is.null(clustervar1) the function overrides the robust command and computes clustered standard errors.

Value

irr

a coefficient matrix with columns containing the estimates, associated standard errors, test statistics and p-values.

fit

the fitted glm object.

call

the matched call.

See Also

poissonmfx, glm

Examples

1
2
3
4
5
6
7
8
9
# simulate some data
set.seed(12345)
n = 1000
x = rnorm(n)
y = rnegbin(n, mu = exp(1 + 0.5 * x), theta = 0.5)

data = data.frame(y,x)

poissonirr(formula=y~x,data=data)

Example output

Loading required package: sandwich
Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: MASS
Loading required package: betareg
Call:
poissonirr(formula = y ~ x, data = data)

Incidence-Rate Ratio:
      IRR Std. Err.      z     P>|z|    
x 1.72454   0.03105 30.268 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

mfx documentation built on May 2, 2019, 12:46 p.m.