I am replicating an analysis that models tree mortality data. Data are structured such that forest sites are revisted at some random interval, which is recorded. It is then determined if a tree lived or died over that random interval, generating 0 1 mortality data (if a tree dies, it gets a 1 in the dependent variable). The interval between initial and final observation varies continuously, from 5-15 years. This is relevant, as the more time that passes, the more likely a tree will die.
Here are some pseudo data for R:
mort <- c(0,1,0,0,0,0,0,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0) interval <- runif(length(mort), 5, 15) pollution <- rnorm(length(mort), 25,5) data<- data.frame(mort, interval, pollution)
I am trying to replicate an analysis which uses a logistic regression model for binary mortality data using the the logit transformation. Authors then model how pollution affects tree mortality rates. In the manuscript the authors write, "because recensus is not annual, we relate annual mortality probability,
pi, of tree
i to the observed binomial data on whether that tree lived or died
Mi via a Bernoulli likelihood,
ti is the time interval between successive censuses."
My question: How would I implement this using the
glm function, or something analagous, in R? Note: I understand modeling this as a hazard function would also be appropriate, but it is not what I am interested in.