Applying the Gaussian model for generalized linear regression
A generalized linear model (GLM) is a generalization of linear regression, which can include a link function to make a linear prediction. As a default setting, the family object for glm
is Gaussian, which makes glm
perform exactly the same as lm
. In this recipe, we first demonstrate how to fit the model to data using the glm
function, and then show that glm
with a Gaussian model performs exactly the same as lm
.
Getting ready
You need to have completed the previous recipe by downloading the house rental data into a variable, house
. Also, you need to fit the house rental data into a multiple regression model, fit
.
How to do it…
Perform the following steps to fit the generalized linear regression model with the Gaussian model:
- Fit independent variables
Sqft
,Floor
,TotalFloor
,Bedroom
,Living.Room
, andBathroom
toglm
:> glmfit <- glm(Price ~ Sqft + Floor + TotalFloor + Bedroom + Living.Room + Bathroom, data=house, family...