## 7.4 Regression analysis using lm

• Use lm to model the SIM
lreg1 = lm(formula = bhp ~ asx, data = data_lm2)
summary(lreg1)  #to generate main results

Call:
lm(formula = bhp ~ asx, data = data_lm2)

Residuals:
Min        1Q    Median        3Q       Max
-0.077007 -0.008153 -0.000162  0.007500  0.060409

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0003046  0.0005270   0.578    0.564
asx         1.0372279  0.0406422  25.521   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.01346 on 651 degrees of freedom
Multiple R-squared:  0.5001,    Adjusted R-squared:  0.4994
F-statistic: 651.3 on 1 and 651 DF,  p-value: < 2.2e-16
pander(lreg1, add.significance.stars = T)  #to tabulate
Fitting linear model: bhp ~ asx
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0003046 0.000527 0.5779 0.5635
asx 1.037 0.04064 25.52 4.215e-100 * * *
• Using stargazer to print the output
library(stargazer)
stargazer(lreg1, type = "html", title = "Regression Results")
 Dependent variable: bhp asx 1.037*** (0.041) Constant 0.0003 (0.001) Observations 653 R2 0.500 Adjusted R2 0.499 Residual Std. Error 0.013 (df = 651) F Statistic 651.320*** (df = 1; 651) Note: p<0.1; p<0.05; p<0.01
• Diagnostic Plots
par(mfrow = c(2, 2))
plot(lreg1)