Skip to content

FAQ-D: compositional/multinomial/multivariate versus ordered logit #3537

Open

Description

@josef-pkt

(semi-random design thoughts)

main issue: do we need to compute all possible "choices"?

    1. In multinomial and discrete choice models the endog is multivariate binary, so it is possible in some cases to compute only the statistics/loglikelihood for the observed choice.
    1. With compositional or multivariate continuous data we observe non-zero values for all "choices" and need to compute the full set of statistics/loglikelihood.
    1. If we want to reuse multinomial as compositional quasi-likelihood models, then we also need the loglikelihood and score for all choices

In case 1.

  • MNLogit and similar need statistics for all choices to compute normalization, so we need to do already most of the computation for the full case
  • ordered Logit, interval censored endog and similar define the probabilities independently from each other based on a latent variable. We don't need to compute anything about the non-observed choices.

so for 3. we have a trade-off between reusable model/code versus computational efficiency (compute only what's needed for the specific, narrowly defined model.)

compositional data: shares restricted to the simplex
projected data: multivariate random variable projected to the unit circle/sphere or simplex

Activity

  1. mortonjt commented on Mar 4, 2017

    @mortonjt
    Contributor

    Pretty excited that you brought up concerns with compositional data.

    We're doing quite a bit of compositional statistics in gneiss at the moment, and are heavily relying on the statistics available in statsmodels.

    I'm not exactly sure what you mean by choice - are you referring to the proportions, or the choice of an orthonormal basis? The calculations were doing allow for a user to pick a tree to represent the ratios of all proportions. It boils down to n-1 regressions for n proportions - so it is a bit computationally expensive, but in practice is not too bad, since we can recycle many of the standard regression techniques used here.

    Considering model statistics, compositional regression models boil down to multivariate response variables, so you can definitely calculate quantities such as SSE and R^2 for the entire fit. We're still in the process of adding better summary statistics, so if you have other ideas, that would be awesome!

  2. josef-pkt commented on Mar 4, 2017

    @josef-pkt
    MemberAuthor

    Thanks for the reference and link.

    In econometrics discrete choice usually refers to any type of model where each observation is a pick one out of k selection. That is the response endog is essentially a multivariate (binary) indicator function.
    The probabilities for selection is multivariate on the simplex.

    One idea for code and model reuse is that the same structure can be applied to fractional or compositional data.
    For example Logit, Probit, GLM-Binomial are written for binary response, but we intentionally don't enforce that endog is binary. So the same model works for fractional data, that is any data where the support is restricted to the [0, 1] or, by translation, any other finite interval. This uses quasi-likelihood which works fine for the parameter estimates but we need to adjust cov_params.

    The same idea works for multivariate compositional data, where the main common feature is that the data and the predictions are restricted to the simplex (or I think we get something similar for circular or angular data by restricting to a sphere).
    However, I haven't checked our MNLogit for this, and some discrete choice, multinomial logit, ordered logit models take computational shortcuts which rules out the reuse for compositional data.

    I haven't looked at the models that are explicitly built for compositional data, some R package authors (Filzmoser, ...) are very active in this area, but I only read abstracts. (There is also an old econometrics literature on estimating shares, like cost or expenditure shares, which is similar multivariate with aggregation restriction.)

    Also, we recently started to implement more multivariate statistics, and I expect that we will get soonish (?) some better handling for multivariate response models outside the few special cases that we have right now like MNLogit and VAR in time series analysis. Having specialized implementation for multivariate models should make them computationally more efficient than working with a nation of univariate models.

    (Related context for bivariate models or models with a restricted bivariate interpretation #3528 complex-valued response, #3530 directional or angular response)

    I birefly looked now at two gnaiss notebooks (not enough to understand any details)
    A, maybe superficial, similarity for fixed tree structure and endogenous shares: nested logit models are one type of discrete choice models when we can arrange the choice options into a tree by how close the alternatives are to each other. In personal expenditure data, it would be a tree which fraction of income to spend on food categories, clothes, entertainment, transport .... (but I haven't looked at that in a very long time).

  3. josef-pkt commented on Mar 4, 2017

    @josef-pkt
    MemberAuthor

    this paper makes the connection to multinomial logit and nested logit
    Fry, Tim R. L., and Derek Chong. 2005. A Tale of Two Logits, Compositional Data Analysis and Zero Observations. Universitat de Girona. Departament d’Informàtica i Matemàtica Aplicada. http://dugi-doc.udg.edu//handle/10256/662.

    skimming the paper
    Simplicial regression. The normal model
    J. J. Egozcue, J. Daunis-i-Estadella, V. Pawlowsky-Glahn, K. Hron and P. Filzmoser
    They have different representation and models, but I didn't see in skimming how the models affect whether bacteria/animals/consumer-goods are substitutes or complements or irrelevant. I.e. how that a variable that increases the presence one animal affect the presence of others.

    math: their C operator and consequently the perturbation and powering operators use symmetric projection ("divide by sum").

    (I found the Fry and Chong paper searching for "independence of irrelevant alternatives compositional data")

  4. mortonjt commented on Mar 5, 2017

    @mortonjt
    Contributor

    That's really awesome that you guys are thinking about incorporating multivariate response models!
    In the early prototyping stages of gneiss, I actually implemented a multivariate response OLS here and ditched it in order to take advantage of the out-of-the-box tools available in statsmodels (i.e. patsy, regression statistics, summaries ...). If you think these code should belong in statsmodels, maybe we can just pop in a PR.

    I'm not too familiar with MNLogit, VAR, etc -- will need to do some reading.

    To give a little more context about why compositional statistics are useful for microbial ecology, we don't typically count an entire population when performing a protocol. We subsample it, meaning that we don't know the total population mass in the original environment, suggesting that the data is compositional.

    There has been a recent flurry of papers that have employed using these sorts of statistics, particularly those taking advantage of the ilr tranform

    http://msystems.asm.org/content/2/1/e00162-16
    https://elifesciences.org/content/6/e21887
    https://peerj.com/articles/2969/

    And this transformation has multiple compelling advantages, including enforcing independence between subpopulations, performing dimensionality reduction in addition to enabling conventional statistical tools to be performed on the transformed data.

  5. josef-pkt commented on Mar 7, 2017

    @josef-pkt
    MemberAuthor

    (I only have an ipad available, so responding is a bit painful)

    This pr added MANOVA put most of the actual work is in multivariateols class
    #3291
    That class shows how to inherit the data handling, but it is incomplete especially in the results class. There are still generic features that are inherited but don't work with multivariate endog models.

    Mnlogit is the oldest multivariate model, but has several specialiced parts because it doesn't completely fit into the class hierarchy.
    So, it's not very difficult to write something for a specific multivariate model,but providivg better generic code still requires work.

    A pr would be very good in the medium term, and given the work you did, it should be possible to get all the pieces together. In the short term I am not sure how much time I will have for it given the backlog of almost finished prs, and my lack of knowledge of the compositional details.
    Another option that might produce something more immediately useful to you, might be to build something in one of your packages that could later be moved into statsmodels.

  6. mortonjt commented on Mar 7, 2017

    @mortonjt
    Contributor

    That is awesome!! I didn't know you guys recently merged in MultivariateOLS.

    The second option makes sense - we need to do a few rounds of refactoring anyways.
    We can probably reuse some of the components already implemented in MultivariateOLS.

  7. josef-pkt commented on Mar 10, 2017

    @josef-pkt
    MemberAuthor

    I finally managed to read the "Simplicial regression" paper. I didn't try to really understand the Aitchison geometry, and there are many things about the underlying statistical assumptions or implications that are not clear to me.

    However, equation (3.11) is just MultivariateOLS (with identical regressors) on the transformed variables.
    Boogaart, K. Gerald van den. 2013. Analyzing Compositional Data with R. Use R! Heidelberg: Springer.
    and an article by them "LINEAR MODELS WITH COMPOSITIONS IN R" mainly use standard linear multivariate methods including (M)ANOVA, which we have no in master.

    Also, those compositional methods are used in a wide range of fields, so statsmodels or a field agnostic package would be a good home for this.

    One possible way forward:

    • add the missing pieces to statsmodels.multivariate, especially finish MultivariateOLS
    • add a new subpackage compositional (or something like that) to collect all the supporting code and eventually full Models to handle compositional endog. One part would be the transformations, ilr, alr and/or clr, and maybe some supporting plots.

    I would be able to work or help out with the multivariate part and integration with and code reuse from statsmodels, but I assume it will take some time before I will "figure out" Aitchison style compositional analysis.
    Given that you are working on this in the bio area, this could be just copied or moved into statsmodels whenever parts are ready and depending on how it fits into your package dependencies and release requirements.

  8. mortonjt commented on Mar 10, 2017

    @mortonjt
    Contributor

    Hi @josef-pkt. Glad to hear that you managed to look over the paper. The material is quite dense - I tried to make it a little digestible in a paper that we just published recently: http://msystems.asm.org/content/2/1/e00162-16
    Of course, you have questions about it - I'll be more than happy to address them.

    Concerning porting over to statsmodels - we can definitely think about what modules we'd like to port over. We already have the key composition modules implemented in scikit-bio, where they have already been peer-reviewed extensively. And it would actually be ideal to gradually migrate these sorts of transforms into an application agnostic package.

    But we'd need to think carefully about what portions should be ported over. The core compositional transforms should be fine - but the tree manipulations, visualizations are quite gnarly. I'm not sure if you guys would want to port over the skbio.TreeNode object - there is a very high maintenance cost for having these sorts of objects. This was one of the motivating factors for developing gneiss in the first place.

    Otherwise, this is really exciting - look forward to digging into the multivariate OLS code in the near future.

  9. josef-pkt commented on Mar 11, 2017

    @josef-pkt
    MemberAuthor

    I read through most of your article (but I don't have any bio background)

    this looks also interesting, and provides a few more things that I "understand":
    Kynčlová, Petra, Peter Filzmoser, and Karel Hron. 2015. “Modeling Compositional Time Series with Vector Autoregressive Models.” Journal of Forecasting 34 (4): 303–14. doi:10.1002/for.2336.

    two general observation, AFAIU:

    1. estimation of transformed endog y
      In contrast to the description above using QMLE, we estimate the transformed y with standard multivariate methods link(y) = x *beta + u where link is ilr, clr or similar and u is error term, so we have E(link(y) | x) = x beta.
      In GLM and QMLE we estimate E(y | x) directly, i.e. something like y = link_inv( x * beta) + u

    2. invariance to choice of transformation or transformation basis:
      In the full unrestricted model, the estimates in terms of y (in simplex) is invariante to the choice of the basis for the transformation. So ilr with different tree structures or clr can be transformed into equivalent basis by linear transformations.
      However, the interpretation of individual parameters, and hypothesis on them depend on the chosen basis. To find equivalent hypothesis or parameterizations we would have to transform the corresponding contrast or restriction matrices.
      Estimating a model with parameter restrictions has the same invariance property in that individual parameters depend on the parameterization, i.e. choice of basis for transformation. This would be for example relevant if we want to impose zero constraints to a get a sparse system.

    aside: reference case here is always multivariate model, i.e. we only have common exog and not choice/species specific exog (e.g. price of a brand in brand choice models)

  10. jolespin commented on Apr 29, 2020

    @jolespin

    Thanks for looking into this @josef-pkt and @mortonjt . I will 100% use this extensively once implementation is finished. Looking forward to using it on my datasets.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions