/*=========================================================
File name: 5_k_independent_parameters.txt
Written by: Karl L. Wuensch, WuenschK@ECU.edu
Date: 28-August-2012.
===========================================================
To test the null hypothesis that k independent
parameters all have the same value, one can use
the chi-square test of heterogenity that is commonly
used in meta-analysis. See Fleiss's article on
meta-analysis for details.
----------------------------------------------------------
Fleiss, JL. The statistical basis of meta-analysis.
Statistical Methods in Medical Research, 1993, 2: 121-145.
----------------------------------------------------------
For this method, one needs k independent effect size estimates
(called Y) along with their variances (i.e., the square of their
standard errors). Each one of those estimates appears on a separate
row in the data file. The INPUT data are:
Group - consecutive integers starting with 1
Y - the measure of effect size
seY - the SE of Y
n - the sample size
Note - a string variable with a note.
In some cases, Y and se.Y may have to be computed
from other variables -- e.g., when testing the
heterogeneity of correlation coefficients, we compute
Y = the Fisher r-to-z transformed value of Pearson r.
Users can replace the data lines (between "CARDS" and "%MACRO ComputeQ") with their own data.
*Create macro for computing Q. */
%MACRO ComputeQ;
proc means noprint; var Group w wy;
output out=sums sum=x1 sumW sumWY max=S x2 x3;
data sums2; set sums;
Do Group=1 to S; sw=sumw; swy=sumWY; output; end; keep group S sw swy;
data Qgroup; merge xyzzy sums2; by Group;
Ybar=swy/sw; Qgroup=w*(Y-Ybar)**2;
proc means noprint; var Group Qgroup; output out=Q sum=nix1 Q max=S nix2;
data p; set Q;
df=S-1; p=1-probchi(Q,df);
proc print; var Q df p; ID;
%MEND ComputeQ;
* Test the heterogeneity of the INTERCEPTS in Table 2;
data xyzzy;
input Group Y seY n Note $35.;
varY=seY*seY; w=1/varY; wy=w*y;
CARDS;
1 142.011 10.664 22 Intercept, Burbank
2 148.053 11.142 47 Intercept, Lancaster
3 144.038 18.250 17 Intercept, Long Beach
4 130.445 10.228 56 Intercept, Glendora
;
%ComputeQ
title 'Comparing Intercepts, k Independent Groups'; run;
* Now test the heterogeneity of the SLOPES in Table 2;
data xyzzy;
input Group Y seY n Note $35.;
varY=seY*seY; w=1/varY; wy=w*y;
*GROUPS MUST BE CONSECUTIVE INTEGERS STARTING WITH 1;
CARDS;
1 4.179 1.105 22 Slope, Burbank
2 3.709 1.177 47 Slope, Lancaster
3 3.749 1.866 17 Slope, Long Beach
4 5.689 1.044 56 Slope, Glendora
;
%ComputeQ
title 'Comparing Slopes, k Independent Groups'; run;
/**** Test equivalence of correlations ***
In the case where one has k independent Pearson
correlations, Y = r-prime, the Fisher r-to-z transformed
correlation. The variance of Y = 1/(n-3).
We illustrate using correlations between FHEIGHT and FWEIGHT
in 4 different areas -- see Table 1 in the article. */
data xyzzy;
input Group r n;
Y = 0.5*log(abs((1+r)/(1-r)));
varY=1/(n-3);
w=1/varY;
wy=w*y;
*GROUPS MUST BE CONSECUTIVE INTEGERS STARTING WITH 1;
CARDS;
1 .628 24
2 .418 49
3 .438 19
4 .589 58
;
%ComputeQ
title 'Comparing Correlation Coefficients, k Independent Groups'; run;
/* Below, we run this code on the 2 independent correlations
* between FWT and MHT in Lancaster and in Glendora.
* The Q-value we obtain below should be equal to the square of
* the z-value (2.63183**2 = 6.9265) obtained earlier and the one-tailed p from Q
* should be identical to the two-tailed p (.00849) from z. */
data xyzzy;
input Group r n;
Y = 0.5*log(abs((1+r)/(1-r)));
varY=1/(n-3);
w=1/varY;
wy=w*y;
CARDS;
1 -.181 49
2 .330 58
;
%ComputeQ
title 'Comparing Correlation Coefficients, k=2 Independent Groups'; run;