Message Boards Message Boards

Specify a variable as random error?

Posted 6 years ago

I've been attempting to solve a difference equation similar to an ARMA process. The equation however contains a random disturbance / stochastic term that I'm not sure how to input. I've tried $ \epsilon$ and I've tried $ e[t] $. Anybody know of how to add this correctly?

I've managed to get the proper solutions using RSolveValue; but now just need to correctly specify the error term.

Thanks

POSTED BY: A.I. S
12 Replies

Ali,

Glad you got it working again by reopening MMA.

As to the other part of your post, I'm not sure I understand what you are trying to do. You say

But as far as then providing an functional solution to the associated recurrence equation, I haven't had any luck

I thought you were looking for a way to enter the recurrence equation as an ARMAProcess and compute stationarity (with WeakStationarity[]) and invertibility with (TimeSeriesInvertibility[]) as shown in the examples.

Can you show a reference or, better yet, give a simple example and the form of the solution you are trying to obtain?

Regards,

Neil

POSTED BY: Neil Singer
Posted 6 years ago

In case you need any further examples I bring up an explicit problem. I included one above in a reply btw hopefully that adds some clarification. For clarify though here's the explicit form of the exact question I'm seeking an answer to:

I) Solve the following initial-value difference equations. Plot the time path of Yt and discuss the convergence or divergence of the solutions as $ t \rightarrow \infty $

$$ y_t = 1.6 + 0.75 y_{t-1} + \epsilon_t $$ $$y_0 = 2 $$

At first it was an issue with the error term. But now that you showed me the syntax for that -- all that would remain is how to specify the initial conditions correctly. What's odd is I'm not getting an error and your code is directly from the references so I can't see it being incorrect. But the solution it gives me when I use your code snippet on these problems with the initial conditions specified I get an unfamiliar answer as you see above.

Hope this clears some things up.

Thanks again.

POSTED BY: A.I. S
Posted 6 years ago

Hi Neil,

Sorry to flood the thread - just hoping to minimize your efforts and time spent at my expense. I was completely wrong in my previous response to which I say your code was outputting a 'wrong' solution I was looking for. It's indeed exactly correct and just specified in an unfamiliar way. It required some simple clerical simplifications and the solutions maintain the same solution.

$ \left\{\left\{a(n)\to (-3)^n 2^{1-2 n}\right\}\right\} $ is actually identical to $ a(n) \rightarrow (2)(-0.75)^t $ after simplification. My apologies for that.

And again thanks so much for the help.

Best, Ali

POSTED BY: A.I. S
Posted 6 years ago

So after trying the code again for some odd reason it's now outputting an error:

Inputting RSolve[{a[n + 1] - 2 a[n] + eps[n] == 1, a[0] == 1}, a[n], n]

Out: RSolve::deqn: Equation or list of equations expected instead of False in the first argument {-2 a[n]+a[1+n]+eps[n]==1,False}.

I've looked at the ARMA reference in the past and its the closest I've gotten to getting my actual specification correctly. Primarily since it includes the stochastic error term correctly. But as far as then providing an functional solution to the associated recurrence equation, I haven't had any luck. Clearly I think there is a function required to transform an ARMA process to it's associated functional form. If I could do that then I imagine I could bracket everything in RSolve[] and find the functional solution.

That aside -- the original code you gave me seemed to work I'm really struggling to see what went wrong.

Best, Ali

POSTED BY: A.I. S
Posted 6 years ago

Sorry! After closing Mathematica and re-opening it seems it works again.

POSTED BY: A.I. S

Ali,

Have you looked at the function ARMAProcess? The documentation is here. I think this is what you want. They show how to compute stationarity, etc.

Regards,

Neil

POSTED BY: Neil Singer

Ali,

My previous post seems to have the "updating name" problem. I hope this helps -- Was this what you were asking?

Regards,

Neil

POSTED BY: Neil Singer
Posted 6 years ago

Hi Neil,

I'm so sorry I don't know why I wasn't getting notified to a response. Hopefully you're able to see my messages; but I appreciate your help it's still very much an inquiry, as I'm not able to do the calculation in Mathematica. Fortunately I've been using R with no problems. That being said I know once I get it in Mathematica there'll be some really nice functions.

From the example it seems eps is correct thanks for that. But I was really trying to avoid creating seeded random distributions; I was hoping for the explicit analytic solutions. So is there no direct way to transform an ARMA specification to an objective function, to then have solved?

For instance instead of specifying the recurrence equation:

$$ y_t = \alpha_0 + \beta_1 y_{t-1} + \beta_2 y_{t-2} + \epsilon_t + \epsilon_{t-1} $$

Then having it solve it as done above, is there a way to instead specify that equation as an: ARMA{2, 1}? Aside from that obviously inputting the coefficients as well. The use to this would be to test for stationarity, invertibility of the time series.

Thanks again

POSTED BY: A.I. S
Posted 6 years ago

Ali,

I think what you need is something like this (I modified an example from the documentation)

RSolve[{a[n + 1] - 2 a[n] + eps[n] == 1, a[0] == 1}, a[n], n]

Which returns a[n] as a function of n and eps[n]. Your eps[n] is a random sequence. To simulate it you would need to generate points for your eps using something like RandomVariate[].

I am not sure you will obtain solutions for complicated equations and you may just have to numerically generate those solutions using the recurrence relationship like this:

In[20]:= RecurrenceTable[{a[n + 1] == 3 a[n], a[1] == 7}, a, {n, 1, 
  10}]

Out[20]= {7, 21, 63, 189, 567, 1701, 5103, 15309, 45927, 137781}

In[22]:= RecurrenceTable[{a[n + 1] == 
   3 a[n] + RandomVariate[NormalDistribution[1, 3]], 
  a[1] == 7}, a, {n, 1, 10}]

Out[22]= {7., 22.4549, 68.8196, 207.914, 625.196, 1877.04, 5632.58, \
16899.2, 50699., 152099.}
POSTED BY: Updating Name
Posted 6 years ago

I'm not sure what's going on here but you might have some insight on this:

Following you code above using RSolve. I used it to find the solution to virtually the same problems with different coefficients.

RSolve[{4 a[n] + 3 a[n - 1] == 0, a[0] == 2}, a[n], n]

The (latex) output Mathematica gives is:

$ \left\{\left\{a(n)\to (-3)^n 2^{1-2 n}\right\}\right\}$

I'm not sure what exactly is going on here because that isn't exactly a solution I can make any sense of. The correct solution to this equation given initial conditions would be:

$ y^h_t = 2(-0.75)^t $ representing the homogenous portion of the solution. At least this is my understanding and am fairly confident is the correct solution. Oddly I get this solution when inputting the following text into Mathematica and ignoring the initial condition parameter:

RSolve[4 a[n] + 3 a[n - 1] == 0, a[n], n]

Gives me: $ \left\{\left\{a(n)\to c_1 \left(-\frac{3}{4}\right)^{n-1}\right\}\right\} $

Following setting up the initials I would get to my answer. Not sure you're able to see where my misunderstanding may lie, but I appreciate the time.

Best, Ali

POSTED BY: A.I. S
Posted 6 years ago

Thanks for the suggestion Neil,

I apologize for any possible confusions. I’ll post an example. The nature of the question is to solve difference equations, in time, with a stochastic disturbance. In other words just solving for the particular solutions and all homogenous solutions to an SDE (stochastic difference equation). I believe on Mathematica this is referenced instead as a recurrence equation. As an example: Suppose an AR(1):

$$ \alpha_o + \beta_1 X_{t-1} + \epsilon_t = y_t $$

The solution to this would follow the null solution and the particular solutions. Regardless of which however I have to have a way to set the random parameter $ \epsilon_t $.

This is of course for pure conceptual and analytical understanding of the solutions behind ARMA process'. As far as I know, I'm not sure to it's direct application. But functionally an ARMA or AR process has a solution. I'm looking for how to derive to that solution but with an error added.

As an added example of what I managed to get correct. I got a solution to a difference equation specified as follows:

$$ RSolveValue[ y[t] == \alpha + \beta_1 x[t-1] + \beta_2 x[t-2], y[t], t] $$

This actually got me very close, if not exactly what I was looking for. But I had to truncate the equation so as to not contain the random disturbance term $ \epsilon_t $

Again any help is greatly appreciated. Thanks, Ali

POSTED BY: A.I. S

Ali,

I do not understand from your post what you want to do. I am guessing from your post that you have either a dynamic system with a random input or a random process. You really need to post some example code for anyone to help because it is not clear what "solve" means in your context. For example, are you trying to simulate the process or are you trying to obtain statistics (ie correlations or covariances) or are you trying to use ARMAProcess[] or a related function to create a model? If you post an example, people here can be more helpful.

Regards,

Neil

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract