Announcement

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

  • Using lincom outputs

    Hi All,
    I'm trying to use the -lincom- command with a survey population. This is what I have now:


    Code:
    svy, subpop(expansion): proportion hlthpln1, over(race acaint)
    lincom _b[_prop_2:_subpop_2] - _b[_prop_2:_subpop_1]
    lincom _b[_prop_2:_subpop_4] - _b[_prop_2:_subpop_3]
    lincom _b[_prop_2:_subpop_6] - _b[_prop_2:_subpop_5]
    
    svy, subpop(nonexpansion): proportion hlthpln1, over(race acaint)
    lincom _b[_prop_2:_subpop_2] - _b[_prop_2:_subpop_1]
    lincom _b[_prop_2:_subpop_4] - _b[_prop_2:_subpop_3]
    lincom _b[_prop_2:_subpop_6] - _b[_prop_2:_subpop_5]

    As written right now, each -Lincom- outputs a coefficient that is the difference between two subpopulations (red below). It also outputs std error, t value, p value, and 95% confidence intervals. As shown below:
    Code:
     . lincom _b[_prop_2:_subpop_2] - _b[_prop_2:_subpop_1]
     ( 1)  - [_prop_2]_subpop_1 + [_prop_2]_subpop_2 = 0
    
    ------------------------------------------------------------------------------
      Proportion |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             (1) |   .0439819   .0031052    14.16   0.000     .0378958     .050068
    ------------------------------------------------------------------------------
    I am trying to run a lincom between the expansion and nonexpansion sets of lincoms (bolded above) to find a difference-in-difference. I could just manually subtract the two outputs, but I am looking for a confidence interval, as well.

    Ultimately my question is: is there a way to create a variable that captures only the coefficient outputs of each lincom and then run a lincom on that?


    Thanks!





  • #2
    Well, the coefficient and standard deviation are single numbers, so there is no point in creating a variable out of them, or at least not for your purposes.

    Code:
    svy, subpop(expansion): proportion hlthpln1, over(race acaint)
    lincom _b[_prop_2:_subpop_2] - _b[_prop_2:_subpop_1]
    local coef_expansion = r(estimate)
    local se_expansion = r(se)
    local df_expansion = r(df)
    
    svy, subpop(nonexpansion): proportion hlthpln1, over(race acaint)
    lincom _b[_prop_2:_subpop_2] - _b[_prop_2:_subpop_1]
    local coef_nonexpansion = r(estimate)
    local se_expansion = r(se)
    local df_expansion = r(df)
    And with both coefficients, their standard errors, and the degrees of freedom saved in those local macros you have all you need to do your difference calculation and get a confidence interval.

    More generally, if you want to grab a number that Stata outputs in a command and hold on to it for later calculation, you will usually find it in either e() or r() after the command runs (or, sometimes, you will find other outputs from which you can calculate directly the one you want). The trick is to know what they are called. The easy way is to just do a dry run. Run some simple-minded regression and then some simple-minded lincom command, and then run -return list- to see what is saved in r(). -ereturn list- will show you what has been saved in e().
    Last edited by Clyde Schechter; 27 Aug 2017, 18:38.

    Comment


    • #3
      Do you mean running -lincom- to create the differences? So something like:

      Code:
      lincom coef_expansion - coef_nonexpansion
      because that returns

      Code:
      [coef_expansion] not found
      r(111);
      I'm unclear on how to do the difference calculation to get a confidence interval without using lincom.

      Comment


      • #4
        No. You need to learn about local macros and how they work. They are an important part of the Stata toolbox. Start with the User's Guide [U] volume of the PDF manuals that come with Stata. (If you're using Stata version 15, the current version, it's section 18.3 in [U]).

        Specifically in your situation:

        Code:
        local difference = `coef_expansion' - `coef_nonexpansion'
        local pooled_se = sqrt(`se_expansion'^2 + `se_nonexpansion'^2)
        local pooled_df =`df_expansion' + `df_nonexpansion'
        
        local tfactor = invttail(`pooled_df', 0.025)
        local lb = `difference' - `tfactor'*`pooled_se'
        local ub = `difference' + `tfactor'*`pooled_se'
        
        display "Difference = `difference', 95% CI `lb' to `ub'"
        For many types of models you do not have to do this. There is the -suest- command that will combine the results of different models and then you can apply -lincom- directly to get the difference in differences of things that are from different models. But -suest- does not support every model, and you do not show your regression commands, so I have made the presumption that they are not among the ones that -suest- supports. But if they are, doing it with -suest- is easier. So read -help suest- and go to the manual chapter that is linked to from that help file. There are worked examples that are similar to what you are trying to do.

        At the end of the day, anyone who is going to be using Stata more than occasionally needs to get familiar with its most basic constructs and commands. The easiest way to do that is by reading the Getting Started [GS] and User's Guide [U] volumes of the PDF manuals that come with your installation. There you will learn the way Stata approaches data management and analysis, and the most important commands that everybody needs to use. You won't remember every detail, but when confronting a problem such as this one, you will likely be able to figure out which ones are going to be useful for solving it, and then you can go to the help files or manual sections to refresh your memory on the details.

        Comment


        • #5
          Dear Clyde,
          I have question on how to install the command mlincom in stata 18. I have tried: ssc install mlincom, replace. I got the following message:
          ssc install: "mlincom" not found at SSC, type search mlincom
          (To find all packages at SSC that start with m, type ssc describe m)
          Could you please help

          Comment


          • #6
            -mgen- is part of the spost13_ado package; use the -search- command to find and install:
            Code:
            search spost13_ado
            Last edited by Rich Goldstein; 01 Jul 2023, 03:56.

            Comment

            Working...
            X