Repository navigation
Conversation
|
I fixed two errors because of refactored GLM in master, but didn't check the details
|
|
There is a problem for the unit tests because penalization weights, alphas, do not have a consistent scaling. I think just mechanically adjusting the test will not help because any refactoring in, for example, scale will most likely affect the penalization weights. In this case the pirls might not even have a penweight that implies a constant relative penalization (weight between loglike and penalty) during the iterations.. |
|
Also, I guess, there is still the bug in the PenalizationMixin class that is fixed in master but not yet used by GAM. |
|
there is a serious problem with cov_params in the unit test case second assert for the case when alpha is small positive number hessian in pirls estimate is singular |
|
possible problem:
Wood mentions the reparameterization in his GAM in R, 1st ed. book This means most likely I have to go through all the pieces instead of starting at the end. |
|
using pinv(hessian) with strong penalization with alpha=1e-10 the example has two components, two spline bases, but no constant |
|
another case alpha=1e-5 |
|
Ok, my guess is that this is the normalization problem with multiple splines in GAM. Checking one example in the notebook with only a single component which has full rank shows reasonable bse. |
|
looks like cov_type has no effect However, plotting get_prediction conf_int looks reasonable, the look maybe a bit wide with 95% coverage prob. update also, after restarting my notebook kernel the confidence intervals for predicted mean look very narrow (instead of wide as before) |
|
effective degrees of freedom are missing, AFAICS related from GLMResults inherited |
|
|
|
possibly a problem with args in How are partial linear model currently handled? Do we have a unpenalized dummy class for a linear component? |
|
refactor
check signature in R mgcv |
|
However, using fit_constrained directly does not help yet to impose the normalization constraints on the spline bases, we still need to transform the penalization matrices. |
|
Adding exog=None as second argument kind of works, it handles now init_kwds correctly. My guess this rules out for now that we use fit_constrained to recreate a model that has non-singular design matrix through spline basis rotation/transformation. patsy's splines have a "remove constant" option. I don't know how that works and figuring out the transformed penalization matrices might not be trivial. Adding an additional penalization towards zero mean to impose the constraint might be easier, and would lead us to more composable penalization structures. |
|
basic class structure:
one possibility would be to outsource those extra parts to a dispatch function or method, so GLMGAM has a similar signature as PenalizedMixin and other Models, i.e. similar to |
|
many unit tests are missing random seeds |
|
I don't have an overview for the implementation yet, and I don't remember enough about GAM
Penalization is quadratic in params, b S b or b R' R b I think I try to separate these two parts and use PenalizedMixin directly, as in my merged penalized PR. Note we need R or S embedded for the full params, i.e. pad with zeros. If we have exog and R or S, then we can also use TheilRidge for the linear case. We need something like design_infor to keep the information about how the component was constructed, which we need for some post-estimation results. class hierarchy for Models with penalized splines? Wood in mgcv often uses QR decomposition in the R tradition, I would prefer to stay more general at the beginning at the cost of not using model specific speedups (e.g. avoid recomputing some parts during cross validation) |
|
Notes: R is der2_basis_, I guess n_samples is nobs f = R dot params grad/deriv: deriv2 = 2 * alpha * S / self.n_samples
In this representation it would not be difficult to augment the R matrix by a concatenating mean of spline basis as additional restriction/penalization term. |
12341c4 to
ee7f4f2
Compare
|
close to the last missing piece: mgcv doc for AFAICS right now the definition doesn't look like it matches up with TheilGLS gcv, but I don't have the TheilGLS example right now to compare. Wiring up edf based df_resid and it's use in scale is going to be a bit messy. scale in GLM is estimated in the model and df_resid is defined in the model class, in i.e. we need the sequence
If scale is estimated during fit, then we would need edf estimate also in fit. messy: circular computation: edf computation currently uses |
|
BUG : fit_pirls hardcodes (I made a change and added |
|
bug-wrong in GLM: scale-type='dev' has wrong computation But I thought bse after pirls was correct before, and has some unit tests. Oh that's funny. my current solution for edf/df_resid is very hackish, but agrees with mgcv now |
|
"bug" unclear definition in mgcv results AFAICS: The I have now, my current test_significance uses edf for computing F and for computing pvalue The F statistic is the same as in |
|
travis test run doesn't work because of pytest version mismatch same error on appveyor |
|
new release of pytest https://pypi.org/project/pytest/#history I guess "somebody" thinks |
|
I commented out the minversion requiremet to see whether the tests even run with pytest 3.10 |
|
AIC: another unclear reverse engineering mgcv adds 1 to the number of params (edf) in aic slightly messy in GLM, constant is assumed in counting df_model, we don't check (in contrast to regression model) whether a constant really is in exog |
|
removing pytest minversion requirement seems to work changing the constrast wald_test summary causes a test failure with string comparison we don't want a decimal if the df_num is integer valued This test didn't fail on python 2.7 appveyor, so most likely string formatting (for integer valued float) has changed between python 2 and 3. |
|
and the last stage: finding alpha a quick experiment with just using The alphas corresponding to mgcv (in our parameterization) based on mgcv default, I think it;s min gcv |
|
Does #5370 replace this or supplement it? |
|
#5370 is a continuation and replacement of this. The same applies to the PRs that have the earlier stages of development of GAM. |
|
Thanks for clarifying. If keeping these around make things easier for you then more power to you. But if encouraging contributors to review PRs is a consideration, pruning (or at least clearly identifying) non-actionable ones would be helpful. |
rebased version of #4575 which was rebased version of #2744
The original GSOC PR with most of the development discussion is #2435
rebase conflict in compat.python:
This has now unneeded
itertools.combinationsimport but I dropped the py 2.6 compat code.