HarlanH/DataFrames.jl — pull request #156 by andreasnoackjensen (2013-01-07 22:29:26+00:00)
Title: WIP: Some modifications to lm

Great work with the DataFrames and Formulas.

I have started to play with the lm functionality. Right now I'm not sure how the design should be but here is something to discuss from. It is very R like at the moment. There are some show methods, HC variance and model restrictions and some programming errors, I guess. Please comment.

```julia
julia> load("/Users/andreasnoackjensen/.julia/DataFrames/demo/lm.jl")

julia> srand(111)

julia> d=DataFrame(randn(50,4));

julia> fit=lm(:(x1~x2+x3+x4),d)

Formula([:x1],[:(+(x2,x3,x4))])

Coefficients:
(Intercept) x2 x3 x4
-0.165825 0.216786 -0.177900 -0.050906

julia> inference(fit)

Formula([:x1],[:(+(x2,x3,x4))])

Coefficients:
Term Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.16582 0.14078 -1.178 0.245
x2 0.21679 0.14196 1.527 0.134
x3 -0.17790 0.14496 -1.227 0.226
x4 -0.05091 0.15399 -0.331 0.742
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-squared: 0.0727

julia> inference_robust(fit)

Formula([:x1],[:(+(x2,x3,x4))])

Coefficients:
Term Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.16582 0.14238 -1.165 0.244
x2 0.21679 0.12864 1.685 0.092 .
x3 -0.17790 0.13886 -1.281 0.200
x4 -0.05091 0.15875 -0.321 0.748
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-squared: 0.0727

julia> restrict(fit, [0 0; 1 0; 0 1; 0 0], [0, 0])

Formula([:x1],[:(+(x2,x3,x4))])

Coefficients:
(Intercept) x2 x3 x4
-0.142910 0.000000 0.000000 -0.083976

julia> waldtest(fit, [0 0; 1 0; 0 1; 0 0], [0, 0])
F(2,46) Pr(>F)
1.911 0.159

julia> waldtest_robust(fit, [0 0; 1 0; 0 1; 0 0], [0, 0])
Chisq(2) Pr(>Chisq)
3.683 0.159
```