Learn R Programming

spatemR (version 1.2.0)

ptfamily: Truncated Poisson Family for GLM

Description

This function defines a truncated Poisson family for use in Generalized Linear Models (GLMs), where zero values are not allowed. It modifies the Poisson likelihood by excluding zero-count observations.

Usage

ptfamily(link = "log")

Value

An object of class "family" that can be used in glm().

Arguments

link

Character string or a link-glm object specifying the link function. Accepted values are "log", "identity", and "sqrt".

Examples

Run this code
set.seed(123)
y <- rpois(100, lambda = 3)
y <- y[y > 0]  # Truncate zeros
x <- rnorm(length(y))
model <- glm(y ~ x, family = ptfamily())
summary(model)

Run the code above in your browser using DataLab