I have a dataset which was stratified across 3 different populations and resulted in the following sampling pattern:
A B C All
Pop Size 713 2904 4687 8305
Num Sampled 72 135 159
In order to make any statistic representative of the entire distribution I created a weight for each sample population (A,B,C).
To do this I computed the fraction of each population that was sampled, divided this by the fraction of the entire population that was sampled, and then normalized these.
Weight 0.16 0.35 0.48
I then added a column to my data set as follows:
wt <- c(0.16, 0.35, 0.48)
MyData$Weight <- wt[MyData$PopGroup]
I can then use this Weight column with the wtd.hist or wtd.mean functions or using the weight aesthetic in ggplot.
What I can not figure out is how to perform statistical tests on the weighted data. Specifically, neither the shapiro.test nor prop.test functions support a weight parameter.