# Curve fitting in R

I had 4 groups of data (in color 1 to 4) and one group is the data for one day, so I had 4 days of data. I was trying to fit a line which describes the pattern of theses lines (oscillating pattern) and do some prediction for the behavior on the fifth day. What I have in mind is lm(~poly(x,,)) or auto.arima(), which only needs one day of data. Is there any way to use all my data for fitting? What would be a more appropriate statistical model to use? Any help would be appreciated. Thanks.

Sophie • The daily data is collected at what intervals? Every five minutes? And you want to forecast all the next day, i.e. all the intervals for the next day? – mpiktas May 22 '15 at 6:28
• Yes, they are collected every 5 mins and I want to forecast all day the next day, so it would be 288 data points. – Sophie May 22 '15 at 7:38
• If you want to forecast whole day, you must realize that essentially you are trying to forecast one data point from 4 data points. Not a lot you can do in such situation. Smoothing the series for all days and averaging, might be your best bet. – mpiktas May 22 '15 at 8:42
• However if you are certain that your process follows some trend, i.e. the DGP is $y_t=g(t)+u_t$, where $g(t)$ is some function, then you have more than enough data to estimate $g(t)$. This then would be your forecast for the next day. – mpiktas May 22 '15 at 8:44
• What is u_t? An error term? And also how do I estimate g(t)? Should I do that based on the shape of the curves? In this situation, the curve looks like a variation fo this function:(sin(x)+cos(x))*e^x to me. – Sophie May 22 '15 at 9:49