3

I have a random walk where by at certain times or conditions the increments follow one distribution, and then another distribution under different conditions - how can I model this random walk (states can have fixed or random probabilities)

For example, An economy has a bull and bear state with transition probabilties of staying the same as 80% and moving to the other state as 20%. The increments of a random walk of exchange rates follow a t-distribution in a bull state and a lognormal distribution in a bear state. How would you go about modelling the exchange rate random walk?

user40124
  • 847
  • 11
  • 19

2 Answers2

2

It sounds like a Hidden Markov model will do exactly what you want. A HMM assumes there is a discrete set of latent (unobservable) states which evolve according to a discrete time Markov process and generate observations which depend only on the current state. Thus a HMM is defined by a set of latent states $Q$, an initial distribution $p(q)$, a transition probability $p(q | q^\prime)$, and an emission probability $p(o|q)$.

Given a state hidden state sequence $q_1 q_2 \cdots q_T$ and observation seqeunce $o_1 o_2 \cdots o_T$ the joint probability can be calculated as

$$ p(q_1, \ldots, q_T, o_1, \ldots, o_T) = p(q_1)P(o_1|q_1)\prod_{t=2}^T p(q_t|q_{t-1})P(o_t|q_t). $$

For your particular example you would have 2 latent states (one for bear and the other for bull), with the emission distribution being t and normal respectively.

alto
  • 3,638
1

The increments of a random walk of exchange rates follow a t-distribution in a bull state and a lognormal distribution in a bear state

If by increment you mean the change from step to step, I don't understand how this can follow a lognormal distribution since these values will all be positive. The below R code uses a t distribution with 10 df and center=1 in the bull state and a normal distribution with mean=-1 and sd=3 in the bear state. Points are blue when in the bull state, and red in bear.

enter image description here

state<-1
duration<-1000
x<-matrix(nrow=duration, ncol=3)
x[1,]<-cbind(1,state,100)

for(t in 2:duration){
  transition<-rbinom(1,1,.2)

  if(transition==1){
    if(state==1){
      state=0
    }else{
      state=1
    }
  }
  if(state==0){
    x.new<-x[t-1,3]+rnorm(1,-1,2)
  }else{
    x.new<-x[t-1,3]+rt(1,10,1)
  }
  x[t,]<-cbind(t,state,x.new)

  plot(x[,1],x[,3],
       xlab="Time", ylab="Exchange Rate", 
       col=c("Red","Blue")[1+x[,2]])
}
Livid
  • 1,158
  • Apologies, it's the logged increments im using and they follow t and normal. Thanks for this, is there anything more theoretical I can read/look up about this type of problem? – user40124 Mar 27 '14 at 18:13
  • @user40124 Sorry this is not my field and I haven't looked at the literature. The above is just the simple way I thought of. One idea that may be good is to look at the historical data to decide what is bull/bear state and divide the increments into those two categories, then sample from these empirical distributions rather than using t and normal. – Livid Mar 27 '14 at 18:18
  • @user40124 you should edit the corrected information into your question to clarify your question (I'd suggest by adding a better framed question to the bottom to reflect this clarifying information). – Glen_b Mar 27 '14 at 23:38
  • I'm afraid i'll find it difficult to be clearer 'mathematically' as this is just some conceptual thinking i've been doing and asked the question to see if anyone could give a more direction and clarity as to what this type of process might be. I'll break my thinking down as much as I can; – user40124 Mar 28 '14 at 12:51
  • I am trying to model an exchange rate using a random walk, and after careful increment analysis have noticed that they are not only heteroscedastic over time, but follow different distributions. I want to experiment with the idea that perhaps the reason for the changes in distributions are due to a change in 'conditions' which could be modelled by a markov chain (the bull/bear situation being the most simplistic). In essence - modelling a random walk whose parameters change according to some other changing state. – user40124 Mar 28 '14 at 12:56
  • @user40124 The general form of the code provided above appears to be what you are asking for. Simply create more levels of nested if-then statements (If month===Jan Then transition prob=0.5; If month===Feb Then transition prob=.2; etc). Since it did not seem to satisfy you, it seems likely you are being somehow unclear in your description. – Livid Mar 28 '14 at 14:24
  • No, this is a great simulation code. I was just wondering if on top there is a theoretical name for this kind of process - I'd like to do some more general reading on the overall idea if possible. – user40124 Mar 28 '14 at 14:26
  • @user40124 In that case I would suggest the strategy of asking what name is used for the process described by the above code. I do not know myself, I would call it something like "random walk monte carlo simulation". – Livid Mar 28 '14 at 14:36
  • 1
    @Livid, your code simulates a Hidden Markov model, which is very well known. I describe HMMs in my answer. – alto Mar 28 '14 at 19:48
  • @alto Thank you, I was wondering if that was the case. It was not clear to me from your answer that they were the same due to a vocabulary deficit on my part. – Livid Mar 29 '14 at 12:09
  • @Livid, no problem. Unfortunately I think HMMs can be unnecessarily confusing for the uninitiated due to the way they are normally presented (which is largely an artifact of their prevalence in natural language processing). Introductions typically assume the emission distribution is discrete and the states are actually unobservable. Neither of these things are a requirement though. In fact, knowing the values of the states (as opposed to just the observations) greatly simplifies parameter estimation. – alto Mar 29 '14 at 17:26