pysal / mgwr

Multiscale Geographically Weighted Regression (MGWR)
https://mgwr.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
368 stars 126 forks source link

I think the critical t-value calculation is (a little) incorrect #79

Open mattwigway opened 4 years ago

mattwigway commented 4 years ago

On line 902 of gwr.py, we have:

critical = t.ppf(1 - alpha, n - 1)

I think the degrees of freedom should be n - ENP - 1, with ENP being the effective number of parameters.

TaylorOshan commented 4 years ago

I see your point that the degrees of freedom for a regression t-test should be n - p - 1 rather than n - 1 where n is that sample size and p is the number of estimated parameters. However, I'm not sure we should substitute in the effective number of parameters here because that pertains to the overall model degrees of freedom. Since GWR is an ensemble of ordinary least squares estimators, I think each individual t-test would still have n - p - 1 degrees of freedom. I haven't seen this explicitly discussed in the literature anywhere so I would be open to other input @mattwigway @ljwolf @weikang9009 or sources from similar methods.

In any event, the existing code may produce a difference in the critical t-value, though it is likely negligible unless sample size is very small. Nevertheless, it would be good to update it to the correct expression.