Greetings. I want to compute Pearson residuals from an rpart model built using method=”poisson.” I'm using R 3.2.1 under Windows 7, 64-bit. Here I create some data, run the model, and tabulate the residuals. require (rpart) # Create data > a <- data.frame (X = 1:20) > set.seed (123); a$Y <- rpois (nrow (a), lambda = a$X) # Build model, tabulate residuals > table (residuals (rpart (cbind (1, Y) ~ X, method = "poisson", data = a), type = "pearson")) -Inf Inf 10 10 # Unsurprisingly this is true using just Y as the response: > table (residuals (rpart (Y ~ X, method = "poisson", data = a), type = "pearson")) -Inf Inf 10 10 I think the problem is in residuals.rpart(), in the line temp <- ifelse(expect == 0, 1e-04, 0) Should that not be temp <- ifelse(expect == 0, 1e-04, expect)?