[R] Prediction of response after glm on whitened data

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Jan 28 16:19:46 CET 2015

Dear Xochitl,

Have a look at gls() from the nlme package. It allows you to fit auto correlated errors.

gls(k ~ NPw, correlation = corAR1(form = ~ Time))

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: R-help [mailto:r-help-bounces op r-project.org] Namens Xochitl CORMON
Verzonden: woensdag 28 januari 2015 15:09
Aan: Rlist; Rlist
Onderwerp: [R] Prediction of response after glm on whitened data

Hi all,

Here is a description of my case. I am sorry if my question is also statistic related but it is difficult to disentangle. I will however try to make it only R applied.

My response is a growth constant "k" and my descriptor is prey biomass "NP" and time series is of 21 years.

I applied a gaussiam GLM (or LM) to this question. After the regression I tested the residuals for autocorrelation using acf(). Because autocorrelation was significant I decided to whiten my data using
{car}dwt() in order to obtain rho (an estimation of my correlation) and then applying the following to my data in order to remove autocorrelation:
kw_i = k_i - rho * k_i-1
NPw_i = NPw_i - rho * NPw_i-1
(method from Jonathan Taylor,

After that I fitted a model on this whitened data (kw_i ~ NPw_i), realised an F-test and obtained classical results such as deviance explained, pvalues and of course the intercept and coefficient of the last regression. However doing that and coming to prediction using
predict() I can only obtained predictions of deltaK (kw_i) in function of deltaNP (NPw_i) but I am actually interested in being able to predict k in function of NP...

Is there a solution to predict directly k and its associated variance using R without having to detail in the script all the mathematical process necessary to come back to something like k_i = mu + rho * k_i-1
+ beta(NPw_i - rho * NPw_i-1) + epsilon
with mu being the intercept, beta the regression coefficient and epsilon the error, ?

Thank you for your help,


Xochitl C.


<>< <>< <>< <><

Xochitl CORMON
+33 (0)3 21 99 56 84

Doctorante en écologie marine et science halieutique PhD student in marine ecology and fishery science

<>< <>< <>< <><

Centre Manche Mer du Nord
150 quai Gambetta
62200 Boulogne-sur-Mer

<>< <>< <>< <><

R-help op r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list