1
$\begingroup$

Edited again: I think that I figured out what was happening. It appears that SPSS rounds weighted counts to the nearest whole number, and then bases any subsequent statistics off of that. My sample was large enough that this caused minor (but noticeable) differences between R (which doesn't round) and SPSS (which does). Since I was looking at percentages the discrepancy in the counts wasn't apparent. I'll leave the rest here in case this is useful to anyone else, or if someone wants to correct me.

Original Question:

My basic problem is that when using weighting in R and SPSS I get different results. The only question I've seen with regards to this is this one: Why do R and SPSS give different SEs (complex survey with weights)? While the answers there are helpful for future reference, I'm currently doing very simple analyses for which those answers wouldn't seem to apply.

I have a dataset that uses sample weights. I have been using SPSS for analysis since it is what other people on my research team are using, but I generally prefer R. I tried to use R's survey package in order to calculate some proportions (using the function svytable). Currently we've been compiling fairly basic statistics using SPSS, largely proportions. I figured that (1) since the analysis is very simple and (2) the weighting scheme is simple (it only involves a single weighting variable, no strata etc.), getting identical results should be simple. My results get close in an absolute sense (within +/- .1), although for cases with small proportions edit: percentages (I was sloppy) the relative difference can be relatively large. I'm wondering if anyone knows why there would be differences.

The dataset is large and can't be reproduced here, however the weighting code I am using is:

In SPSS:

WEIGHT BY weightvariable.
CROSSTABS interestingstuff BY relevantvariable.

In R:

library(survey)
design<-svydesign(ids=~0,weights = weightvariable, data=mydata)
results<-svytable(~interestingstuff+relevantvariable, design)
#this is to convert from counts to percentages
results<-round(t(t(results)/colSums)*100,3)

Any help would be greatly appreciated.

$\endgroup$
  • $\begingroup$ Please add examples of how the resulting values differ between the R and SPSS analyses. Questions about software per se are off-topic here, but if there are differences in the statistical approaches these systems use it would be important to document them. Maybe also show the results in the 2 systems with and without weighting. $\endgroup$ – EdM Jun 10 at 19:47
  • $\begingroup$ @EdM I think I figured out what is going on, and I'll edit my question to reflect that (although the question may be off topic and eventually removed). It appears that SPSS is rounding the weighted counts to the nearest whole number and then basing the rest of the statistics off of that. I don't have tons of experience using weights, but that seems like something that SPSS shouldn't be doing. $\endgroup$ – pgok Jun 10 at 22:48
  • 1
    $\begingroup$ A difference in rounding of weighted counts between platforms seems to be of sufficient interest to statistical practice that it would be good to document that in an answer. You can post an answer to your own question. $\endgroup$ – EdM Jun 11 at 0:59
  • $\begingroup$ A little Googling (try "SPSS crosstabs weight") turns up an authoritative explanation at ibm.com/support/pages/some-options-fractional-weights-crosstabs. $\endgroup$ – whuber Jun 11 at 14:35
1
$\begingroup$

In answer to my own question, after some comparisons between the count output (instead of the percentage/proportion output) shows that the problem is that the SPSS default is to round weighted counts to the nearest whole number. Subsequent statistics (at least in my application) are based on these rounded numbers. R does not default to rounded counts so when calculating percentages/proportions the R results will be slightly different than the SPSS output. My understanding of the SPSS documentation is that you can choose whether or not SPSS will round or truncate, but there is no obvious way to get it to do neither (even when computing exact statistics SPSS says it will round prior to calculating the statistics, which seems slightly deceptive, but I digress). You can mimic the default SPSS behavior in R by simply doing round(output,0) where the output is the raw counts given by a function like svytable.

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

The ASIS option in SPSS CROSSTABS will calculate with the fractional weighted cell counts with no adjustments, except for exact tests. The exact tests in CROSSTABS use algorithms provided by Cytel, makers of StatXact, and these do not allow non-integer values for cell counts.

Part of the issue here is that you're making an "apples to oranges" comparison in that the WEIGHT command, despite allowing non-integer values, is a frequency weighting function, and CROSSTABS does not recognize or make specific adjustments for sampling weights. The svytable function in R is designed for sampling weights. The SPSS Complex Samples module has a CSTABULATE procedure that handles sampling weights. The CTABLES procedure does have some basic sampling weight handling in the form of "effective base weighting" (where you specify a weighting variable in the procedure, not using the WEIGHT command).

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.