I have a question about hierarchical grouping of time-series in R. I currently have this matrix:
A B C F G H I
[1,] -33.697 8.610 42.31 17.465 24.84 14.210 10.632
[2,] -4.698 15.993 20.69 6.222 14.47 3.423 11.047
[3,] -37.458 9.687 47.14 14.659 32.49 12.759 19.726
[4,] -23.851 16.517 40.37 14.392 25.98 9.438 16.538
[5,] 3.329 15.629 12.30 3.449 8.85 2.635 6.215
[6,] -38.071 5.746 43.82 15.932 27.89 14.113 13.772
Just by inspection, I can figure out that:
- G = H + I
- C = F + G
- A = B - C
Is there a way that I can find these sum relationships (positive and negative) automatically on large time-series in R? I have tried using an lm() to figure out the relationships but that is too time consuming to do on every series. Not to mention many times there are collinearity problems.
Many Thanks!
structure(list(A = c(-33.6970557915047, -4.69841752527282, -37.457728596637,
-23.8508993089199, 3.32904924079776, -38.0712462896481), B = c(8.60984595282935,
15.9929901333526, 9.68719404516742, 16.5167794595473, 15.6285679822322,
5.74573907931335), C = c(42.306901744334, 20.6914076586254, 47.1449226418044,
40.3676787684672, 12.2995187414344, 43.8169853689615), F = c(17.4649945173878,
6.22195235290565, 14.6593122615013, 14.3921482057776, 3.44929573708214,
15.9315551938489), G = c(24.8419072269462, 14.4694553057197,
32.4856103803031, 25.9755305626895, 8.8502230043523, 27.8854301751126
), H = c(14.2098777298816, 3.42268325854093, 12.7592747195158,
9.43778987810947, 2.63517117220908, 14.1129822209477), I = c(10.6320294970647,
11.0467720471788, 19.7263356607873, 16.5377406845801, 6.21505183214322,
13.7724479541648)), .Names = c("A", "B", "C", "F", "G", "H",
"I"), row.names = c(NA, -6L), class = "data.frame")