Learn R Programming

SingleCellAssay (version 0.80)

zlm: Run a zero-inflated regression

Description

Fits a hurdle model on zero-inflated continuous data in which the zero process is modeled as a logistic regression and (conditional on the the response being >0), the continuous process is Gaussian, ie, a linear regression.

Usage

zlm(formula, data, lm.fun = glm, silent = TRUE, subset, ...)

Arguments

formula

model formula

data

a data.frame, list or environment in which formula is evaluated

lm.fun

a function that takes a formula and data the arguments family='binomial' and family='gaussian', eg, glm or glmer.

silent

if TRUE suppress common errors from fitting continuous part

subset

ignored

...

passed to lm.fun

Value

list of class 'zlm' with "disc"rete part and "cont"inuous part

Examples

Run this code
# NOT RUN {
data<- data.frame(x=rnorm(500), z=rbinom(500, 1, .3))
logit.y <- with(data, x*2 + z*2); mu.y <- with(data, 10+10*x+10*z + rnorm(500))
y <- (runif(500)<exp(logit.y)/(1+exp(logit.y)))*1
y[y>0] <- mu.y[y>0]
data$y <- y
fit <- zlm(y ~ x+z, data)
summary(fit$disc)
summary(fit$cont)

#Compares likelihood ratios, currently only can drop an entire term
test.zlm(fit, type='LRT', hypothesis.matrix='x')
#Accepts arguments like car::linearHypothesisTest
test.zlm(fit, type='Wald', hypothesis.matrix=c('x=2', 'z=2'))
#Little evidence for difference in discrete, big evidence in continuous
# }

Run the code above in your browser using DataLab