# Linear Regression: How can I satisfy all assumptions and rectify auto-correlation at the same time?

I am attempting to model sightings of a species at either the east or west of an island to see what environmental variables such as SST, Chl-a etc may be influencing an obvious migration pattern that they display between east and west. Species presence is recorded as a percentage calculated from the monthly total sightings at either the east or west location. It has to be done this way as the data was collected via citizen science so the number of animals isn't reliable.

Below is the lm() model for which I had to transform my data to ensure I met all assumptions.

transformed<-abs(dat$y - mean(dat$y))

mod1 <- lm(transformed~x, data=dat)

gvlma::gvlma(mod1)

mod1
ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS
USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM:
Level of Significance =  0.05

Call:
gvlma::gvlma(x = mod1)

Value p-value                Decision
Global Stat        2.241814  0.6914 Assumptions acceptable.
Skewness           0.009048  0.9242 Assumptions acceptable.
Kurtosis           0.253950  0.6143 Assumptions acceptable.
Link Function      1.120267  0.2899 Assumptions acceptable.
Heteroscedasticity 0.858549  0.3541 Assumptions acceptable.


I found that mod1 had an autocorrelation issue so I added a lag1 using the slide() function in the DataCombine package.

mod2<-lm(x~y,
data=dat)

library(DataCombine)
data <- data.frame(mp2017.dat, resid_mod1=mod2$residuals) data_1 <- slide(econ_data, Var="resid_mod1", NewVar = "lag1", slideBy = -1) data_2 <- na.omit(data_1) transformed<-abs(data_2$x - mean(data_2$x)) mod3 <- lm(transformed ~ y + lag1, data=data_2)  This rectified the autocorrelation issue but now the model does not satisfy all assumptions! gvlma::gvlma(mod3) ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM: Level of Significance = 0.05 Call: gvlma::gvlma(x = mod3) Value p-value Decision Global Stat 22.23782 1.797e-04 Assumptions NOT satisfied! Skewness 2.58773 1.077e-01 Assumptions acceptable. Kurtosis 0.05036 8.224e-01 Assumptions acceptable. Link Function 19.04845 1.274e-05 Assumptions NOT satisfied! Heteroscedasticity 0.55128 4.578e-01 Assumptions acceptable.  I have been going round in circles for days with this problem! Please, could someone tell me if I can use either model or, if not, how can I rectify one problem without causing another? • Just to make sure, you are dealing with time series data? Because if the data does not have a time dimension to it, you do not need to care about autocorrelation. Feb 3 '18 at 18:49 • Sorry, yes it does. 143 consecutive months @RichardHardy Feb 3 '18 at 19:06 • This may be a dead issue for the OP, but for anybody interested (1) a linear model for a percent response isn't obviously a good idea (2) a transformation$| y - \bar y|\$ on the face of it isn't necessary statistically or meaningful scientifically. Jun 19 '20 at 12:12
• Thanks for your comment @NickCox. For this particular study, the method worked well and the article was published earlier this year. Jul 19 '20 at 9:58
• Congrats on the publication! If you’re comfortable, could you please share the citation? @JoHarris
– Dave
Oct 24 at 12:16

I have now managed to overcome this issue using the following lm() which satisfies all assumptions.

    mod <- lm(abs(y-mean(y)) ~ x,
data=mp2017.dat, na.action=na.exclude)


I checked autocorrelation using Durbin–Watson test using

    lmtest::dwtest(mod)


The output was very close to 2. Field (2012) Discovering Statistics Using R states that as long as the result is between 1.5 and 2.5 it is acceptable.

• This is a strange model because it posits that various functions of all the responses vary with x. Moreover, it imposes a dependency among the responses, explicitly violating the assumptions of lm How do you propose to interpret it??
– whuber
Oct 24 at 16:04
• @whuber the interpretation is available here - doi.org/10.1002/aqc.3350 Oct 25 at 13:26