Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Sandra Lara Time Series #2

Objective Find the model for the time series and predict the next 3 points within 10% error. Introduction There are 35 points which were obtained with all positive input integers.
-1.8768,-1.4788,-3.7635,-8.1633,-10.9016,-8.7647,-3.4760,-1.1503,-6.3486,16.491,-23.046,-19.4817,-8.5773,-1.1681,-6.2798,-21.638,-34.373,-32.546,17.1791,-2.7665,-4.4544,-23.217,-43.4851,-46.755,-29.329,-7.1930,-2.1966,21.4327,-49.262,-60.6578,-44.541,-15.3701,-1.0182,-17.026,-51.0008 The graph obtained from these points is the following:

Some observations from the graph are the following: The function has a sinusoidal component. As time increases it increase amplitude

Thus, the hypothesis will be:

The prediction model has a sinusoidal component that can predict points within 10% error.

Methodology 1. Store two variables in the workspace in Matlab; data, and t. The data variable is the sample points, and the t variable is the interval of time that has all the points. 2. Load the Curving fitting tool in Matlab. 3. Set the x data as the t variable and the y data as the data variable.

4. Set the fitting function as the sum of sine

5. 6. 7. 8. 9. Results

a. This step is done to test the hypothesis b. This function is the only sinusoidal form that offers the tool of Matlab Change the number of terms in the sine. See in the Curve fitting tool graph how the fitting curve approximate with data vs. t graph. Get the equation Get the 35 first points from the equation. Compare those points with the data variable

Number of terms: 1

This graph shows that one term is not enough to fit the data vs. t graph Number of terms: 2

With 2 terms the graph is getting closer but does not fit the curve yet. However, it does show that this is the right path. Number of terms: 3

This gives us the right form of the graph. So the proposed equation is the following: General model Sin3: f(x) = a1*sin(b1*x+c1) + a2*sin(b2*x+c2) + a3*sin(b3*x+c3) Coefficients (with 95% confidence bounds): a1 = 1715 (-1.054e+005, 1.089e+005) b1 = 0.0005793 (-0.03562, 0.03678)

c1 = a2 = b2 = c2 = a3 = b3 = c3 =

3.142 (3.1, 3.185) 59.3 (35.07, 83.53) 1.008 (1.005, 1.012) -1.564 (-1.584, -1.543) 59.22 (35.01, 83.42) 0.9912 (0.9877, 0.9948) 1.582 (1.561, 1.602)

To have a better idea of how the curve behave in the long-term, the extended axis x and axis y shows its behavior until time 50. It gives a good prediction model because it still has a sinusoidal component in the long term, and the amplitude gets bigger.

Number of terms: 4

This gives us the right form of the graph. So the proposed equation is the following: General model Sin4: f(x) = a1*sin(b1*x+c1) + a2*sin(b2*x+c2) + a3*sin(b3*x+c3) + a4*sin(b4*x+c4) Coefficients (with 95% confidence bounds): a1 = 2757 (-5.262e+009, 5.262e+009) b1 = 0.04874 (-228.5, 228.6) c1 = 3.133 (-569.6, 575.9) a2 = 39.62 (28.7, 50.53) b2 = 1.013 (1.009, 1.017) c2 = -1.569 (-1.602, -1.536) a3 = 39.57 (28.67, 50.46) b3 = 0.987 (0.9831, 0.9909) c3 = 1.578 (1.545, 1.61) a4 = 2724 (-5.262e+009, 5.262e+009) b4 = 0.04897 (-229.5, 229.6) c4 = -0.009123 (-581.7, 581.7) To have a better idea of how the curve behave in the long-term, the extended axis x and axis y shows its behavior until time 50. It gives a good prediction model because it still has a sinusoidal component in the long term, and the amplitude gets bigger. However, the amplitude does not increase as much as it does with three terms.

Number of terms: 5

This gives us the right form of the graph. So the proposed equation is the following: General model Sin5: f(x) = a1*sin(b1*x+c1) + a2*sin(b2*x+c2) + a3*sin(b3*x+c3) + a4*sin(b4*x+c4) + a5*sin(b5*x+c5) Coefficients (with 95% confidence bounds): a1 = 588.7 (-6.052e+007, 6.052e+007) b1 = 0.05272 (-65.03, 65.13) c1 = 3.055 (-362.8, 368.9) a2 = 77.38 (-2069, 2224) b2 = 1.005 (0.8132, 1.197) c2 = -1.478 (-3.019, 0.06308) a3 = 1.143 (-46.86, 49.15) b3 = 0.9373 (-0.1098, 1.984) c3 = 0.2691 (-12.94, 13.48) a4 = 556.5 (-6.052e+007, 6.052e+007) b4 = 0.05397 (-66.44, 66.55) c4 = -0.09327 (-386.1, 385.9) a5 = 77 (-2077, 2231) b5 = 0.9914 (0.8071, 1.176) c5 = 1.686 (0.06613, 3.305)

To have a better idea of how the curve behave in the long-term, the extended axis x and axis y shows its behavior until time 50. It gives a good prediction model because it still has a sinusoidal component in the long term, and the amplitude gets bigger. However, the increase of the amplitude is very small.

To better determine how many sine terms gives the best fit, the table below shows information about the percentage error gotten between one point of the fit curve and one point from the data variable. # Sine terms 3 4 5 Max % error 40 24.79 58.96 Mean of % error 5.93 3.65 4.61 Min % error 0.3 0.01 0.08

The best fit will be the function of 4 sine terms because it has the smaller maximum percentage error, the smaller mean of percentage error and the smaller minimum percentage error.

Conclusion If we see the fitting curve of 3, 4 or 5 sinusoidal terms, they all fulfill the first observations; they increase in amplitude and have a sinusoidal form. However, none of them predict the 35 points within an error of 10%. The best fit obtained was the one with 4 sine terms, but still it gave a percentage error of %24.79. In the interval of 35-40, it might predict points within an interval of 10% of error, but the confidence level is not high due to past experiences. Therefore, it is necessary to get more data to improve the model or propose another hypothesis.

You might also like