Skip to content

Prediction for functional regression - #2172

Merged
josef-pkt merged 21 commits into
statsmodels:masterfrom
kshedden:predict-functional
Feb 5, 2015
Merged

josef-pkt merged 21 commits into
statsmodels:masterfrom
kshedden:predict-functional

Conversation

@kshedden

Copy link
Copy Markdown
Contributor

This is a prediction method tailored to functional regression models in which one or more variables is modeled using b-splines.

The code doesn't produce any graphs of its own, but one natural thing to do with the predictions is to plot them, producing plots like this:

https://umich.box.com/shared/static/g2jx0wi5lo2r8liknpib.pdf

This is implemented as functions that are currently in the sandbox, but could be moved to become a method of the base results class (with the glm version attached to glm results class).

Related to #2151, but tailored to the functional case.

It would be nice to have an option for the pointwise confidence band to be a simultaneous confidence band.

@kshedden

Copy link
Copy Markdown
Contributor Author

For OLS, the simultaneous confidence band is easily obtained using Scheffe's method. For GLM's it may be much harder but here is one reference:

http://projecteuclid.org/euclid.aos/1016218225

@josef-pkt

Copy link
Copy Markdown
Member

Looks good overall, but we are getting different versions for similar functionality.
I put milestone 0.7 but we might not have it ready with a "reasonably stable" API to advertise it as an official function and method for the results classes.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.34%) when pulling 0a3b18a on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.34%) when pulling 91da2fb on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.34%) when pulling 567985f on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.16%) when pulling 82ccdeb on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.06%) when pulling 1c0c53b on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@kshedden

Copy link
Copy Markdown
Contributor Author

Travis problems solved. It was due to not specifying dtypes on dataframe creation, and was not an issue on any of my 3 local python installs. Error messages were not helpful.

@kshedden

Copy link
Copy Markdown
Contributor Author

I've now added simultaneous confidence bands for both OLS and GLMs. The simultaneous CB's make the code in this PR tailored for functional regression analyses. I'm thinking that functional regression has enough specialized techniques that it will be better to have separate predict methods for functional and non-functional regressions. But I am open to merging this with the other predict if there is a reasonable way to do it.

I'm fine with this staying in the sandbox detached from results classes for 0.7. I and collaborators/students will be using this routinely once it's merged (need to fix #2178 to make it usable with survival regression).

There are 3 other methods for simultaneous GLM confidence bands in the Sun et al paper. Some day I may go back and look at the others. The one method that I implemented is the simplest.

Here are the updated plots created by the test script:

https://umich.box.com/shared/static/g2jx0wi5lo2r8liknpib.pdf

@josef-pkt

Copy link
Copy Markdown
Member

I'm thinking that functional regression has enough specialized techniques that it will be better to have separate predict methods for functional and non-functional regressions.

From the theoretical side I don't see any difference when using splines, given the knots it's still just a model linear in a finite number parameters (with the same asymptotics if we ignore endogenous knot selection).
Kernel estimators or other fully non-parametric estimators for the functional part would be different.

But I haven't looked at the simultaneous confidence intervals yet.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.06%) when pulling 2110a71 on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@kshedden

Copy link
Copy Markdown
Contributor Author

It's the confidence bands that are specialized to the functional case.
They assume that the points where the predictions are made fall on a
continuous path through the covariate space. The predictions themselves
are generic.

On Sun, Jan 11, 2015 at 5:55 PM, Josef Perktold [email protected]
wrote:

I'm thinking that functional regression has enough specialized techniques
that it will be better to have separate predict methods for functional and
non-functional regressions.

From the theoretical side I don't see any difference when using splines,
given the knots it's still just a model linear in a finite number
parameters (with the same asymptotics if we ignore endogenous knot
selection).
Kernel estimators or other fully non-parametric estimators for the
functional part would be different.

But I haven't looked at the simultaneous confidence intervals yet.

—
Reply to this email directly or view it on GitHub
#2172 (comment)
.

@josef-pkt

Copy link
Copy Markdown
Member

I don't understand the simultaneity issue for the confidence band, but I think I will hold off with reading until I have merged a few more PRs.
and then start with Sun Loader '94 and Loader, Sun 1997 to avoid the complications coming from GLM.
Based on the abstract it still looks like a parametric versus non-parametric issue to me instead of just functional.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.29%) when pulling 406803b on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.33%) when pulling b7f2a9d on kshedden:predict-functional into 3748bf2 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.33%) when pulling 4d879bf on kshedden:predict-functional into 3748bf2 on statsmodels:master.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use alpha=0.05 for the significance level of confidence intervals (one of the few greek letters) instead of cvrg_prob=0.95

@josef-pkt

Copy link
Copy Markdown
Member

@kshedden Can you rebase and force push? and then I'll merge it as it is.

We can take it out of the sandbox in 0.8 when we have settled on the structure for the various predict functions and methods.

@kshedden

kshedden commented Feb 5, 2015

Copy link
Copy Markdown
Contributor Author

Rebased, waiting for green. Let me know if you want me to squash commits.

@josef-pkt

Copy link
Copy Markdown
Member

about squashing: not really necessary given that you already rebased. You could squash the travis-only failures commits, but for the rest I prefer no squashing. (I think the extra information in commits is often useful.)

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.09%) to 83.14% when pulling 76afe21 on kshedden:predict-functional into 6441b92 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.09%) to 83.14% when pulling 76afe21 on kshedden:predict-functional into 6441b92 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

I had to restart one travis-ci job, seems to be build problems most likely not ours.

merging

josef-pkt added a commit that referenced this pull request Feb 5, 2015
ENH: Prediction for functional regression, in sandbox for now
@josef-pkt
josef-pkt merged commit df24baa into statsmodels:master Feb 5, 2015
@kshedden
kshedden deleted the predict-functional branch July 1, 2016 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants