I would like to obtain the significance value for a correlation computed on complex survey data in R! As far as I know, correlations are calculated as follows with the survey package:
var <- svyvar(~var1+var2, design, na.rm=TRUE)
cov2cor(as.matrix(var))
This only provides the correlation coefficients, though. Hence my question: How can I get the significance value for such a correlation? I know that this might be done by passing the sig.stats = TRUE argument to the svycor function in the jtools package:
svycor(~var1+var2,
design,
na.rm = TRUE,
sig.stats = TRUE,
bootn = 1000)
This, however, relies on the wtd.cor function in the weights package - which I somehow have troubles installing, due to some issue with the gdata dependency. Does anyone have a workaround for this? Thanks a lot in advance!
The easiest way to get this significance test is
The null hypothesis that the correlation is zero is exactly the null hypothesis that there is no linear component to the relationship between the variables. This gives you very close to the test you could do if
svycontrastworked onsvyvaroutputThat is, assume
then with the built-in
dclus1data set as an exampleand
for basically the same z-statistic that you could then turn into a p-value.
This is better than using the
weightspackage, becauseweights::wtd.cordoesn't account for clustering or stratification, only for weights.