# Multiple regression in R

I built the multiple regression about birth weight with independent variables with gestation, age(mom's), wt1(mom's weight), so on.. but it appears that gestation is not as important as something like race, and ht(mom's height). Is this right? or did I do something wrong about it.

m <- lm(wt ~., data=babies)
summary(m)
anova(m)

m <- lm(wt ~ gestation + age + wt1 + dage + dwt, data=babies)
summary(m)
anova(m)

m <- lm(wt ~ gestation + smoke + race + age + ed + ht + wt1 + drace + dage + ded + dht + dwt, data=babies)
summary(m)
anova(m)


## migrated from stackoverflow.comMay 7 '17 at 0:21

This question came from our site for professional and enthusiast programmers.

• what does your "gestation" variable look like? – tagoma May 6 '17 at 9:58
• something like 284 , 282 279 999 282 286... so one its a data from UsingR package babies – Coding Machine May 6 '17 at 10:02
• race, ed, drace, and ded are categorical variables with more than two levels each, you can't just throw them into a model like that – rawr May 6 '17 at 14:37

Average human gestation lasts 280 days (quick google search).

If you scatterplot your babies$gestation vs babies$wt: - it looks like there is a strong (linear) relation between the 2 variables - there are some outliers (999, where no data are available => also see UsingR documentation)

So first step would probably be removing outliers/missing data.

Going furhter if you draw an histogram, you will see there are quite a lot of points (babies$gestation) around (below and above) 300. One can think that around there, gestation has no longer influence on babies' weight. And you can check that by constraining babies$gestation.

m <- lm(wt ~ gestation < 300 , data=babies)
summary(m)

Call:
lm(formula = wt ~ gestation < 300, data = babies)

Residuals:
Min      1Q  Median      3Q     Max
-64.160 -11.160   0.421  11.840  56.840

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)          124.579      1.866   66.77  < 2e-16 ***
gestation < 300TRUE   -5.419      1.942   -2.79  0.00535 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 18.19 on 1234 degrees of freedom
Multiple R-squared:  0.006269,  Adjusted R-squared:  0.005464
F-statistic: 7.785 on 1 and 1234 DF,  p-value: 0.005349


gestation becomes statistically significant when constrained to 300. Basically, one can think there is a limit down and a limit up to the relation between gestation and babies' weight.