Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206278

Weighted dataset for complex survey

$
0
0

I have a dataframe with part of the NHANES dataset (which is a complex survey) and a weights to apply on it. A screenshot of part of the dataframe and the weights are shown below:

enter image description here

People are represented by SEQN variable. I want a new dataframe with repeated people which represents the weighted dataframe. An example of it (got in NHANES R package) is shown below:

enter image description here

Variables are different in this new dataset, but I put it here just to illustrate what I want: you can notice that person with SEQN = 51624 is repeated three times in the weighted dataset. How should I apply weights to get a dataframe like this one to my dataset? I've already tried R survey package, as described here. The problem is that the method 'svydesign' gives an object from class 'survey.design'. As long as I understand, this object represents the weighted dataset but it can only be used inside methods from 'survey' package (for example, the method 'svyglm', which does linear regression). But what we want is the weighted dataframe, like the one I showed here.

Thanks in advance!


Viewing all articles
Browse latest Browse all 206278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>