Announcement

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

  • estadd scalar - how to change format and return results

    Dear all,

    I conduct t-tests between survey data and census data (I assume the latter to be error-free). The t-tests are run on a number of dummy-coded sociodemographic categorical variables, such as dummies for different age categories, gender and citizenship. (I am aware of the statistical limitations of computing t-tests between categorical variables).

    I am using -estadd- in order to add the p-value of the t-test to the list of scalars in order to use it for further operations. However, I encounter two problems with the output that I cannot solve even after looking up for help provided in the internet.

    Here is the code with the example of gender and nationality:

    Code:
    svy: mean d_male
    lincom d_male -($c_male/100)
    local t  = r(estimate) / r(se)
    estadd scalar p_male = 2*ttail(e(df_r),abs(`t')), replace
     
    svy: mean d_female
    lincom d_female - ($c_female/100)
    local t  = r(estimate) / r(se)
    estadd scalar p_female = 2*ttail(e(df_r),abs(`t')), replace
    
    svy: mean d_national
    lincom d_national - ($c_national/100)
    local t  = r(estimate) / r(se)
    estadd scalar p_national = 2*ttail(e(df_r),abs(`t')), replace
    
    svy: mean d_foreigner
    lincom d_foreigner - ($c_foreigner/100)
    local t  = r(estimate) / r(se)
    estadd scalar p_foreigner = 2*ttail(e(df_r),abs(`t')), replace
    I encounter two problems with the output.

    (1) In case the p-value is 0.000, the format of the scalar is e.g. e(p_male) = 4.126e-07.
    How can I change the format? I know that I can work with display, such as
    Code:
     display %8.3f e(p_male)
    However, I would like to change the format in the output of "ereturn list". Is that possible?

    (2) I compute about 20 t-tests in a row. After each command, stata confirms that the scalar is added. However, when I type "ereturn list", only the last scalar added is returned.

    Following the example from above this would be:

    Code:
    ereturn list
    Output:

    scalars:
    e(p_foreigner) = .0005030865374663
    e(rank) = 1
    e(k_eq) = 1
    e(stages) = 1
    e(N) = 4200
    .........

    These are probably very basic problems. However, I could not find proper advice, so I am thankful for any suggestion!
    Susanne


  • #2
    To the best of my knowledge, you cannot control the display format of -ereturn list-.

    Regarding problem #2, I cannot replicate your problem. Is your Stata completely up to date? (Try -update all-.)

    Comment


    • #3
      Hello Clyde,

      thanks a lot for your answer, I also had the impression that changing the format of the scalars in the output was not possible.

      Regarding problem 2, -update all- did not help.
      I should have added that before running the t-tests, I add 25 scalars stemming from a different computation, and these are all returned after -ereturn list-. So it must be a code- and not a software problem. However, the bug is probably hard to fix via remote diagnosis. I think I will change from scalars to generating variables.

      Thank you anyway!

      Susanne

      Comment


      • #4
        Oh, wait! I see it now. When I tried to replicate your problem I just ran a bunch of -estadd- command serially, and all of the results are there. But that's not what you did. You ran several blocks of code,each of which starts with -svy: mean-. And the -mean- command clears previous contents of e(), to overwrite them with the new -mean- results.

        So you can't store these results in e(). I'm not sure why you wanted to anyway. But I wouldn't make "variables" out of them either, because those "variables" would be constant--which is just a waste of memory. Why not just store them as scalars and work with them that way?

        Comment

        Working...
        X