I've tryed both the approaches but I find difficulties with both.. I try to explain better which is my problem before I tell you my questions with the two approaches.
I have the dataset "acceptances" in which I have the number of acceptances for everyday in an hospital with the indipendent variables described before. The hospital has three places in which we do the visits..So in my dataset I have 3 rows per day one for every place. The dataset seems like:
Date Place NumerAccept weekday month NoConvention Rain
2008-01-02 Place1 203 wed Gen 0 1
2008-01-02 Place2 70 wed Gen 0 1
2008-01-02 Place3 9 wed Gen 0 1
2008-01-03 Place1 345 thu Gen 0 1
2008-01-03 Place2 24 thu Gen 0 1
2008-01-03 Place3 99 thu Gen 0 1
2008-01-04 Place1 339 fri Gen 0 0
2008-01-04 Place2 36 fri Gen 0 0
2008-01-04 Place3 101 fri Gen 0 0
.... and so on... I have the dataset until yesterday, so the last three rows are the acceptances of yesterday 29 of July 2013. Now I do my Poisson regression:
poisson_reg=glm(NumeberAccept ~ 1 + weekday + month + place + NoConvention + Rain,
family = poisson(link = log), data = acceptances)
Now for my predictions I create a new dataset acceptances_2 from which I want to calculate the prediction interval for the Number of Acceptances for the next 2 months!! So the first row will be the number of acceptations today, and the last row will be the acceptances on September 29.
I don't know if this question has already an answer, but I wasn't able to find it. I'm trying to do a Poisson regression in R and I want to obtain the prediction intervals. I saw that the predict function for lm
gives it writing 'interval="prediction"'
but it doesn't work with predict.glm
!
Does someone know if there is a way to have those prediction intervals?? Can you type the code if you have some examples?
So I have to count the number of everyday acceptances in an hospital and I have the following code:
poisson_reg=glm(NumeberAccept ~ 1 + weekday + month + place + NoConvention + Rain,
family = poisson(link = log), data = dataset)
summary(poisson_reg)
Now if I type in R predict(poisson_reg, newdata, type="responce")
I have the prediction for the number of acceptances for everyday but I need the prediction intervals too!
I saw that for an object of class "lm"
in the predict call you can write: predict(poisson_reg, newdata, interval="prediction")
and it gives the 95% prediction intervals. Is there a way to obtain the same with an object of class "glm"
?