0

I have a data-set which has 3 columns: date, amount, and a factor/cluster. For example:

date;amount;cluster_id
02.10.10;-13,86;3
04.10.10;-66,28;3
06.10.10;-14,99;3
25.10.10;-20,96;3
30.10.10;-408,99;3
31.01.11;-29,5;2
07.02.11;-652,85;3
19.09.11;-277,48;3
30.09.11;-6,18;3
03.10.11;-242,47;3
04.11.11;-299,77;3
20.02.12;-367,85;3
03.10.12;-4,99;4
13.09.13;-6,59;4
14.10.13;-1043,46;3
24.10.13;-373,99;3
24.10.13;-1321,91;3
18.12.13;-24,45;4
03.02.14;-66,87;3
30.08.14;-7,6;2
28.10.14;-115;3
13.12.14;-8,99;3
15.12.14;-352,44;3
19.12.14;115;3
08.07.15;-59;2

The following code:

ggplot(data, aes(x=date, y=amount, colour=factor(mycluster))) +
stat_smooth(method = "rlm", formula = y ~ x)

simply performs a rlm per group/factor. And looks like: Plot of Regression per cluster

How can I combine each separate regression model into one big (added) model in order to plot one "combined" model in an easy way e.g. without looping over all the rlm models manually.

Georg Heiler
  • 16,916
  • 36
  • 162
  • 292
  • [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – shekeine Sep 18 '15 at 10:21
  • 1
    `+ stat_smooth(method = "rlm", formula = y ~ x, aes(color = NULL))`? I'm afraid I don't understand the question. – Roland Sep 18 '15 at 10:22
  • I edited the question. Do you understand it now @Roland? – Georg Heiler Sep 18 '15 at 13:23
  • Well, does my comment answer your question? – Roland Sep 18 '15 at 13:25
  • not really you perform a rlm of ALL the data, but what I was rather up to is to perform a regression for EACH and than add each result into one big model. – Georg Heiler Sep 18 '15 at 13:48
  • @geoHeil what does your model look like? How do you combine three regressions into one model? – Heroka Sep 18 '15 at 14:14
  • As I am mostly interested in the forecast I compute each forecast and then add these amounts to one "final" amount. But I was hoping there is a better way to do it. – Georg Heiler Sep 18 '15 at 14:33
  • It is not clear at all what you want to do (not even if you want to plot or the numeric values). Voting to close. – Roland Sep 18 '15 at 16:23
  • ok - I close it however I only see the delete link and not the http://meta.stackexchange.com/questions/37752/how-do-i-close-my-own-question no longer relevant link. – Georg Heiler Sep 18 '15 at 16:28

0 Answers0