In [1]:
%load_ext rpy2.ipython

3.4 Statistical inference

Read the data

Data are in the child.iq directory of the ARM_Data download-- you might have to change the path I use below to reflect the path on your computer.


In [2]:
%%R
# I had to import foreign to get access to read.dta
library("foreign")
kidiq <- read.dta("../../ARM_Data/child.iq/kidiq.dta")

# I won't attach kidiq-- i generally don't attach to avoid confusion(s)
#attach(kidiq)

Load the arm library-- see the Chapter 3.1 notebook if you need help.


In [8]:
%%R
library("arm")

Regression-- to demonstrate reports of fit, Pg38


In [4]:
%%R
fit.3 <- lm(kidiq$kid_score ~ kidiq$mom_hs + kidiq$mom_iq)

Display, Pg 38

Just right?


In [5]:
%%R
display(fit.3)


lm(formula = kidiq$kid_score ~ kidiq$mom_hs + kidiq$mom_iq)
             coef.est coef.se
(Intercept)  25.73     5.88  
kidiq$mom_hs  5.95     2.21  
kidiq$mom_iq  0.56     0.06  
---
n = 434, k = 3
residual sd = 18.14, R-Squared = 0.21

Print, Pg 39

Too little information?


In [6]:
%%R
print(fit.3)


Call:
lm(formula = kidiq$kid_score ~ kidiq$mom_hs + kidiq$mom_iq)

Coefficients:
 (Intercept)  kidiq$mom_hs  kidiq$mom_iq  
     25.7315        5.9501        0.5639  

Summary, Pg 38

Too much information?


In [7]:
%%R
summary(fit.3)


Call:
lm(formula = kidiq$kid_score ~ kidiq$mom_hs + kidiq$mom_iq)

Residuals:
    Min      1Q  Median      3Q     Max 
-52.873 -12.663   2.404  11.356  49.545 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept)  25.73154    5.87521   4.380 1.49e-05 ***
kidiq$mom_hs  5.95012    2.21181   2.690  0.00742 ** 
kidiq$mom_iq  0.56391    0.06057   9.309  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 18.14 on 431 degrees of freedom
Multiple R-squared:  0.2141,	Adjusted R-squared:  0.2105 
F-statistic: 58.72 on 2 and 431 DF,  p-value: < 2.2e-16