Hi!
I am currently working with a subsample of the 11th wave of the European Social Survey using only data from Austria and the post-stratified design weight (“pspwght”) in a dataframe with a sample of columns. I am doing this as preparation for an upcoming survey so the results themselves are to no interest to me.
This is a dput example of the data:
dput(head(Austria , 100))
structure(list(pspwght = structure(c(0.392890632152557, 0.325153321027756,
4.00002336502075, 0.176227644085884, 1.06093990802765, 1.39281249046326,
0.577186286449432, 0.61948549747467, 0.693634867668152, 0.492267221212387,
0.355206817388535, 0.313930124044418, 0.276816129684448, 0.508959949016571,
4.00062370300293, 0.416357308626175, 0.877044260501862, 1.39281249046326,
1.65953147411346, 1.28546929359436, 0.677669644355774, 1.4569765329361,
1.14213705062866, 3.25787138938904, 0.994012236595154, 0.193289756774902,
1.77882707118988, 0.348330587148666, 0.35663366317749, 0.508153080940247,
1.72783446311951, 0.911978185176849, 1.03292644023895, 0.445305109024048,
0.468475818634033, 1.42682373523712, 0.792647421360016, 3.5898962020874,
0.77514386177063, 0.274301379919052, 0.111601747572422, 1.08428049087524,
0.91899448633194, 1.02412927150726, 0.184346452355385, 0.613888680934906,
0.949091792106628, 0.465819239616394, 4.00062370300293, 1.84259843826294,
1.18525660037994, 2.51070737838745, 0.60658198595047, 0.219329491257668,
0.586152851581573, 0.5426424741745, 0.462139993906021, 0.890610218048096,
0.929227650165558, 1.41777682304382, 0.411239564418793, 0.447509318590164,
1.1829160451889, 0.268614828586578, 1.15855026245117, 1.40137541294098,
3.5764274597168, 0.674251556396484, 0.274342894554138, 0.599278211593628,
0.350841909646988, 1.22611272335052, 1.06632363796234, 0.349367260932922,
0.871076226234436, 1.62642300128937, 1.23339951038361, 0.149169757962227,
1.85931277275085, 1.547856092453, 0.124111473560333, 0.356065511703491,
4.00062370300293, 2.11004400253296, 0.829765737056732, 1.81093227863312,
0.202194035053253, 1.30419969558716, 0.232740327715874, 0.520037412643433,
1.1829160451889, 1.35533928871155, 3.57973980903625, 0.630868315696716,
0.598446130752563, 1.02866518497467, 0.91028904914856, 3.30561852455139,
0.46259668469429, 0.292296499013901), label = "Post-stratification weight including design weight", format.spss = "F3.2"),
trstprl = structure(c(6, 6, 7, 5, 6, 3, 6, 9, 6, 8, 6, 6,
6, 3, 7, 2, 7, 2, 4, 5, 7, 4, 4, 3, 5, 0, 5, 2, 5, 2, 0,
5, 8, 5, 4, 8, 8, 5, 7, 4, 0, 2, 9, 8, 5, 5, 4, 6, 4, 8,
7, 6, 3, 5, 9, 10, 7, 4, 6, 2, 4, 5, 7, 9, 5, 5, 8, 5, 2,
4, 6, 7, 5, 7, 4, 3, 7, 4, 6, 6, 6, 3, 6, 7, 4, 3, 8, 7,
4, 4, 2, 7, 6, 8, 5, 8, 0, 9, 0, 4), label = "Trust in country's parliament", format.spss = "F2.0", labels = c(`No trust at all` = 0,
`1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `7` = 7,
`8` = 8, `9` = 9, `Complete trust` = 10, Refusal = 77, `Don't know` = 88,
`No answer` = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), trstlgl = structure(c(9, 6, 5, 6, 8, 5, 5, 9,
7, 8, 8, 9, 4, 5, 9, 6, 9, 4, 5, 7, 7, 4, 5, 2, 5, 5, 7,
6, 8, 4, 6, 9, 7, 6, 8, 8, 9, 5, 6, 6, 8, 3, 10, 8, 6, 5,
7, 7, 4, 10, 10, 6, 5, 5, 10, 10, 8, 4, 5, 2, 6, 8, 9, 10,
7, 8, 7, 8, 10, 5, 8, 7, 6, 8, 6, 3, 10, 7, 8, 8, 10, 3,
5, 10, 6, 5, 9, 8, 6, 7, 7, 7, 7, 8, 3, 9, 7, 9, 0, 3), label = "Trust in the legal system", format.spss = "F2.0", labels = c(`No trust at all` = 0,
`1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `7` = 7,
`8` = 8, `9` = 9, `Complete trust` = 10, Refusal = 77, `Don't know` = 88,
`No answer` = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), trstplc = structure(c(10, 4, 8, 9, 8, 7, 8, 9,
8, 10, 8, 9, 4, 7, 9, 7, 9, 5, 6, 5, 8, 6, 5, 2, 8, 7, 8,
8, 7, 3, 6, 9, 7, 7, 8, 8, 9, 7, 7, 8, 8, 3, 9, 8, 7, 7,
7, 7, 4, 10, 8, 6, 5, 8, 10, 10, 8, 4, 7, 7, 6, 8, 9, 10,
8, 8, 7, 8, 0, 9, 10, 8, 9, 8, 7, 5, 6, 8, 8, 9, 7, 3, 8,
10, 6, 5, 9, 9, 4, 8, 7, 3, 7, 9, 9, 9, 7, 10, 4, 6), label = "Trust in the police", format.spss = "F2.0", labels = c(`No trust at all` = 0,
`1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `7` = 7,
`8` = 8, `9` = 9, `Complete trust` = 10, Refusal = 77, `Don't know` = 88,
`No answer` = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), trstplt = structure(c(5, 1, 4, 3, 5, 5, 4, 7,
3, 8, 6, 3, 9, 0, 8, 2, 6, 5, 1, 3, 8, 6, 2, 2, 4, 0, 4,
0, 3, 1, 0, 3, 8, 4, 5, 8, 5, 5, 5, 4, 1, 0, 8, 5, 2, 3,
2, 5, 4, 8, 6, 6, 1, 2, 9, 10, 5, 1, 3, 2, 4, 2, 2, 6, 5,
4, 6, 4, 0, 2, 5, 6, 4, 5, 3, 1, 2, 2, 0, 5, 5, 2, 4, 7,
2, 1, 6, 6, 1, 5, 2, 3, 5, 3, 1, 5, 0, 7, 0, 3), label = "Trust in politicians", format.spss = "F2.0", labels = c(`No trust at all` = 0,
`1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `7` = 7,
`8` = 8, `9` = 9, `Complete trust` = 10, Refusal = 77, `Don't know` = 88,
`No answer` = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), trstprt = structure(c(5, 0, 4, 3, 5, 5, 5, 6,
2, 8, 6, 3, 9, 0, 7, 2, 6, 5, 1, 3, 8, 6, 2, 2, 4, 0, 2,
2, 2, 2, 0, 3, 7, 4, 5, 8, 5, 5, 3, 3, 1, 0, 9, 4, 2, 4,
2, 6, 4, 7, 5, 6, 1, 3, 9, 10, 5, 1, 4, 2, 5, 2, 3, 6, 3,
4, 6, 4, 0, 3, 5, 7, 5, 5, 2, 1, 1, 2, 0, 3, 5, 2, 5, 7,
2, 1, 5, 6, 1, 3, 2, 3, 5, 4, 1, 5, 0, 6, 0, 5), label = "Trust in political parties", format.spss = "F2.0", labels = c(`No trust at all` = 0,
`1` = 1, `2` = 2, `3` = 3, `4` = 4, `5` = 5, `6` = 6, `7` = 7,
`8` = 8, `9` = 9, `Complete trust` = 10, Refusal = 77, `Don't know` = 88,
`No answer` = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), stratum = structure(c(107, 69, 18, 101, 115,
7, 58, 38, 62, 105, 26, 94, 100, 98, 5, 35, 75, 7, 56, 101,
17, 7, 21, 23, 45, 69, 41, 99, 77, 67, 113, 28, 61, 29, 63,
112, 44, 25, 71, 108, 94, 59, 62, 2, 101, 48, 87, 29, 11,
87, 22, 58, 45, 89, 42, 64, 37, 29, 38, 17, 36, 101, 24,
108, 58, 30, 20, 59, 99, 48, 109, 38, 48, 90, 35, 59, 11,
101, 5, 53, 66, 103, 48, 2, 56, 19, 69, 14, 87, 61, 24, 17,
21, 55, 52, 47, 101, 38, 21, 40), label = "Sampling stratum", format.spss = "F4.0"),
psu = structure(c(317, 128, 418, 295, 344, 373, 86, 3, 108,
314, 622, 242, 270, 255, 368, 783, 165, 373, 73, 283, 414,
373, 610, 429, 31, 132, 19, 266, 177, 121, 339, 660, 105,
684, 506, 335, 475, 442, 155, 319, 243, 89, 107, 557, 280,
43, 219, 679, 394, 219, 425, 83, 30, 225, 25, 109, 836, 693,
3, 411, 796, 279, 431, 318, 82, 708, 422, 89, 263, 42, 328,
1, 44, 227, 757, 90, 394, 284, 363, 61, 116, 305, 39, 550,
71, 420, 126, 397, 215, 99, 438, 410, 605, 66, 55, 37, 285,
3, 600, 13), label = "Primary sampling unit", format.spss = "F5.0")), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"), na.action = structure(c(`42` = 42L,
`55` = 55L, `70` = 70L, `110` = 110L, `134` = 134L, `178` = 178L,
`215` = 215L, `216` = 216L, `237` = 237L, `252` = 252L, `300` = 300L,
`303` = 303L, `312` = 312L, `329` = 329L, `399` = 399L, `410` = 410L,
`555` = 555L, `558` = 558L, `562` = 562L, `613` = 613L, `723` = 723L,
`767` = 767L, `782` = 782L, `801` = 801L, `802` = 802L, `840` = 840L,
`854` = 854L, `998` = 998L, `1002` = 1002L, `1101` = 1101L, `1140` = 1140L,
`1223` = 1223L, `1253` = 1253L, `1350` = 1350L, `1380` = 1380L,
`1530` = 1530L, `1560` = 1560L, `1595` = 1595L, `1666` = 1666L,
`1737` = 1737L, `1907` = 1907L, `1935` = 1935L, `1947` = 1947L,
`1965` = 1965L, `2007` = 2007L, `2164` = 2164L, `2208` = 2208L,
`2222` = 2222L, `2236` = 2236L, `2240` = 2240L, `2270` = 2270L,
`2290` = 2290L, `2297` = 2297L, `2335` = 2335L), class = "omit"))
My issue is that the survey package is not as deep as I would like it to be and lacks implementation of some measurements such as McDonalds Omega (I have been looking to alternative packages that also use survey weights to no avail).
Because of this I ended up finding an alternative procedure in which the number of rows in the dataframe are replicated based on the rounded weights producing identical results to the output of the survey package. The aim of all this is to use the "weighted dataset" and then directly apply the omega function from the psych package:
lapply(c('Hmisc','scales','haven','survey','psych'),require, character.only = T)
ESS11 <- read_sav(/ESS11.sav') # Add path here.
Austria <- subset(ESS11, cntry == 'AT')
Austria <-na.omit(Austria[,c('pspwght','trstprl','trstlgl','trstplc','trstplt','trstprt','stratum','psu')])
Experimental_sample <- Austria[rep(1:nrow(Austria), times = round(Austria$pspwght)), ]
omega(Experimental_sample[,c('trstprl','trstlgl','trstplc','trstplt','trstprt')])
Is this procedure correct? If not, are there alternative ways of obtaining McDonalds Omega with survey weights?
Also, reading other users posts I have discovered that this procedure is quite similar to how SPSS calculates weights and that it can introduce bias, is this accurate? Because otherwise, my tests with Cronbach's Alpha seem to yield similar results when testing the output of both the survey package and the Experimental_sample I created:
ESS11_weight_austria <- svydesign(ids=~psu, strata=~stratum, weights=~pspwght, data=Austria)
round(svycralpha(~trstprl+trstlgl+trstplc+trstplt+trstprt, ESS11_weight_austria),2)
*alpha*
0.88
round(alpha(Experimental_sample[,c('trstprl','trstlgl','trstplc','trstplt','trstprt')])[['total']][['raw_alpha']],2)
[1] 0.88
Any potential solutions or comments on this are welcomed, thanks in advance.