[Dplr-commits] r683 - branches/redfit/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 4 12:09:48 CEST 2013
Author: mvkorpel
Date: 2013-09-04 12:09:48 +0200 (Wed, 04 Sep 2013)
New Revision: 683
Modified:
branches/redfit/R/detrend.series.R
Log:
Use lm.fit() instead of lm().
Avoids codetools nag about possibly unused variable.
Modified: branches/redfit/R/detrend.series.R
===================================================================
--- branches/redfit/R/detrend.series.R 2013-09-04 09:21:05 UTC (rev 682)
+++ branches/redfit/R/detrend.series.R 2013-09-04 10:09:48 UTC (rev 683)
@@ -39,11 +39,14 @@
ModNegExp <- try(nec.func(y2), silent=TRUE)
if(class(ModNegExp)=="try-error") {
## Straight line via linear regression
- tm <- seq_along(y2)
- lm1 <- lm(y2 ~ tm)
- ModNegExp <- predict(lm1)
- if(coef(lm1)[2] > 0 && !pos.slope)
+ tm <- cbind(1, seq_along(y2))
+ lm1 <- lm.fit(tm, y2)
+ coefs <- lm1[["coefficients"]]
+ if (all(is.finite(coefs)) && (coefs[2] <= 0 || pos.slope)) {
+ ModNegExp <- drop(tm %*% coefs)
+ } else {
ModNegExp <- rep(mean(y2), length(y2))
+ }
}
resids$ModNegExp <- y2 / ModNegExp
do.mne <- TRUE
More information about the Dplr-commits
mailing list