melnikovmaxim

R_L12

Jan 2nd, 2020
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.90 KB | None | 0 0
  1. /*
  2. Выведите на один график исходный временной ряд и сглаженный временной ряд.
  3. На практике для выделения тренда часто применяется параметр α = 0.2. Подбирая нужные параметры
  4. α,β,γ можно добиться желаемого сглаживания.
  5. Проведите простое экспоненциальное сглаживание ряда rainseries с использованием функции
  6. HoltWinters() для разных значений параметр α (0,9; 0,8; 0,6). Выведите графики.
  7.  
  8. link https://yadi.sk/d/528aAPrTfbOfsg
  9. */
  10.  
  11. kings <- scan("http://robjhyndman.com/tsdldata/misc/kings.dat",skip=3)
  12. kings
  13. kingstimeseries <- ts(kings)
  14. kingstimeseries
  15.  
  16.  
  17. births <- scan("http://robjhyndman.com/tsdldata/data/nybirths.dat")
  18. birthstimeseries <- ts(births, frequency=12, start=c(1946,1))
  19. birthstimeseries
  20. plot.ts(birthstimeseries)
  21.  
  22.  
  23. souvenir <- scan("http://robjhyndman.com/tsdldata/data/fancy.dat")
  24. souvenirtimeseries <- ts(souvenir, frequency=12, start=c(1987,1))
  25. souvenirtimeseries
  26. plot.ts(souvenirtimeseries)
  27.  
  28. logsouvenirtimeseries <- log(souvenirtimeseries)
  29. plot.ts(logsouvenirtimeseries)
  30. plot.ts(birthstimeseries)
  31. birthstimeseriescomponents <- decompose(birthstimeseries)
  32. birthstimeseriescomponents$seasonal
  33. plot(birthstimeseriescomponents)
  34. birthstimeseriescomponents <- decompose(birthstimeseries)
  35. birthstimeseriesseasonallyadjusted <- birthstimeseries-birthstimeseriescomponents$seasonal
  36. plot(birthstimeseriesseasonallyadjusted)
  37.  
  38. rain <- scan("http://robjhyndman.com/tsdldata/hurst/precip1.dat",skip=1)
  39. rainseries <- ts(rain,start=c(1813))
  40. plot.ts(rainseries)
  41.  
  42. rainseriesforecasts <- HoltWinters(rainseries, beta=FALSE, gamma=FALSE)
  43. rainseriesforecasts
  44. rainseriesforecasts$fitted
  45. plot(rainseriesforecasts$fitted)
Add Comment
Please, Sign In to add comment