feeplot: Plot First-Exposure Effect Distribution

View source: R/feeplot.R

feeplotR Documentation

Plot First-Exposure Effect Distribution

Description

Creates a bar plot of the observed count data overlaid with fitted values from a oneinfl model and its associated counterfactual (non-inflated) model.

Usage

feeplot(model, data, maxpred, ylimit, cex = 1.5, lwd = 1.5, ...)

Arguments

model

A fitted object of class "oneinflmodel".

data

A data frame containing the original data used to fit the model.

maxpred

Optional integer indicating the maximum count value to include on the x-axis. Defaults to the maximum observed value in data.

ylimit

Optional numeric value specifying the upper limit of the y-axis. Defaults to 110% of the maximum observed count frequency.

cex

A numeric value for point size in the overlay plot. Defaults to 1.5.

lwd

A numeric value for line width in the overlay plot. Defaults to 1.5.

...

Additional arguments passed to points() or lines().

Details

The factual predictions come from the fitted oneinfl model, while the counterfactual distribution is obtained by transforming the model into a non-inflated counterpart using the same estimated parameters.

The function detects whether the model is based on a Poisson or negative binomial distribution and selects the appropriate counterfactual model.

Value

A barplot with overlaid predicted values from the factual and counterfactual distributions, including a legend identifying each component.

See Also

feepred, fee, dfee

Examples

df <- data.frame(x = runif(10,0,10), d = sample(c(0,1), 10, replace=TRUE), y = rpois(10, 3) + 1)
model <- oneinfl::oneinfl(formula = y ~ x + d | x + d, df = df, dist = "Poisson")
feeplot(model, data = df)


fee documentation built on Aug. 8, 2025, 7:45 p.m.

Related to feeplot in fee...