At this point you haven't described the within-group heteroscedasticity structure in your model yet. Try weights=varPower()
as shown in the example in ?gls
. That gets rid of the heteroscedasticity in your case.
Compare:
m1 <- gls(salary ~ age*sex)
plot(m1)
m2 <- gls(salary ~ age*sex, weights=varPower())
plot(m2)
Also if you look in Chapter 5.2.1 (page 208) in Mixed Effects Models in S and S-Plus by Pinheiro and Bates 2000, there is a lot of information on the Variance Functions in nlme
. This answer may also be helpful: Regression modelling with unequal varianceRegression modelling with unequal variance .