If I do this, I will get two ratios (interception and year)
data <- data.frame(accidents=c(3,1,5,0,2,3,4), year=1:7) glm(accidents ~ year, family=poisson(link = log), data) Coefficients: (Intercept) year 0.7155 0.0557
But the correct answer is 0.944
data <-data.frame(accidents=c(3,1,5,0,2,3,4)) glm(accidents ~ ., family=poisson(link=log), data) Coefficients: (Intercept) 0.944
Is there a way to specify the glm formula only for the response variable? If I use the second formula with the first data frame, I get the wrong answer because "." also includes "year". In the second data frame, I cheat because there is only one column.
source share