Description Usage Arguments Note References See Also Examples
View source: R/TranstionMatrixMCFirstOrder.R
Transition Matrix for a 1st order Markov Chain
1 | TransitionMatrixMCFirstOrder(data, rc.names = NULL)
|
data |
precipitation occurrence data |
rc.names |
names of the states. |
Function rturn NULL
if data
contains
NA
s values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## # Not Run in the examples, uncomment to run the following lines
#library(RMAWGEN)
#data(trentino)
#
#year_min <- 1961
#year_max <- 1990
#
#period <- PRECIPITATION$year>=year_min & PRECIPITATION$year<=year_max
#station <- names(PRECIPITATION)[!(names(PRECIPITATION) %in% c("day","month","year"))]
#prec_mes <- PRECIPITATION[period,station]
#
### removing nonworking stations (e.g. time series with NA)
#accepted <- array(TRUE,length(names(prec_mes)))
#names(accepted) <- names(prec_mes)
#for (it in names(prec_mes)) {
# accepted[it] <- (length(which(!is.na(prec_mes[,it])))==length(prec_mes[,it]))
#}
#prec_mes <- prec_mes[,accepted]
### the dateset is reduced!!!
#prec_mes <- prec_mes[,1:2]
#valmin <- 0.5
#
#mt <- TransitionMatrixMCFirstOrder(data=prec_mes>valmin,rc.names=c("dry","wet"))
#
#CCGamma <- CCGamma(data=prec_mes,lag=0,tolerance=0.001,valmin=valmin,only.matrix=FALSE)
#
#i <- 1
#pd <- CCGamma$p0_v1[i]
#pdv <- mt[[i]]
#pdcalc <- pd*pdv["dry","dry"]+(1-pd)*pdv["wet","dry"]
#
#pw <- 1-pd
#pwcalc <- pd*pdv["dry","wet"]+(1-pd)*pdv["wet","wet"]
#
## verify
#pd-pdcalc
#pw-pwcalc
#
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.