Announcement

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

  • Lowess curve in Logit

    Hello, could you please guide my how to create a plot for log odds estimated by LOWESS (obtained using the command in Stata lowess with the option) along with the linear logistic fit logit?
    Similar to:
    Click image for larger version

Name:	Screen Shot 2021-03-24 at 11.47.28 AM.png
Views:	1
Size:	35.9 KB
ID:	1599514

  • #2
    We'd need to know what data you have, and what data that paper was drawing from.

    I suspect that your paper does not have traditional individual-level data. The y-axis leads me to think that someone went and predicted CHD risk from a logit model with age as a covariate. Except that if it's from a model with age as a linear term, then the dots, which I would have assumed represent each observation's predicted risk, won't be scattered. They'll form some nice straight lines, because they're from a model. For example, try running this code.

    Code:
    webuse lbw
    logit low age i.race i.smoke
    predict xb
    twoway scatter xb age || lowess xb age
    Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	26.6 KB
ID:	1599607



    There are separate lines because I put two categorical covariates (arbitrarily chosen) in the model. The twoway syntax that I wrote would generally be how you do that graph in general, but I have no idea what that paper is plotting from. Basically, ignore the lowess line in the graph, it's meaningless, the point is that if you are plotting predictions from a model with a linear term for age, then the predictions in log odds units are going to form pretty little straight lines, because you told the model to do that. So, again, what data is the paper generating that graph from? Do you have similar data? If you do, can you present it with dataex?
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment

    Working...
    X