search for: sumt2

Displaying 3 results from an estimated 3 matches for "sumt2".

Did you mean: sum2
2009 Jul 08
0
typo in ts detrending implementation in spec.pgram?
...llo! I wonder if there is a typo in detrending code of spec.pgram in spectrum.R from stats package. One can see in the code https://svn.r-project.org/R/trunk/src/library/stats/R/spectrum.R . I am afraid there is a typo and the code should look like if (detrend) { t <- 1L:N - (N + 1)/2 sumt2 <- N * (N^2 - 1)/12 for (i in 1L:ncol(x)) x[, i] <- x[, i] - mean(x[, i]) - sum((x[, i]-mean(x[,i]) * t) * t/sumt2 } Note x[, i]-mean(x[,i]) instead of x[,i] only as in repository. Here is a quick reference http://en.wikipedia.org/wiki/Simple_linear_regression#Estimati...
2019 Feb 14
0
Proposed speedup of spec.pgram from spectrum.R
...if(is.tskernel(spans)) spans else kernel("modified.daniell", spans %/% 2) } if(!is.null(kernel) && !is.tskernel(kernel)) stop("must specify 'spans' or a valid kernel") if (detrend) { t <- 1L:N - (N + 1)/2 sumt2 <- N * (N^2 - 1)/12 for (i in 1L:ncol(x)) x[, i] <- x[, i] - mean(x[, i]) - sum(x[, i] * t) * t/sumt2 } else if (demean) { x <- sweep(x, 2, colMeans(x), check.margin=FALSE) } ## apply taper: x <- spec.taper(x, taper) ## to correct for tapering...
2009 Jul 09
2
How to Populate List
...! I wonder if there is a typo in detrending code of spec.pgram in spectrum.R from stats package. One can see in the code https://svn.r-project.org/R/trunk/src/library/stats/R/spectrum.R . I am afraid there is a typo and the code should look like if (detrend) {     t <- 1L:N - (N + 1)/2       sumt2 <- N * (N^2 - 1)/12       for (i in 1L:ncol(x))             x[, i] <- x[, i] - mean(x[, i]) - sum((x[, i]-mean(x[,i]) * t) * t/sumt2     } Note x[, i]-mean(x[,i]) instead of x[,i] only as in repository. Here is a quick reference http://en.wikipedia.org/wiki/Simple_linear_regression#Estimati...