0

I am analyzing NHANES data (https://wwwn.cdc.gov/nchs/nhanes/) which use a complex, multistage, probability sampling design.

I want to plot some data in Stata using a contour plot. With non-weighted data, I would use the following command

twoway contour dbq700 bmxbmi ridageyr if cohort == 1

For survey data, however, I need weights. Once I try to consider this using the following command below, I get an error message ( " weights not allowed ")

twoway contour dbq700 bmxbmi ridageyr if cohort == 1 [aw = wtdrd6y]

It doesn't work with the svy commands either. Is it impossible to draw contour plots in Stata with survey data?

I tried:

twoway contour dbq700 bmxbmi ridageyr if cohort == 1 [aw = wtdrd6y]

I got an error message as specified above.

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
Dr.M
  • 101
  • 1

1 Answers1

1

It is not supported because weights could not make a difference to the results. That's my analysis.

Reduce the problem to a bare minimum in one dimension: At x = 1 I observe y = 150 and at x = 2 I observe y = 250. Where do I put a contour for y = 200? Evidently, the example is contrived, so that it is clear that the contour should be placed at x = 1.5.

Now add the information that at x = 1 I have the equivalent of 12 observations and at x = 2 I have the equivalent of 666 observations.

That information doesn't change the answer.

If you were considering the calculation as statistical, then knowing weights could be fed into some quantification of uncertainty, but contouring is a deterministic calculation.

That said, it seems likely that statistically you need a different analysis. Predicting what is geometrically a response surface with two predictors should indeed, however you do it, use information on weights, but that is a different question altogether.

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
  • @ Nick Cox. Thank you for your instant reply. I really appreciate your explanation. I regret I do not fully understand it. Contour plots are often used with random data to display the relationship between 3 variables. Why would this not be possible with survey data? I do not mean to sound rude, I am simply not understanding it. I saw in a related paper (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5801475/) and was wondering whether the authors did not consider weights. – Dr.M Apr 07 '23 at 12:35
  • @ Nick Cox. Sorry, the maximum length did not allow me to post my full question. Would it be invalid to use the data unweighted for a contour plot to examine the aforementioned relationship - clearly acknowledging it in a publication? – Dr.M Apr 07 '23 at 12:39
  • 1
    Contouring is just interpolation between values considered to be known. How well you know them is not part of the information. I take it you want to fit a prediction surface, but that is not contouring, even if the plot superficially looks like a contoured map. – Nick Cox Apr 07 '23 at 12:53
  • 1
    I can't comment on what is publishable in your field. If I were a journal reviewer then from what I understand of your problem I would reject contouring as an inappropriate choice of method. – Nick Cox Apr 07 '23 at 12:55