Skip to content

add regression.special_linear_model  #2203

Open

Description

@josef-pkt

I have been thinking for a while to add some shortcut and stripped down linear models into regression.
Stripped down means that not all functionality and results are available, i.e. "limited" models.

One possible suggestion for the module name is special_linear_model.
I thought of simplified as a name but it's a misnomer.

examples:

  • OLS based on summary statistic (e.g. covariance matrix)
  • parallel OLS: multivariate endog with shortcuts

Activity

  1. added this to the 0.8 milestone on Jan 23, 2015
  2. josef-pkt commented on Jan 23, 2015

    @josef-pkt
    MemberAuthor

    issue mainly to park the idea for a module name.

  3. kshedden commented on Jan 23, 2015

    @kshedden
    Contributor

    The parallel regression would be very useful. We often need to regress 1 y vector against many (say, 20K) x vectors in separate regressions (e.g. 20k separate regressions). Sometimes there are also additional variables z that need to go into every regression. For example, if y is a phenotype, x represents different genes that you want to assess one-at-a-time, and the z's are control variables.

    Would also be useful to have this for logistic regression but that's a bit more work to implement efficiently.

  4. josef-pkt commented on Jan 23, 2015

    @josef-pkt
    MemberAuthor

    @kshedden do you really mean one endog y and many exog x?

    The common case in neuroimaging about which we had the discussion before was one exog x, but many endog y (on time series for each pixel). Same with parameteric bootstrap.
    Both can reuse a pinv(exog) or solve the linear least squares problem with a 2-dim y.

    Is there a common structure in the many exog case that would make computational savings possible?

  5. josef-pkt commented on Jan 23, 2015

    @josef-pkt
    MemberAuthor

    I have seen a github repo (which I don't remember) that copied our GLM and vectorized it for multiple/multivariate endog, IIRC. I didn't check the details.

  6. kshedden commented on Jan 24, 2015

    @kshedden
    Contributor

    A typical example is that you have an outcome, say blood pressure, and you
    are looking for molecular predictors ('markers') of it. You have some sort
    of large-scale assay that measures thousands of candidate markers, the vast
    majority of which will be irrelevant. The basic "screening" analysis is to
    calculate the correlation coefficient between the outcome and each of the
    markers. A slightly more sophisticated version is where you have controls
    like gender and age and you want to fit multiple regression models of the
    outcome against one marker at a time and all the controls. Of course some
    people would also want to build models including several markers at a time,
    but this goes beyond what I am thinking of here.

    It's not a huge deal computationally to just loop over the markers and fit
    thousands of models one-at-a-time. But using some basic matrix
    factorizations you can do it all in just a few steps. I wouldn't want to
    reproduce everything that's in a statsmodels OLS result, just the
    parameters, fitted values, residuals, and other things that can be obtained
    in one step using linear algebra.

    I've done the imaging version of this too, where you have many voxels
    (dependent variables) regressed against covariates (stimulus type, time,
    etc.). This can also be set up as a different type of parallel regression.

    So I think a parallel regression could be quite useful.

    On Fri, Jan 23, 2015 at 2:49 PM, Josef Perktold [email protected]
    wrote:

    @kshedden https://github.com/kshedden do you really mean one endog y
    and many exog x?

    The common case in neuroimaging about which we had the discussion before
    was one exog x, but many endog y (on time series for each pixel). Same
    with parameteric bootstrap.
    Both can reuse a pinv(exog) or solve the linear least squares problem with
    a 2-dim y.

    Is there a common structure in the many exog case that would make
    computational savings possible?

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

  7. josef-pkt commented on Jan 24, 2015

    @josef-pkt
    MemberAuthor

    I wouldn't want to reproduce everything that's in a statsmodels OLS result, just the
    parameters, fitted values, residuals, and other things that can be obtained in one step
    using linear algebra.

    Yes, that's what I meant with stripped down version, and the use cases I had in mind. If the need arises we could add later some other things that will be slow or require large arrays.
    The docstrings should make it clear that these are limited purpose special versions and the use case for which they are designed.

    If you have a vectorized linear algebra version for your use case, then we could get started with this once 0.7 is out the door. I have some experimental version for some of the other cases, where I was trying to figure out the required calculations.

    I was thinking of working with skeleton versions of the current model-results class pattern, but where most things won't be inherited because our current framework won't be able to handle most of the special data structures and features.

  8. andportnoy commented on Nov 14, 2018

    @andportnoy

    @kshedden do you really mean one endog y and many exog x?

    The common case in neuroimaging about which we had the discussion before was one exog x, but many endog y (on time series for each pixel). Same with parameteric bootstrap.
    Both can reuse a pinv(exog) or solve the linear least squares problem with a 2-dim y.

    Is there a common structure in the many exog case that would make computational savings possible?

    My use case is almost exactly that (EEG data, different y for each channel for each timepoint, but potentially different X's).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions