/*========================================================= File name: 4_two_independent_regression_coefficients.txt Written by: Karl L. Wuensch, WuenschK@ECU.edu Date: 17-May-2016. =========================================================== * Use data from Table 2. Compare regression coefficients for Lancaster and Glendora. * "K&K" uses data from Kleinbaum & Kupper , Table 8.1. * m is the number of predictors in the regression model. * Assign to "Pool" value 1 if you wish the error terms and degrees of freedom to be pooled between groups; * Assign value 0 if you wish them not to be pooled (df with Satterthwaite adjustment); * Users can replace the data lines (between CARDS and PROC) with their own data. */ data b1Ib2; input Pool m b1 b2 se1 se2 MSE1 MSE2 n1 n2 alpha Note $20.; bdiff=(b1-b2); df1 = n1-m-1; df2 = n2-m-1; If pool = 0 then goto Satter; df=df1+df2; MSE=((n1-m-1)*MSE1+(n2-m-1)*MSE2)/df; sediff = SQRT(MSE*(se1**2/MSE1+se2**2/MSE2)); GOTO T; Satter: v1=se1*se1; v2=se2*se2; df=(v1+v2)**2/(v1**2/df1+v2**2/df2); sediff=SQRT(v1+v2); T: t=bdiff/sediff; tneg=0-abs(t); p=2*probt(tneg,df); cump=1-alpha/2; CV=TINV(cump,df); CI_Lower=bdiff-CV*sediff; CI_Upper=bdiff+CV*sediff; CARDS; 1 1 148.053 130.445 11.142 10.228 457.956 407.826 49 58 .05 Int, Lan v Glen 0 1 148.053 130.445 11.142 10.228 457.956 407.826 49 58 .05 Int, Lan v Glen 1 1 3.709 5.689 1.177 1.044 457.956 407.826 49 58 .05 Slope, Lan v Glen 0 1 3.709 5.689 1.177 1.044 457.956 407.826 49 58 .05 Slope, Lan v Glen 1 1 0.9493 0.96135 0.116145 0.0913 91.457 71.897 29 40 .05 Slope, K&K 0 1 0.9493 0.96135 0.116145 0.0913 91.457 71.897 29 40 .05 Slope, K&K ; PROC print; var Pool b1 b2 bdiff sediff t df p Note; id; title 'Difference between two independent slopes or intercepts'; proc print; var Pool b1 b2 bdiff alpha CI_Lower CI_Upper Note; title 'CI for Difference between two independent slopes or intercepts'; run;