FAQ/wttest - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Type the odd letters out: scieNce GATHeRS knowledge fAster tHAN SOCIeTY GATHErS wisdom

location: FAQ / wttest

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).