Announcement

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

  • Twoway with controls?

    Hi everyone,
    I am new here and I have a problem I have been trying to solve for a while without success.

    Is it possible to perform a two-way graph [lfitci] with slopes and ci's for multiple groups (e.g., countries) in the same "graph window" while simultaneously controlling for additional variables (which are included in the equation but not displayed in the graphs)? As soon as I add additional variables, Stata tells me that I have exceeded the maximum number of variables.

    Or is it necessary to switch to another strategy here, for instance by performing regressions with controls in multiple groups and then use another command like margins plot?

    Here is an example of a code that is working for this, but without controls:

    twoway lfitci depvar indepvar, by(cntry)

    All the best,
    Joakim

  • #2
    In short, no. lfitci is only about the data mentioned, an outcome and a predictor. It's not for displaying results after fitting a more complicated model. or a way of fitting such. As you surmise your journey lies through margins.

    Comment


    • #3
      Thank you Nick! I have tried doing that too but has so far been unsuccessful. Any suggestions or clues, for instance about a package that might help me with this? I have spent a ridiculous amount of time investigating this.

      All the best,
      Joakim

      Comment


      • #4
        You are aware of marginsplot.

        coefplot from the Stata Journal and SSC is an excellent command I've never used.

        Otherwise I can't improve on https://www.statalist.org/forums/help#stata for,how to ask a question.

        Comment


        • #5
          So, I can produce a marginsplot graph for individual regressions, but I cannot find a way of combining (group-specific) slopes for several regressions in a single graph window. I have also tried storing estimates for multiple regressions and used coefplot (but that is not what I want since I have 15 groups and the graphs become unreadable).

          I am sorry if I ask the question wrongly or if I am unspecific, I just would not know how to ask for something I don't know of myself. Anyway, here is my code to produce margin plots for separate regressions:

          Code:
          margins, at(indepvar=(-4(1)4) predict(xb)
          marginsplot, recastci(rarea) recast(line)
          How can I combine estimates from 15 separate regressions (groups) into a single graph window with slopes and ci's (for one independent variable) for each group separately?

          Joakim
          Last edited by Joakim Kulin; 15 Feb 2023, 07:18.

          Comment

          Working...
          X