Here is the setup:
We want to estimate the proportion of people in a country who wear black socks versus not-black socks. We have 100 cities (primary sampling units) in the country. In each city there are a certain number of blocks (secondary sampling unit) and in each block there are a certain number of houses (tertiary sampling units). We do not know the number of blocks, houses, or people before sampling begins. Once we select a house we do a census of all occupants to determine their sock colors. The sock color for each occupant will be reported as bs=1 for black socks and bs=0 for not-black socks.
The sampling commences by randomly selecting a number of cities, 10 for example. In each selected city we enumerate the number of blocks in that city. In each of the selected cities a number of blocks (say 5) are chosen at random. In each of the selected blocks the number of houses on that block is enumerated. Finally, a number of houses (say 5) on each chosen block is selected at random and the sock-color census performed in each of these houses. Given this information we can assign a sampling probability p to each house selected. The datafile will consist of a row for each person, listing the city.ID, block.ID, house.ID, p, and bs.
And here are the questions:
(1) Is this a valid sampling design, i.e., given the information provided can we get reasonable estimates of the proportion of people in the country who wear black socks and the standard error of the estimate?
(2) Is this how one might specify the design in R and Stata and calculate the result?
design <- svydesign(~city.ID+block.ID+house.ID,probs=~p,data=sampfile) svymean(~bs,design) gen wt = 1/p svyset city.ID [pweight=wt], vce(linearized) singleunit(missing) || block.ID || house.ID svy: mean bs