Learn R Programming

MMLR (version 0.2.0)

Aver_soj_time: Calculating the average sojourn time in each state

Description

Calculating expectation of sojourn times in states for the observed time and for given initial state, using eigenvalues and eigenvectors.

Usage

Aver_soj_time(ii, tau_observed, Q)

Arguments

ii

number (scalar)

tau_observed

number (scalar), observed time

Q

Matrix (m x m), m - number of states

Value

Vector of average sojourn times in each state. Vector components in total should give observation time (tau_observed).

Details

Calculating expectation of sojourn times in states for the observed time (tau_observed) and if initial state is given (ii). Matrix Q is so-called Generator matrix: \(Q=\lambda-\Lambda, where \lambda\) is matrix with known transition rates from state $s_i$ to state $s_j$, and \(\Lambda\) is diagonal matrix with a vector \((\Lambda_{1},...,\Lambda_{m}\) on the main diagonal, where m is a number of states of external environment. Eigenvalues and eigenvectors are used in calculations.

Examples

Run this code
# NOT RUN {
lambda <- matrix(c(0, 0.33, 0.45, 0), nrow = 2, ncol = 2, byrow = TRUE)
m <- nrow(lambda)
ld <- as.matrix(rowSums(lambda))
Lambda <- diag(as.vector(ld))
Generator <- t(lambda) - Lambda
Aver_soj_time(1,10,Generator)
# }

Run the code above in your browser using DataLab