Repository navigation
Conversation
|
fails on 2 older numpy not sure what's going on. idx should be something like |
|
It looks like python 2.7 incompatibility, not related to numpy The division from the future solved it. |
4ecdd47 to
7b05449
Compare
|
runtime warning during cross-validation (I think). I did not investigate, I'm not sure whether and how empty bins are causing it. |
|
last commit adjust the cross-validation window length choice in a semi ad-hoc way.
We bias the choice of window length: Because cross-validation undersmooths in all the examples with smaller sample sizes, we increase the bandwidth up to an acceptable loss in terms of MSE, given by shift_loss. By default this is now 10 % of acceptable loss in MSE. ( |
|
my script files based on modification date of files "\scripts\try_nonparametric_binned.py" |
this implements binning for local constant and local linear kernel regression following Fan and Marron 1994
It also adds a simple cross-validation with leave k-th bin out to choose the bandwidth
This undersmooths in small samples.
speed is very good, but there still might be a little bit of slack.
see https://groups.google.com/d/msg/pystatsmodels/KVmXLAJfMxU/lUaoV51oCwAJ
It works, but
Maybe replace MSE with something less quadratic, to not be influence so much by large residuals.
If the half window is smaller than the number of explanatory variables, then the design matrix for the local regression is singular at the boundaries. I think this is the zero division warning when the window length was too small in the cross-validation, i.e. minimum window length is 3 for linear.
if the window length is small and there are empty bins, then the design matrix could also be singular if we don't have enough grid points with non zero weights.
This uses only convolution. Additional results like effective degrees of freedom are not available. (that's why I used cross-validation for choosing window length given that the algorithm is fast)
Auxiliary quantities for binned observations in Turlach and Wand 1996 use the local regression representation and I have not tried to derive those for a convolution version. (diagonal of hat/smoother matrix for local constant looks ok, but for local linear regression it requires that we solve analytically a partitioned inverse, which I didn't try.
update see #3493 for follow-up idea of combining convolution and linalg for regression, which should solve this issue because we can use the linear algebra version with x.T W x directly, which means we can also calculate cov_params (x.T W x)**(-1) and some assumption, like homoscedasticity, on the error variance.
As byproduct of cross-validation we get a out-of-sample (leave many bins out) estimate of the mean squared prediction error MSE). But it's not used yet outside of cross-validation.
My plan is to merge this as basic smoother, and leave additional bandwidth selection methods and results statistic for the future, when I have again a week or three available.
I also haven't looked yet for references for a convolution version for local polynomial regression with order higher than linear.
This is a companion to #3380 which focuses on variance estimation with almost equal spaced regressor and nonparametric mean function.
One difference to #3380 and to Savitzky-Golay is that in this PR we handle frequency weights coming from the binning.