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.
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:
WEIGHT BY weightvariable. CROSSTABS interestingstuff BY relevantvariable.
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.