简体   繁体   中英

Markov chain transition matrix from vector of probabilities

The complete data.frame overview:

'data.frame':   29 obs. of  3 variables:
$ FirmDatum : Date, format: "1982-12-31" "1983-03-31" "1983-06-30" ...
$ fittedSurv: num  0.884 0.839 0.779 0.746 0.817 ...
$ Rating    : chr  "Aa" "Aaa" "B" "Bb" ...

The column fittedSurv contains probabilities and the column Rating corresponds to the probability ( fittedSurv ) at that point in time.

For Markov chain transition matrix I need additional columns. Just purely resampling the single column (vector) of probabilities would not do alone.

What would be the most efficient way as far as inference is concerned?
Possible indication as to the correct R package would be sufficient - an example would be a bonus.

@Jonathan. It might well be. I suspect however that the probabilities changing over time could be bootstrapped or the vector of probabilities re-sampled so that meaningful columns of probabilities would be created. Something like:

A <- data.frame(X=FrameTs$Rating)
B <- data.frame(replicate(20, sample(as.character(A$X), size=100, replace = TRUE)))

The possible solution (which I don't trust) is:

A <- data.frame(X=FrameTs$Rating)
w <- FrameTs$fittedSurv/sum(FrameTs$fittedSurv)
B <- data.frame(replicate(10, sample(as.character(A$X), size=10, replace = TRUE, prob=w)))

which produces equally weighted matrix given the probabilities:

   X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
1   A  A  A  A  A  A  B  A  B   B
2   B  A  A  A  A  A  A  A  A   A
3   A  A  A  B  C  A  A  B  B   A
4   A  A  A  A  A  A  A  A  A   A
5   B  A  A  A  B  A  A  A  A   B
6   A  A  B  B  B  A  A  B  A   A
......and so on...

Of course the matrix B size can be extended via replicate(1000, sample(...

Based on this matrix of "probabilities" (ratings) its possible to get Markov transition matrix. (package msm etc). The output figures seems to be intuitive and correct but I don't trust this this approach

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM