Diff for "FAQ/intslopes" - CBU statistics Wiki
location: Diff for "FAQ/intslopes"
Differences between revisions 4 and 5
Revision 4 as of 2011-06-27 14:27:22
Size: 3313
Editor: PeterWatson
Comment:
Revision 5 as of 2011-06-28 13:41:51
Size: 3321
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
Cribari-Neto (2004) recommends using a variant of the t-statistic which he calls the HC4-based quasi-t test which adjusts the standard error of the interaction regression coefficient. This may be computed using this [attachment:HC4.xls spreadsheet.] This spreadsheet also computes an extension of the HC4-based quasi-t recommended by Ng and Wilcox (2010) which is more robust to departures from assumptions underlying the computing of the variance of the regression estimates - specifically the assumption that the regression model is equally precise in both groups for all values of x (homoscedasticity). They call their estimate the HC4-based wild bootstrap quasi-t test which additionally accounts for sampling variability by sampling continually (with replacement) from the current sample to assess the variation in the t value (the 'bootstrapping' bit!) Details of how to compute this using the spreadsheet using ''complete cases'' are given [:FAQ/HChowto: here.] Cribari-Neto (2004) recommends using a variant of the t-statistic which he calls the HC4-based quasi-t test which adjusts the standard error of the interaction regression coefficient. This may be computed using this [attachment:HC4.xls spreadsheet.] This spreadsheet also computes an extension of the __HC4-based quasi-t__ recommended by Ng and Wilcox (2010) which is more robust to departures from assumptions underlying the computing of the variance of the regression estimates - specifically the assumption that the regression model is equally precise in both groups for all values of x (homoscedasticity). They call their estimate the __HC4-based wild bootstrap quasi-t__ test which additionally accounts for sampling variability by sampling continually (with replacement) from the current sample to assess the variation in the t value (the 'bootstrapping' bit!) Details of how to compute this using the spreadsheet using ''complete cases'' are given [:FAQ/HChowto: here.]

Interaction between a continuous variable and a 2 category variable (comparison of slopes)

Here we examine the special case where we wish to test the interaction between a continuous variable (x) and a two category variable (group). This is equivalent to comparing the slopes of x between the two groups.

This can be formulaed as a t-statistic of the regression estimate for the x by group interaction (x by group product) term (fitted in a regression also containing x and group). We usually code the group as a dichotmous 0-1 variable. The t-statistic for the interaction's regression coefficient can be used to assess if the itneraction is present.

Cribari-Neto (2004) recommends using a variant of the t-statistic which he calls the HC4-based quasi-t test which adjusts the standard error of the interaction regression coefficient. This may be computed using this [attachment:HC4.xls spreadsheet.] This spreadsheet also computes an extension of the HC4-based quasi-t recommended by Ng and Wilcox (2010) which is more robust to departures from assumptions underlying the computing of the variance of the regression estimates - specifically the assumption that the regression model is equally precise in both groups for all values of x (homoscedasticity). They call their estimate the HC4-based wild bootstrap quasi-t test which additionally accounts for sampling variability by sampling continually (with replacement) from the current sample to assess the variation in the t value (the 'bootstrapping' bit!) Details of how to compute this using the spreadsheet using complete cases are given [:FAQ/HChowto: here.]

Both the asymptotic HC4 estimator and its bootstrap version may also be computed using R 2.10 and later. For the former you will need to add-in the libraries 'foreign' and 'sandwich' which contain the macros you will need to evaluate the adjusted variance of the x by group interaction term if you have not installed these already. An example SPSS file containing the data used below is [attachment:modeg.sav given here.] Note: You will need to change the file location in the read.spss() command.

install.packages("sandwich")

The following syntax produces tval (t-value for the group by x interaction), its degrees of freedom (df) and its 2-sided p-value (pout).

library(foreign)
library(sandwich)
dat <- read.spss("C:\\Documents and Settings\\peterw\\Desktop\\My Documents\\My Documents2\\BARNEY MODERATION + R HC4 CODE\\test.sav")
attach(dat)
dat <- na.omit(dat)
vc <- vcovHC(fm,type="HC4")
tval <- fm$coeff[4]/sqrt(vc[4,4])
df <- length(dat$A)-4
pout <- 2*pt(-abs(tval),df)

The usual asymptotic results may be outputted using

vc <- vcov(fm)
tval <- fm$coeff[4]/sqrt(vc[4,4])
df <- length(dat$A)-4
pout <- 2*pt(-abs(tval),df)

The HC4 bootstrap version may be computed by installing the reg2ci macro. Details with a worked example are in the appendix of Ng and Wilcox.

References

Cribari-Neto, F. (2004). Asymptotic inference under heteroscedasticity of unknown form. Computational Statistics and Data Analysis 45 215-233.

Ng, M. and Wilcox, R.R. (2010). Comparing the regression slopes of independent groups. British Journal of Mathematical and Statistical Psychology 63 319-340.

None: FAQ/intslopes (last edited 2013-03-08 10:17:43 by localhost)