Announcement

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

  • Using svy with graph

    Dear all,

    I am trying to use graph in Stata 16 to plot bars of the means of categorical variables (5-point scale) while using the svy command so as to have accurate point estimates.

    Here's an example of what I tried to do using a variable "nuclear" that excludes the 6th response category ("don't know").
    Code:
    . svy: graph bar nuclear if nuclear!=6
    graph is not supported by svy with vce(linearized); see help svy estimation for a list of Stata
    estimation commands that are supported by svy
    r(322);
    I had successfully used svyset to calibrate the weights with the rake option:
    Code:
    #delimit ;
    svyset [pweight=_one], rake(i.gender2 i.age1 i.region1 i.race3 i.latino i.educ1, 
        totals(_cons=25127
        1.gender2=12236 2.gender2=12891
        1.age1=7568 2.age1=8305 3.age1=9254 
        1.region1=5260 2.region1=4435 3.region1=9499 4.region1=5933
        1.race3=18242 2.race3=3191 3.race3=3694
        1.latino=20604 2.latino=4523
        1.educ1=9944 2.educ1=7748 3.educ1=7435
        ));
    #delimit cr
    I also saved the raked weights as "rake_wt":
    Code:
    #delimit ;
    svycal rake i.gender2 i.age1 i.region1 i.race3 i.latino i.educ1 [pw=_one],
    gen(rake_wt) totals(_cons=25127
        1.gender2=12236 2.gender2=12891
        1.age1=7568 2.age1=8305 3.age1=9254 
        1.region1=5260 2.region1=4435 3.region1=9499 4.region1=5933
        1.race3=18242 2.race3=3191 3.race3=3694
        1.latino=20604 2.latino=4523
        1.educ1=9944 2.educ1=7748 3.educ1=7435
        ) ;
    #delimit cr
    I know graph has a pweight option, however I get different point estimates when I set pweight equal to my calibrated weights. For example, here's the results from svy: mean:
    Code:
    . svy: mean nuclear if nuclear!=6
    (running mean on estimation sample)
    
    Survey: Mean estimation
    
    Number of strata =       1        Number of obs   =      2,836
    Number of PSUs   =   2,836        Population size =     25,127
    Calibration      :    rake        Design df       =      2,835
    
    --------------------------------------------------------------
                 |             Linearized
                 |       Mean   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
         nuclear |   3.087027   .0283936      3.031353    3.142701
    --------------------------------------------------------------
    Versus the graph I get when I set pweight equal to my calibrated weights:
    Code:
    graph bar nuclear if nuclear!=6 [pw = rake_wt]


    Without having to individually save each svy: mean result, is there a way I can graph the accurate point estimates?

    Best,
    Jason

  • #2
    Dear all,

    I am trying to use graph in Stata 16 to plot bars of the means of categorical variables (5-point scale) while using the svy command so as to have accurate point estimates.

    Here's an example of what I tried to do using a variable "nuclear" that excludes the 6th response category ("don't know").
    Code:
    . svy: graph bar nuclear if nuclear!=6
    graph is not supported by svy with vce(linearized); see help svy estimation for a list of Stata
    estimation commands that are supported by svy
    r(322);
    I had successfully used svyset to calibrate the weights with the rake option:
    Code:
    #delimit ;
    svyset [pweight=_one], rake(i.gender2 i.age1 i.region1 i.race3 i.latino i.educ1, 
        totals(_cons=25127
        1.gender2=12236 2.gender2=12891
        1.age1=7568 2.age1=8305 3.age1=9254 
        1.region1=5260 2.region1=4435 3.region1=9499 4.region1=5933
        1.race3=18242 2.race3=3191 3.race3=3694
        1.latino=20604 2.latino=4523
        1.educ1=9944 2.educ1=7748 3.educ1=7435
        ));
    #delimit cr
    I also saved the raked weights as "rake_wt":
    Code:
    #delimit ;
    svycal rake i.gender2 i.age1 i.region1 i.race3 i.latino i.educ1 [pw=_one],
    gen(rake_wt) totals(_cons=25127
        1.gender2=12236 2.gender2=12891
        1.age1=7568 2.age1=8305 3.age1=9254 
        1.region1=5260 2.region1=4435 3.region1=9499 4.region1=5933
        1.race3=18242 2.race3=3191 3.race3=3694
        1.latino=20604 2.latino=4523
        1.educ1=9944 2.educ1=7748 3.educ1=7435
        ) ;
    #delimit cr
    I know graph has a pweight option, however I get different point estimates when I set pweight equal to my calibrated weights. For example, here's the results from svy: mean:
    Code:
    . svy: mean nuclear if nuclear!=6
    (running mean on estimation sample)
    
    Survey: Mean estimation
    
    Number of strata =       1        Number of obs   =      2,836
    Number of PSUs   =   2,836        Population size =     25,127
    Calibration      :    rake        Design df       =      2,835
    
    --------------------------------------------------------------
                 |             Linearized
                 |       Mean   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
         nuclear |   3.087027   .0283936      3.031353    3.142701
    --------------------------------------------------------------
    Versus the graph I get when I set pweight equal to my calibrated weights:
    Code:
    graph bar nuclear if nuclear!=6 [pw = rake_wt]
    Click image for larger version

Name:	Graph_Statalist.png
Views:	2
Size:	27.9 KB
ID:	1633742

    Without having to individually save each svy: mean result, is there a way I can graph the accurate point estimates?

    Best,
    Jason
    Attached Files

    Comment

    Working...
    X