Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

comparing two numerical variables in R

$
0
0

I have run the R function stl() function and use its generated residuals for grubbs test. The code is the following:

stl.res = stl(dataset, s.windows='periodic')
residuals = as.numeric(strl.res$time.series[, "remainder"])
grubbs.result = grubbs.test(residuals)

strsplit(grubbs.result$alternative,"")[[1]][3]
## [1] "38.4000349179783"

outlier = as.numeric(strsplit(grubbs.result$alternative,"")[[1]][3])
outlier
## [1] 38.40003492

which(residuals == outlier)
## integer(0)

My question is why the return value of which() is 0. Actually residuals[1920] = 38.4000349179783. So the call of which() should return a value of 1921, not 0. I guess this is a problem with precision. I have tried many ways, but not managed to solve it.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>