GLM.jl icon indicating copy to clipboard operation
GLM.jl copied to clipboard

easy printing of fstat

Open compleathorseplayer opened this issue 4 years ago • 1 comments

Hi All. What about the following for easy access to ftest()?

ftest(lmodel)=(1/(1-r2(lmodel))-1)*(length(predict(lmodel))-
    length(coef(lmodel)))/(length(coef(lmodel))-1)   

I have been giving this manually to my students, but it would be nice to have it available as a method (at the moment ftest() with one argument fails)

I tried to make this into a Pull request but have never done that and got bogged down with 'branch comparisons'. Could someone please submit this if you think it is a good idea?

Maybe the function should be called fstat() to be analogous to the r2() diagnostic (a value, as opposed to a table)

compleathorseplayer avatar Jan 27 '21 18:01 compleathorseplayer

It also needs easy access to the p-value for the F-statistic.

function fstat(ols::LinearModel)
    k = length(coef(ols)) - 1
    n = nobs(ols)
    F = (1 / (1 - r2(ols)) - 1) * (n - k - 1) / k
    p = ccdf(FDist(k, n - k - 1), F)
    return F, p
end

andy-aa avatar Apr 10 '21 23:04 andy-aa

I believe #424 addressed this.

palday avatar Sep 29 '22 03:09 palday