r - HoltWinters on Panel Data -


I'm trying to run Holtvintrs process panel data to come up with sales forecasts for a list of companies I In the data frame, there are "company", "year" and "sale" fields. I'm interested in adding an extra column to this data frame that shows sales received using Holt Winters.

For the same company, exercise is trivial because I can still run HoltWinters I by looping Companies in this situation in their position I increase my position, but I am looking for a solution I am saved from the loop.

Any thoughts? can

HoltWinters to help file, it does not seem to vector So, I do not think you can escape the loop. The best I can do is make your loop beautiful with lapply (this can also be a small speed gain). Let's say you have different time series (or time series union):

  set.seed (0) a & lt; - ts (rnorm (10), start = c (2001, 5), freq = 12) b & lt; - ts (rnorm (10), start = c (2001, 5), freq = 12) c & lt; - ts (rnorm (10), start = c (2001, 5), freq = 12) d & lt; - ts (rnorm (10), start = c (2001, 5), freq = 12) e & lt; - ts (rnorm (10), start = c (2001, 5), freq = 12) f & lt; - TS (Ronorum (10), Beginning = C (2001, 5), Freak = 12) Individual. A & lt; - Tascism (A, B, C) Individual. Two & lt; - Team Federation (D, E, F) Panel & lt; - List (individual.one, individual.two) ans & lt; - lapply (panel, HoltWinters)  

yields:

  & gt; Anne Holt-Winters with exponential lubricating tendency and additive seasonal component. Call: fun (x = x [[LL]]) soft parameters: alpha: beta 0: 0 Gamma: 0 coefficients: [1] a -0.504 9 84 544 b -0.035336155 S 1 -lk0856l57l0 S2 - 0.35285 9 142 S3 0.002437573 S 4 2.5508 9 7 9 07 S5 .9 8,67,6 9, 568 S6 -0.5 9 6066 9 30 S7 -1.02855 9 65 9 S8 -0.187 9 23 9 05 S9 -0.14 9 28 9 171 S10 -0.168011617 S11 0.60645244 9 S12 -0.57,82,31,362 [2] The exponential smoothing and additive seasonal component with the Holt-Winters trend. Call: fun (x = x [[2L]]) soft parameters: alpha: beta 0: 0 Gamma: 0 coefficients: [1] a -0.3 9 575 9 55 B -0.04035375 S 1 0.7550503 9 s2 -0 .64553006 S3 1.06488778 s 4 -0.40487180 S5 1.74515472 S6 0.64324387 s7 -0.36380752 s8 -0.74481981 s9 -1.04726447 s10 -0.90172103 s11 -1.42433355 s12 1.32401148  

Where:

  & gt; Panel [[1]] ABC May 2001 1.262954285 0.7635935 -0.22426789 Jun 2001 -0.326233361 -0.7990092 0.37739565 July 2001 1.329799263 -1.1476570 0.13333636 August 2001 1.272429321 -0.2894616 0.80418951 September 2001 0.414641434 -0.2992151 -0.05710677 Oct 2001 -1.539 9 5042 -0.4115108 0.50360797 November 2001 -0.928567035 0.2522234 1.08576936 December 2001 -0.294720447 -0.8919211 -0.69095384 January 2002 -0.005767173 0.4356833 -1.2845 9935 February 2002 2.404653389 -1.2375384 0.04672617 [2] DEF May 2001 -0.2357066 1.7579031 0.26613736 June 2001 -0.4428883 0.5607461 -0.37670272 July 2001 -0.4333103 -0.4527840 2.44136463 Agst 2001 -06494716 -0.8320433 -0.79533912 September 2001 0.7267507 -1.1665705 -0.05487747 October 2001 1.1519118 -1.0655906 0.25014132 Nvanbr 200l 0.9921604 -1.5637821 0.61824329 Dec December 2001 -0.4295131 1.1565370 -0.17262350 January 2002 1.2383041 0.8320471 -2.22390027 February 2002 -0.2793463 -0.2273287 -1.26361438  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -