R language Access Menu

Title Text Both  

Regression after Box-Cox transformation

This is often done to deal with non-normal distribution in regression equations: 

Code:

> library(car)
> p1 = powerTransform(bwt~., data=bwdf)
> yy = bcPower(bwdf$bwt, p1$roundlam)
> bwdf2 = bwdf[-9]
> bwdf2$yy = yy
> formula2 = as.formula('yy ~ .')
> mod = lm(formula2, bwdf2)
> summary(mod)

Call:
lm(formula = sf2, data = bwdf2)

Residuals:
     Min       1Q   Median       3Q      Max 
-1825.26  -435.21    55.91   473.46  1701.20 

Coefficients:
            Estimate Std. Error t value             Pr(>|t|)    
(Intercept) 2926.962    312.904   9.354 < 0.0000000000000002 ***
age           -3.570      9.620  -0.371             0.711012    
lwt            4.354      1.736   2.509             0.013007 *  
race2       -488.428    149.985  -3.257             0.001349 ** 
race3       -355.077    114.753  -3.094             0.002290 ** 
smoke1      -352.045    106.476  -3.306             0.001142 ** 
ptl          -48.402    101.972  -0.475             0.635607    
ht1         -592.827    202.321  -2.930             0.003830 ** 
ui1         -516.081    138.885  -3.716             0.000271 ***
ftv          -14.058     46.468  -0.303             0.762598    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 650.3 on 179 degrees of freedom
Multiple R-squared:  0.2427,    Adjusted R-squared:  0.2047 
F-statistic: 6.376 on 9 and 179 DF,  p-value: 0.00000007891


    Comments & Feedback