Multiple Linear Regression in R
Contents
Math model
1 | Y = a1*X1 + a2*X2 + a3*X3 + ... + an*Xn + b |
Y
and X
are known, a
and b
will be calculated.
Data processing
Input Y
and X
to Rstudio.
1 | # build multiple regression model |
Build the model. lm()
take thes the known Y
and X
as arguments, lm(Y ~ X1 + X2 + ... + Xn)
.
1 | model = lm(GRDP~LANDU_21+LANDU_22+LANDU_23+LANDU_24, data = df) |
Model application.
1 | test = read_excel("your_test_data.xlsx") |