Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • logistic_scores is now available on SSC

    Thanks as always to Kit Baum, a new command logistic_scores is now available from SSC. Stata 9 is required.

    It's all about generating logistic scores, a transformation of graded ordinal variables best publicised in Frederick Mosteller and John W. Tukey's book Data Analysis and Regression (1977). The idea can also be seen in a long paper by Tukey written in 1961 but not published until 1986.

    This is a slow-running project, I posted some Mata code on Statalist in 2007, got around to writing a command in 2015, and tweaked it in 2022, and finally wrote up a help file this month.

    The definitions and even the derivation of the recipe are all in the help file and an ancillary document and its references.

    Take any example of such a variable. Many Stata users will know that the
    auto dataset includes rep78 -- which is repair record 1978 on a five-point scale with numeric values 1 to 5.

    Here is a graph to show what this command produces for that variable.

    Click image for larger version

Name:	logistic_G1.png
Views:	1
Size:	65.6 KB
ID:	1786879


    And here as a second example are some anonymous or at least unexplained data from Mosteller and Tukey, included so that I could check that the command produced the same results.
    Click image for larger version

Name:	logistic_G2.png
Views:	1
Size:	63.2 KB
ID:	1786880

    People not interested in this command might nevertheless be interested in the small graphical tricks for producing such displays. Complete code is included in the help file.

    In two sentences, perhaps not intelligible until you've read the longer accounts: Cumulative probabilities define breakpoints between slices of an underlying distribution taken be standard logistic. Scores are then returned as the centres of gravity of those slices.

    How far the original variables say something about whatever is being graded, or something about the people doing the grading, is a topic for discussion. Either way or both ways, they are the data we have.

    Many people reading this will have been exposed to a classification of measurement scales or levels into nominal, ordinal, interval, and ratio, That classification was revisited repeatedly in articles (and a book) by the psychologist Stanley Smith Stevens from 1946 to 1975 (the last publication was posthumous). The way it is cited varies across the entire range from purely descriptive to strongly prescriptive -- or even strongly proscriptive.


    One common argument runs that for variables like this with values 1 2 3 4 5 are, as said, just ordinal grades conventionally reported as successive integers, but not otherwise to be taken literally, which means numerically. We don't have licence, the argument runs, to treat intervals such as 2 minus 1 or 3 minus 2 as equal or even as meaning anything in particular. So the scale lacks the property that intervals can be taken literally. Still less can we take it that 2 is twice 1, 4 is twice 2, and so on. Ratios can be formed, but not legitimately. So far, so correct, but does that affect what we can do (should do) statistically? Have you heard the line that only medians make sense for such variables, and that means can't be used validly? Do you agree in principle? In your statistical practice?

    Despite this caution much of the practice of data analysis ignores or even defies any purism about measurement scales. summarize (for example) will without a murmur of discontent take such a variable and calculate not just means, but also SD, skewness and kurtosis, and so forth. Is that valid or useful? Stata's attitude, as with most comparable software, is that yours is the choice to make, and yours is the responsibility. More broadly, any number of websites post average review scores, not to mention what many universities do with student grades or marks.

    On a less abstract level: How do people use such variables? Perhaps the easiest decision to make is to treat a variable like rep78 through a set of indicator variables when it is regarded as a predictor or covariate. That answers, or avoids, qualms about measurement scale. It is letting the data show how the variable works in practice. Depending on results, researchers might leave the variable as indicators, to be emboldened to replace it with the data as it came, to use a quadratic instead, and so on.

    Logistic scores are also a variant on the letting the data show how the variable works in practice. The easy part to buy is that cumulative probabilities are well defined if anything is with such a variable. The last cumulative probability is identically 1. Otherwise we have (usually) one fewer cumulative probability than categories acting as breakpoints between slices of a distribution.

    More arbitrary is positing an underlying logistic distribution. The argument for that pivots on simplicity and tractability: the scores for each slice fall out as a result of a moderately simple calculation, as now done for you by this command.

    I wouldn't usually use logistic scores as a predictor without checking whether alternatives, notably indicator variables, give broadly similar results.

    What about logistic scores as an outcome? Recently I heard of a variable like rep78 being used as an outcome in multiple regression as it came. I had to suppress as commentary what I suppose is a fairly standard line that you should be trying something quite different instead, say ordinal logit -- or ordinal probit, or any number of alternative ordinal models from categorical data analysis. I readily confess to a chicken and egg reluctance to get involved with these models. That is, you need to use them routinely before you can wrap your head around which one to use, what to look for, and how to explain them. So, although there is always a need to check whether linearity works well enough I don't want to write off that kind of application, and now have an alternative to suggest.
    Last edited by Nick Cox; 31 Jul 2026, 03:35.

  • #2
    Thanks for this Nick Cox . (I learned a lot from the plotting examples in the help file alone!)
    Conceptual, not a coding/syntax question: I've been trying out logistic_scores on survey items where people rate things 1 to 5, and the density plot with the shaded slices is the clearest picture I've seen of what scoring an ordinal variable actually does. I'm trying to learn the ways this might be useful when someone hands me a 1 to 5 survey. One thing surprised me and I want to check I've understood it. The average of the scores always comes out to zero. That makes sense once you see it, since the slices cover the whole distribution and so the weighted average of the slice centres is just the mean of the standard logistic. But it means that if I run the command separately on two groups I want to compare, both groups average zero and the difference between them is exactly zero no matter what is going on underneath. I tried it on simulated data with a big real gap between the groups and got a coefficient of about 1e-16 with a standard error of 0.023, so it looked like a clean, well estimated null rather than anything obviously wrong. Stacking the two groups and running it once gives the difference back, though it shrinks as the gap gets wider.
    So my question is how you handle comparisons. Do you run it once on everything together and then split? And would an option to take the cut points from one dataset and apply them to another make sense (the way Roger Newson's fridit does for ridits)? I'm thinking of survey waves, where I'd want the same scale each year rather than one that moves as the answers move.
    Eric A. Booth | Sr. Researcher | Texas2036.org | www.github.com/EricABooth

    Comment


    • #3
      And to add to the points raised by Eric, what to think about survey weighted response data?
      http://publicationslist.org/eric.melse

      Comment


      • #4
        I will reply separately to the two Erics.

        eric_a_booth Bang on: the scaling is to a unit logistic with mean zero and the scores should average zero in every case. If you're comparing different data, you won't see a difference in mean unless it's some kind of machine imprecision.

        To compare different sets of grades, nothing replaces looking at those grades directly and so you need to look at their frequency distributions, and means would help more than say medians. The graphs may still help.

        That said, several kinds of other comparisons could make sense, such as taking one group as standard or reference and seeing how far some other variable differed, But wouldn't that boil down to comparing the original data directly?

        As often pointed out and even more often ignored, the fact that I understand that I should (say) type 4 if I "agree", and you do too, doesn't mean that our opinions are equivalent in strength even if we fill in the same answers. No doubt this is discussed in a more penetrating way somewhere, or in many places. I am not a psychologist or sociologist! A relative of mine reported that almost everything he experienced was OK, but another relative was irritated by almost everything she came across. Such experiences are trivial but worrying for some kinds of analyses.

        I'd recommend looking at the Mosteller and Tukey book from 1977. It's a quirky book, but some sections are timeless and make points not well covered anywhere else that I know. It's been reprinted yet copies should still be in good libraries. The discussion is scattered across two chapters and placed within a context of transformations that isn't relevant to all purposes. As often, I think I began to understand the method properly only when I had written some code to do it and looked at examples. (And rediscovered some calculus that I was better at when aged 17 than I am now.)

        ericmelse If you mean svy and pweights and so forth, that's something I've never had occasion to use, or even to try to understand. So, flippant though it may seem, I almost never implement pweights in my commands unless I am linking to a command where Stata supports them too.
        Last edited by Nick Cox; 31 Jul 2026, 11:29.

        Comment

        Working...
        X