/* Example of F-test for _some_ coefficients */ /* Example using body fat data from Chapter 7 */ data body; input triceps thigh midarm bodyfat; cards; 19.5 43.1 29.1 11.9 24.7 49.8 28.2 22.8 30.7 51.9 37.0 18.7 29.8 54.3 31.1 20.1 19.1 42.2 30.9 12.9 25.6 53.9 23.7 21.7 31.4 58.5 27.6 27.1 27.9 52.1 30.6 25.4 22.1 49.9 23.2 21.3 25.5 53.5 24.8 19.3 31.1 56.6 30.0 25.4 30.4 56.7 28.3 27.2 18.7 46.5 23.0 11.7 19.7 44.2 28.6 17.8 14.6 42.7 21.3 12.8 29.5 54.4 30.1 23.9 27.7 55.3 25.7 22.6 30.2 58.6 24.6 25.4 22.7 48.2 27.1 14.8 25.2 51.0 27.5 21.1 ; run; /* Testing about sets of coefficients in PROC REG: */ PROC REG DATA = body; MODEL bodyfat = triceps thigh midarm; TEST thigh=0, midarm=0; /* This tests whether beta_2=beta_3=0, given that X1 is in the model */ RUN; /* Calculating coefficients of partial determination */ PROC REG DATA = body; MODEL bodyfat = triceps thigh / pcorr2; MODEL bodyfat = triceps thigh midarm / pcorr2; RUN; /* **** Investigating multicollinearity ******* */ /* Noting correlation among predictors */ PROC CORR DATA = body; VAR triceps thigh midarm; RUN; /* SAS will calculate the Variance Inflation Factors */ /* for each predictor if we include the VIF option */ /* in the MODEL statement. */ PROC REG DATA = body; MODEL bodyfat = triceps thigh midarm / VIF; RUN; /* *************** Interaction models ************ */ /* Testing whether the interaction terms are significant */ /* in the bodyfat example */ /* We will center the X variables: */ /* in order to match the book's analysis */ PROC MEANS DATA = body; VAR triceps thigh midarm; OUTPUT OUT = bodystats MEAN(triceps) = meantriceps MEAN(thigh) = meanthigh MEAN(midarm) = meanmidarm; run; DATA body2; IF _N_=1 THEN SET bodystats; SET body; ctriceps = triceps - meantriceps; cthigh = thigh - meanthigh; cmidarm = midarm - meanmidarm; run; /* First we create the interaction (cross-product) terms */ DATA body2; SET body2; ctriceps_cthigh = ctriceps*cthigh; ctriceps_cmidarm = ctriceps*cmidarm; cthigh_cmidarm = cthigh*cmidarm; run; /* Now we fit the model with all pairwise interactions */ PROC REG DATA = body2; MODEL bodyfat = ctriceps cthigh cmidarm ctriceps_cthigh ctriceps_cmidarm cthigh_cmidarm; TEST ctriceps_cthigh=0, ctriceps_cmidarm=0, cthigh_cmidarm=0; /* This tests whether beta_4=beta_5=beta_6=0, given that X1,X2,X3 are in the model */ RUN;