Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a plotted my forecasted and real data in one graph, but I can't figure out how to plot the standard deviation on the same graph. The following is the code I have used:

d5 = FinancialData["IBM", {{1995, 1, 28}, {1999, 6, 28}}, "Value"];     

model = ARModel[{0.005250931478811768`}, 0.0004221114709120837`];

Inverse[InformationMatrix[d5, model]];

Sqrt[Diagonal[%]/n];

BestLinearPredictor[d5, model, 5, Exact -> False][[1]];

forecast = IntegratedPredictor[d5, {1, 1}, 12 , % + μ]

Because my 5-day forecast was plotted like a small dot next to the real data points, I have shortened the data and plotted my forecast again below;

shortdata = FinancialData["IBM", {{1999, 4, 28}, {1999, 6, 28}}, "Value"];

forecastgraph = ListLinePlot[{Take[shortdata, -43], Transpose[{Range[44, 48], forecast}]}, 
  PlotStyle -> {{Thin}, {Dashing[{0.01}], Red,Thick}},
  AxesLabel -> {"t",\\!\(TraditionalForm\`\*"\"\<\!\(\*SubscriptBox[\(x\),\(t\)]\)\>\""\)}];

Here is my 5 day forcast graph

realdata = FinancialData["IBM", {{1999, 4, 28}, {1999, 7, 3}}, "Value"];

real = ListLinePlot[realdata, PlotStyle -> {Thick, Green}];

stdevgraph = Show[real, forecastgraph]

Graph of my forecast and real occured data

I would like to add the standard deviation to stdevgraph. How can I do that?

share|improve this question
3  
I think you're using any package which is not originally installed with Mathematica. Several of your commands are not recognized by Mathematica 9.0. –  Rod Apr 20 '13 at 22:01
    
Sorry, forgot to mention. I am using Mathematica 8 with Time Series Package installed. –  Erkam Kivrak Apr 20 '13 at 22:03
    
I'm trying to understand what you've done... could you please explain where did your ARModel parameters ({0.005250931478811768}, 0.0004221114709120837) come from? I think they are like mean and standard deviation of IBM daily returns, right? By the way, did you try to use TimeSeries[model, 5] to generate your 5-day forecast? –  Rod Apr 21 '13 at 7:51
    
I have detrended the data first, then I have used the Hannan Rissanen Estimator to fit the model and estimate the coefficients of the model. I am using the TimeSeries package for mathematcia 8. I have not used TimeSeries[model, 5] because I have used the BestLinearPredictor to predict the 5 day and also used the IntergratedPredictor to transform back the detrended data to their actual values. –  Erkam Kivrak Apr 21 '13 at 8:32
    
So what about the standard deviation you're trying to plot? Which specifc model you're using? The plot itself is the easiest part, but I haven't seen any standard deviation data to be plotted... –  Rod Apr 21 '13 at 8:39
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.