# ANCOVA violation: homogeneity of regression slopes

I am attempting to run a 2x2x2 unbalanced factorial ANCOVA on sediment mercury (Hg) concentrations (continuous response variable), sediment moisture content (%; continuous covariate), and three categorical variables: state (TX, OK), spring (active, former), and bird nesting (yes, no). However, when I begin testing the ANCOVA assumptions, my data violate the homogeneity of regression slopes assumption for significant moisture content covariate * nesting categorical interaction, but not the covariate and the other categorical interactions (state, spring). How can I proceed? I read that a possible solution is converting the continuous scale of the covariate to a categorical variable (ie: levels of moisture content: low and high) and making it a subsequent independent categorical variable, and then use a factorial ANOVA to analyze the data. Is this the best option or is there a better approach? Thank you!

> datum=read.csv(file.choose())
ID    Sed_Hg State_text State Spring_text Spring Nesting_text Nesting  Moist_Cont
1 TLS001  0.00707   Texas     1      Active      1         Yes       1       59.3
2 TLS002  0.00247   Texas     1      Active      1         Yes       1       29.1
3 TLS003  0.00286   Texas     1      Active      1         Yes       1       25.2
4 TLS004  0.00679   Texas     1      Active      1         Yes       1       50.9
5 PLS001  0.02610   Texas     1      Active      1          No       2       51.0
6 PLS002  0.02480   Texas     1      Active      1          No       2       48.6
> State.nf=datum$State > State.nf=c("TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "OK", "OK", "OK", "OK", "OK", "OK", "OK", "OK", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX") > is.factor(State.nf) [1] FALSE > State.=factor(State.nf) > is.factor(State.) [1] TRUE > levels(State.) [1] "OK" "TX" > summary(State.) OK TX 8 26 > Spring.nf=datum$Spring
> Spring.nf=c("Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Active", "Former", "Former", "Former", "Former", "Former", "Former", "Former", "Former", "Former", "Former")
> is.factor(Spring.nf)
[1] FALSE
> Spring.=factor(Spring.nf)
> is.factor(Spring.)
[1] TRUE
> levels(Spring.)
[1] "Active" "Former"
> summary(Spring.)
Active Former
24     10
> Nesting.nf=datum$Nesting > Nesting.nf=c("Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No", "Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No", "No", "No", "No", "No", "No", "No") > is.factor(Nesting.nf) [1] FALSE > Nesting.=factor(Nesting.nf) > is.factor(Nesting.) [1] TRUE > levels(Nesting.) [1] "No" "Yes" > summary(Nesting.) No Yes 18 16 > reg=aov(Sed_Hg~Moist_Cont + State. + Spring. + Nesting. + Moist_Cont*State. + Moist_Cont*Spring. + Moist_Cont*Nesting. + State.*Spring. + State.*Nesting. + Spring.*Nesting., data=datum) > par(mfrow=c(3,2)) > plot(reg, which=1:2) > plot(reg, which=3:4) > plot(reg, which=5:6) > #Test the Homogeneity of Regression Slopes Assumption: To see if the covariate significantly interacts with the categorical independent variable, run an ANCOVA model including both the independent variable and covariate*independent variable interaction term. If the interaction term is significant, ANCOVA should not be performed. > Sed_Hg=datum$Sed_Hg
> Moist_Cont=datum\$Moist_Cont
> hofrs1=aov(Sed_Hg~Moist_Cont+State.+Moist_Cont*State.)
> summary(hofrs1)
Df    Sum Sq   Mean Sq F value  Pr(>F)
Moist_Cont         1 0.0014980 0.0014980  63.142 7.2e-09 ***
State.             1 0.0000044 0.0000044   0.187   0.668
Moist_Cont:State.  1 0.0000141 0.0000141   0.593   0.447
Residuals         30 0.0007118 0.0000237
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> #Interaction (Moist_Cont:State.) = not significant… no evidence to reject null hypothesis that the gradients between those relationships do not differ at different levels of the factor.
> #Reject null hypothesis that the State has no effect on the Moist_Cont

> hofrs2=aov(Sed_Hg~Moist_Cont+Spring.+Moist_Cont*Spring.)
> summary(hofrs2)
Df    Sum Sq   Mean Sq F value   Pr(>F)
Moist_Cont          1 0.0014980 0.0014980  61.799 8.99e-09 ***
Spring.             1 0.0000026 0.0000026   0.107    0.746
Moist_Cont:Spring.  1 0.0000004 0.0000004   0.019    0.893
Residuals          30 0.0007272 0.0000242
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> #Interaction (Moist_Cont:Spring.) = not significant… no evidence to reject null hypothesis that the gradients between those relationships do not differ at different levels of the factor.
> #Reject null hypothesis that the Spring has no effect on the Moist_Cont

> hofrs3=aov(Sed_Hg~Moist_Cont+Nesting.+Moist_Cont*Nesting.)
> summary(hofrs3)
Df    Sum Sq   Mean Sq F value   Pr(>F)
Moist_Cont           1 0.0014980 0.0014980  148.00 3.96e-13 ***
Nesting.             1 0.0002014 0.0002014   19.90 0.000106 ***
Moist_Cont:Nesting.  1 0.0002252 0.0002252   22.25 5.18e-05 ***
Residuals           30 0.0003037 0.0000101
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> #Interaction (Moist_Cont:Nesting.) = significant… evidence to fail to reject null hypothesis that the gradients between those relationships may differ at different levels of the factor.
> #Fail to reject null hypothesis that the Nesting has no effect on the Moist_Cont