- If we're estimating the model
lm(height ~ weight,data)using weight in lbs and height in inches, will we find the same results when we convert to metric data?
October 20, 2016
lm(height ~ weight,data) using weight in lbs and height in inches, will we find the same results when we convert to metric data?normalize <- function(vect){
vbar <- mean(vect)
z <- (vect-vbar)/sd(vect)
return(z)
}
mtcars.n <- mtcars %>% mutate_each(funs(normalize))
Call: lm(formula = mpg ~ hp + wt + disp, data = mtcars.n)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.568e-17 7.740e-02 0.000 1.00000
hp -3.544e-01 1.301e-01 -2.724 0.01097 *
wt -6.171e-01 1.731e-01 -3.565 0.00133 **
disp -1.927e-02 2.128e-01 -0.091 0.92851
Residual standard error: 0.4379 on 28 degrees of freedom
Multiple R-squared: 0.8268, Adjusted R-squared: 0.8083
F-statistic: 44.57 on 3 and 28 DF, p-value: < 1e-04
library(stargazer) fit1 <- lm(mpg ~ hp + wt + disp, mtcars) fit2 <- lm(mpg ~ hp + wt + disp, mtcars.n) stargazer(fit1,fit2,type = "html")
| Dependent variable: | ||
| mpg | ||
| (1) | (2) | |
| hp | -0.031** | -0.354** |
| (0.011) | (0.130) | |
| wt | -3.801*** | -0.617*** |
| (1.066) | (0.173) | |
| disp | -0.001 | -0.019 |
| (0.010) | (0.213) | |
| Constant | 37.106*** | 0.000 |
| (2.111) | (0.077) | |
| Observations | 32 | 32 |
| R2 | 0.827 | 0.827 |
| Adjusted R2 | 0.808 | 0.808 |
| Residual Std. Error (df = 28) | 2.639 | 0.438 |
| F Statistic (df = 3; 28) | 44.566*** | 44.566*** |
| Note: | *p<0.1; **p<0.05; ***p<0.01 | |