Announcement

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

  • Getting survey SD in the return list

    Hi
    Du anyone know how to get the survey SDs (1.221283 og 1.405879) in the output below into eg a matrix:

    Over Mean Std. Dev.

    value
    F 2.276053 1.221283
    M 2.47721 1.405879
    Sample code are below.
    Both after svy:mean and estat the same set of values are saved in e(V), but they aren't similar to anything in the output.


    Kind regards nhb


    Code:
    clear
    
    * Generate data
    set obs 50
    set seed 12345
    generate sex = int(2 * runiform())
    label define sex 0 F 1 M
    label values sex sex
    generate strata = int(3 * runiform())
    label define strata 0 S1 1 S2 2 S3
    label values strata strata
    generate value = sex * strata * runiform() + 4 * runiform()
    
    * Generate population totals and weights
    generate N = 8000*(strata == 0) + 4000*(strata == 1) + 11000*(strata == 2)
    bysort strata : generate w = N / sum((N < .))
    bysort strata : replace w = w[_N]
    
    * Setting up svy
    svyset [pweight=w], strata(w)
    
    svy:mean value, over(sex)
    matlist e(V)
    estat sd
    matlist e(V)
    Kind regards

    nhb

  • #2
    estat sd saves results to r().

    Code:
    estat sd
    return list
    matrix list r(mean)
    matrix list r(sd)
    matrix list r(variance)

    Comment


    • #3
      Hi Jeff
      Thank you.
      This is embarrassing.
      Why didn't I see that myself?
      Anyway thank you very much.

      Have a nice weekend

      Kind regards/nhb
      Kind regards

      nhb

      Comment

      Working...
      X