简体   繁体   中英

Linear Regression with coefficients question

We are given the following dataset [dataset used for linear regression][1]

[1]: https://github.com/Iron-Maiden-19/regression/blob/master/shel2x.csv and we fit this linear regression model - Model A

modelA <- lm(Y ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8,data=shel2x)

which is fine but then we are given the following problem which I am unsure how to solve the following question - Fit Model B and compare the AIC of it to modelA and here is modelB:

Y = β0 + β1X1+ β2X2+ β3X2^2 + β4X4+ β5X6 +ε

So I know the beta values represent my coefficients from the first model but how do I do regression and how do I form an equation for regression.

In R, you perform a linear regression just the way you already have.

modelA <- lm(Y ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8,data=shel2x)

ModelA is a linear model of the form:

Y = beta0 + beta1*X1 + beta2*X2 + beta3*X3 + beta4*X4 + beta5*X5 + beta6*X6 + beta7*X7 + beta8*X8

So, to fit model B, you would just create another linear model in the following manner:

modelB <- lm(Y ~ X1 + X2 + X2^2 + X4 + X6, data=shel2x)

Then calling:

summary(modelA)
summary(modelB)

Should give you the summary output for the two separate linear models, which will include the separate AIC for both of them. Without running the models and without looking at your data, I'm almost positive that modelB will have a smaller AIC, as it always tends to favor the more parsimonious model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM