Getting data
Let temperature be x1
Let Oil be x2
Let Time be x3
Let no of inedible kernel be y
x1 <- c(7,5,7,7,6,6,5,6,5,6,5,7,6,6,6)
x2 <- c(4,3,3,2,4,3,3,2,4,2,2,3,3,3,4)
x3 <- c(90,105,105,90,105,90,75,105,90,75,90,75,90,90,75)
y <- c(24,28,40,42,11,16,126,34,32,32,34,17,30,17,50)
dat <- data.frame(x1,x2,x3,y)
1. Fit a first order model using Poisson Regression with the Log-Link
model <- glm(y~.,family = poisson(link="log"),data = dat)
summary(model)
##
## Call:
## glm(formula = y ~ ., family = poisson(link = "log"), data = dat)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.3497 -2.7886 -0.5767 1.3166 6.0752
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 8.243925 0.530997 15.525 < 2e-16 ***
## x1 -0.346247 0.060457 -5.727 1.02e-08 ***
## x2 -0.088511 0.059548 -1.486 0.137
## x3 -0.026742 0.004054 -6.597 4.19e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 213.45 on 14 degrees of freedom
## Residual deviance: 133.38 on 11 degrees of freedom
## AIC: 219.96
##
## Number of Fisher Scoring iterations: 5
Above is the summary of the fitted poisson model on our data using log link
This summary gave beta parameters as follows
Beta 0 8.24
Beta 1 -0.346247
beta 2 -0.088511
beta 3 -0.026742
Q2) 2. Fit a first order model using Poisson Regression with the Identity link
model2 <- glm(y~.,family = poisson(link="identity"),data = dat)
summary(model2)
##
## Call:
## glm(formula = y ~ ., family = poisson(link = "identity"), data = dat)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.9743 -2.5317 -0.8320 0.9487 8.5725
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 153.6777 18.3859 8.358 < 2e-16 ***
## x1 -6.7614 2.0263 -3.337 0.000848 ***
## x2 -5.3548 2.0278 -2.641 0.008273 **
## x3 -0.6835 0.1352 -5.055 4.31e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 213.45 on 14 degrees of freedom
## Residual deviance: 157.17 on 11 degrees of freedom
## AIC: 243.74
##
## Number of Fisher Scoring iterations: 17
Above is the summary of the fitted poisson model on our data using identity link
This summary gave beta parameters as follows
Beta 0 153.677
Beta 1 -6.7614
beta 2 -5.3548
beta 3 -0.6835
Q3) 3. Compare the model deviances between questions 1 and 2, which would you choose?
deviance_model1 <- 213.45- 133.38
deviance_model2 <-213.45 - 157.17
deviance_model1
## [1] 80.07
deviance_model2
## [1] 56.28
As we can see that the residual deviance of the model with log link is less hence we will select the model 1 which is fitted using log link with
Q4) 4. For the model of question 3, what is the estimated mean number of unpopped kernels when Temperature is 5, Oil is 3, and Time is 90?
X1 <- c(5)
X2 <- c(3)
X3 <- c(90)
pred <- predict(model,data.frame(x1=X1,x2=X2,x3=X3),type = "response")
pred
## 1
## 46.54296
Hence 46.54296 is estimated mean number of unpopped kernels when Temperature is 5, Oil is 3, and Time is 90
Q5) For the model of question 4, what is the estimated probability that there will be less or equal to 30 unpopped kernels when Temperature is 5, Oil is 3, and Time is 90?
ppois(q = 30,lambda = 46.54296 )
## [1] 0.006484191
0.6484191 % estimated probability that there will be less or equal to 30 unpopped kernels when Temperature is 5, Oil is 3, and Time is 90