8.4 - Equal Slopes Model - SAS

Equal Slopes Model

Using our Salary example using the data in the table below, we can run through the steps for the ANCOVA.

Females Males
Salary years Salary years
80 5 78 3
50 3 43 1
30 2 103 5
20 1 48 2
60 4 80 4
  1. Step 1: Are all regression slopes = 0

    A simple linear regression can be run for each treatment group, Males and Females.

    Note! To perform regression analysis on each gender group in Minitab, we will have to sub-divide the salary data manually and save them separately. See the next page for Minitab example

    Running these procedures using statistical software we get the following:

    Males

    Use the following SAS code (Equal Sas Code 01)

    data equal_slopes;
    input gender $ salary years;
    datalines;
    m 78 3
    m 43 1
    m 103 5
    m 48 2
    m 80 4
    f 80 5
    f 50 3
    f 30 2
    f 20 1
    f 60 4
    ;
    proc reg data=equal_slopes;
    where gender='m';
    model salary=years;
    title 'Males';
    run; quit;

    And here is the output that you get:

    The REG Procedure
    Mode1:: MODEL1
    Dependent Variable: salary

    Number of Observations Read 5
    Number of Observations Used 5

    Analysis of Variance

    Source DF Sum of Squares Mean Square F Value Pr > F
    Model 1 2310.40000 2310.40000 44.78 0.0068
    Error 3 154.80000 51.60000    
    Corrected Total 4 2465.20000      

    Females

    Use the following SAS code (Equal Sas Code 02)

    data equal_slopes;
    input gender $ salary years;
    datalines;
    m 78 3
    m 43 1
    m 103 5
    m 48 2
    m 80 4
    f 80 5
    f 50 3
    f 30 2
    f 20 1
    f 60 4
    ;
    proc reg data=equal_slopes;
    where gender='f';
    model salary=years;
    title 'Females';
    run; quit;

    And here is the output for this run:

    The REG Procedure
    Mode1:: MODEL1
    Dependent Variable: salary

    Number of Observations Read 5
    Number of Observations Used 5

    Analysis of Variance

    Source DF Sum of Squares Mean Square F Value Pr > F
    Model 1 2250.00000 2250.00000 225.00 0.0006
    Error 3 30.00000 10.00000    
    Corrected Total 4 2280.00000      

    In both cases, the simple linear regressions are significant, so the slopes are not = 0.

  2. Step 2: Are the slopes equal?

    We can test for this using our statistical software.

    In SAS we now use proc mixed and include the covariate in the model (Equal Sas Code 03).

    We will also include a ‘treatment × covariate’ interaction term and the significance of this term answers our question. If the slopes differ significantly among treatment levels, the interaction p-value will be < 0.05.

    data equal_slopes;
    input gender $ salary years;
    datalines;
    m 78 3
    m 43 1
    m 103 5
    m 48 2
    m 80 4
    f 80 5
    f 50 3
    f 30 2
    f 20 1
    f 60 4
    ;
    proc mixed data=equal_slopes;
    class gender;
    model salary = gender years gender*years;
    run;
    
    Note! In SAS, we specify the treatment in the class statement, indicating that these are categorical levels. By NOT including the covariate in the class statement, it will be treated as a continuous variable for regression in the model statement.

    The Mixed Procedure
     Type 3 Tests of Fixed Effects

    Effect Num DF Den DF F Value Pr > F
    years 1 6 148.06 <.0001
    gender 1 6 7.01 0.0381
    years*gender 1 6 0.01 0.9384
     

    So here we see that the slopes are equal and in a plot of the regressions, we see that the lines are parallel.

    plot
  3. Step 3: Fit an Equal Slopes Model

    We can now proceed to fit an Equal Slopes model by removing the interaction term. Again, we will use our statistical software SAS (Equal Sas Code 04).

    data equal_slopes;
    input gender $ salary years;
    datalines;
    m 78 3
    m 43 1
    m 103 5
    m 48 2
    m 80 4
    f 80 5
    f 50 3
    f 30 2
    f 20 1
    f 60 4
    ;
    proc mixed data=equal_slopes;
    class gender;
    model salary = gender years;
    lsmeans gender / pdiff adjust=tukey;
          /* Tukey unnecessary with only two treatment levels */
    title 'Equal Slopes Model';
    run;
    
     

    and obtain the following final results:

    The Mixed Procedure
     Type 3 Tests of Fixed Effects

    Effect Num DF Den DF F Value Pr > F
    years 1 7 172.55 <.0001
    gender 1 7 47.46 0.0002

    Least Squares Means

    Effect gender Estimate Standard Error DF t Value Pr > |t|
    gender f 48.0000 2.2991 7 20.88 <.0001
    gender m 70.4000 2.2991 7 30.62 <.0001
    Note! In SAS, the model statement automatically creates an intercept, and so the ANCOVA model is technically over-parameterized. To get the slopes and intercepts for the covariate directly, we have to re-parameterize the model. This entails suppressing the intercept (noint), and then specifying that we want the solutions, (solution), to the model:

    Here is what the SAS code looks like for this (Equal Sas Code 05):

    ata equal_slopes;
    input gender $ salary years;
    datalines;
    m 78 3
    m 43 1
    m 103 5
    m 48 2
    m 80 4
    f 80 5
    f 50 3
    f 30 2
    f 20 1
    f 60 4
    ;
    proc mixed data=equal_slopes;
    class gender;
    model salary = gender years / noint solution;
    ods select SolutionF;
    title 'Equal Slopes Model';
    run;

    Here is the output:

    Solution for Fixed Effects
    Effect gender Estimate Standard Error DF t Value Pr > |t|
    gender f 2.7000 4.1447 7 0.65 0.5356
    gender m 25.1000 4.1447 7 6.06 0.0005
    years   15.1000 1.1495 7 13.14 <.0001

    In the first section of the output above is reported a separate intercept for each gender, the ‘Estimate’ value for each gender, and a common slope for both genders, labeled ‘Years’.

    Thus, the estimated regression equation for Females is y-hat= 2.7 + 15.1(Years), and for males it is y-hat = 25.1 + 15.1(Years)

    To this point in this analysis, we can see that 'gender' is now significant. By removing the impact of the covariate, we went from

    Type 3 Tests of Fixed Effects
    Effect Num DF Den DF F Value Pr > F
    gender 1 8 2.11 0.1840

    (without covariate consideration)

    to

    gender 1 7 47.46 0.0002

    (adjusting for the covariate)