Import Data

# install.packages("sp")
library(sp)
data(meuse)

Build a Model using Simple Linear Regression

Linear regression is one of the most traditional way of examining the relationships among predictors and variables. As we discussed in a previous post about the general idea of modeling and machine learning, we may have the purpose of inference the relationships among variables.

Goal: examine the relationship between the topsoil lead concentration (lead column, as y-axis) and the topsoil cadmium concentration (cadmium column, as x-axis).

We use the lm function over here:

m1<-lm(lead~cadmium,data = meuse)
m1
## 
## Call:
## lm(formula = lead ~ cadmium, data = meuse)
## 
## Coefficients:
## (Intercept)      cadmium  
##       71.44        25.24

lead = 25.24 * cadmium + 71.44 The model above shows that, on average, when cadmium increases 1 unit, lead increases 25.24 units.

Please refer to our later posts about the visualization and analysis of the model.