Hello,
I just want to briefly mention that I’m fairly new to R, and this is the first analysis I try to run in the context of a complex survey design. Below a description of my problem along with a few questions.
I want to output a one-way frequency analysis. The data set contains survey weights (WTS_S), along with 500 bootstrap weights (BSW1-BSW500). The variable of interest is PROVINCE. The method to estimate variance is BRR. I’ using the following code to capture the survey design.
CCHSDesign = svrepdesign(data = myData,
weights = ~WTS_S,
repweights = "BSW[1-500]",
combined.weights = F,
type = "BRR")
I use combined.weights = F since repweights does not contain the sampling weights. Neverthelss, I get the following warning message:
Warning message:
In svrepdesign.default(data = myData, weights = ~WTS_S, repweights = "BSW[1-500]", :
Data look like combined weights: mean replication weight is 1303.63701983038 and mean sampling weight is 1302.86018957346
The previous message does no appear when I used combined.weights = F, which seems not to be appropriate in my situation.
Question 1: Is the previous warning message of any concern to me?
Question 2: Why do I get “Balanced Repeated Replicates with 456 replicates.” instead of 500 when I run CCHSDesign?
In addition to the frequencies by category of PROVINCE, I also want the standard errors (SEs). Running the following code provides the frequencies, but not the SEs.
prop.table(svytable(~PROVINCE,design=CCHSDesign))*100
Question 3: How can I get the SEs in addition to the frequencies by categories of PROVINCE?
Thanks a lot for your support,
A.G.
Welcome to the forum.
I think we need more information and sample data on the problem We need to know things such as what package(s) you are working with and the structure of the data. It may also help to know your OS and what versions of R and RStudio you are using.
See this for some suggestions on how to craft a reprex (reproducible example).
Thanks for your quick reply. Please, see further details you asked me to provide.
OS: Windows 10 (64-bit)
R version: 3.6.2
R studio version: 3.5
Package: survey
Structure of data: One observation per individual, some variables of interest (e.g. age), one survey weight (WTS_S) and 500 bootstrap weights (BSW1-BSW500).
For simplification purpose, I include only a random subsample of 20 individuals, and kept 20 bootstrap weights.
So, I ran the “svrepdesign” on this subsample using now repweights = "BSW[1-20]", and still reading less than 20 bootstrap weights (i.e. 13). I copied the data below, since I cannot upload txt or csv file. Any recommendation for the future for sharing sample data is more than welcome.
Hopefully, this is going to work for you.
Thanks. I suspect this is a bit too much outh of my area for me to be much help---I don't think I have ever used survey but it gives me and other reader a bit of an idea of what you are doing. However if I can refer you bark to the reprex link above, we really probably should see what code you are using. you can just enclose the code between two lines with a ``` on each line to present the code.
I can read in your sample data put it is better te present it in an R format. A handy way to supply sample data is to use the dput() function. See ?dput. For your sample dataset then head(dput(myfile, 20), and then just copy and paste should work.
Ideally we should be able to run your code and, maybe, duplicate the error.
Peopre are more likely to helf if they do not have to fiddle with data.
A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large dataset then something like head(dput(myfile), 100) will likely supply enough data for us to work with.
Hi again,
I already solved my problems.
Q1: When I use “combined.weights = T” I don’t get the warning message. Additionally, I compared the results with the output generated by SAS and both match. So, I feel comfortable the right way to do is to specify T.
Q2: I coded “repweights = "BSW[1-9]+" and it worked
Q3: I was able to get what I wanted as follows:
FreqProv = as.data.frame(svymean(~factor(PROVINCE), CCHSDesign))
Thank you very much,
AG.