Computing and comparing weighted group means
The package 'weights' performs an unpaired t-test using R.
For example the code below performs this
wtd.t.test(erData$mAQ.M, erData$mAQ.F, weight=erData$males, weighty=erData$females, samedata=T) #t test for males/females
This pdf document explains how to obtain weighted means and obtain a weighted variance by simply multiply the 'usual' unweighted variance by a scalar function of the weights. In addition it gives formulae for the variance of the difference in weighted means which are then used in an unpaired t-test.
You can also use the linear regression procedure in SPSS to do weighted least squares since this procedure as a weight subcommand. You can also use WEIGHT CASES in SPSS but if you do this you need to standardized the weights so they sum to the sample size in order to obtain the correct standard errors, t values and p-values.
For example suppose I have 34 observations with weights, wtadj, which sum to 199.716. If we create a new weight variable, stanwtadj, equal to the (Number of data points * wtadj)/(sum of wtadj) we can then perform the weighted one sample t-test using the one sample t-test procedure which is the equivalent of fitting a regression only including the intercept with weights, wtadj.
COMPUTE stanwtadj=34*wtadj/199.716. EXECUTE. T-TEST /TESTVAL=0 /MISSING=ANALYSIS /VARIABLES=y /CRITERIA=CI(.95).