Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Hampel_Filter_R.R 667 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  1. install.packages("pracma")
  2. library(pracma)
  3. set.seed(33)
  4. # Generar los datos
  5. x <- numeric(1024)
  6. z <- rnorm(1024)
  7. x[1] <- z[1]
  8. for (i in 2:1024) {
  9. x[i] <- 0.4*x[i-1] + 0.8*x[i-1]*z[i-1] + z[i]
  10. }
  11. # Aplicar el Filtro de Hampel
  12. omad <- hampel(x, k=20)
  13. # Indice de los atípicos detectados:
  14. omad$ind
  15. # Gráfico detectando atípicos
  16. plot(1:1024, x, type="l")
  17. points(omad$ind, x[omad$ind], pch=21, col="darkred")
  18. # Nueva serie sin atípicos
  19. x_new=omad$y
  20. # Ambas series
  21. plot(1:1024, x, type="l",col="red",xlim=c(0, 1050), ylim=c(-60,70))
  22. par(new=TRUE)
  23. plot(1:1024, x_new, type="l",col="blue",xlim=c(0, 1050), ylim=c(-60,70),axes= FALSE, xlab='', ylab='' )
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...