Announcement

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

  • Graphs using svy:

    Dear all,

    I am trying to run an lfit graph with confidence intervals using two variables, let's call them var1 and var2.

    However since I am using weighted survey data I am understand I must use the svy: command before any written code to ensure the sample weightings are correct.

    The code I initially predicted to be correct is below, however this gives an error message as shown.

    Code:
    . svy: twoway (lfitci var1 var2)
    twoway is not supported by svy with vce(linearized); see help svy estimation for a list of Stata estimation commands that are
    supported by svy
    Please could someone suggest how I could go about producing such a graph?

    I am using Stata 15.1 for Windows 10.

    Many thanks in advance,
    James Clarke.
    Last edited by James Clarke; 16 Apr 2020, 09:57.

  • #2
    James,

    You'll need to actually estimate the model using the svy prefix and then plot predictions. Here's an example:
    Code:
    use http://www.stata-press.com/data/r13/nhanes2f
    svyset psuid [pweight=finalwgt], strata(stratid)
    
    svy: regress zinc age
    margins, at(age=(20(5)75))
    marginsplot, recastci(rarea)
    Lance

    Comment


    • #3
      Dear Lance,

      This has worked perfectly, exactly what I was trying to do.

      Thank you so much for the help!

      James Clarke.

      Comment

      Working...
      X