-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the function 'get.psi' to compute the matrix-valued function
Add the function 'get.psi' to compute the matrix-valued function psi based on a given semi-Markov kernel 'q'
- Loading branch information
1 parent
acfd3df
commit 0af0f3e
Showing
6 changed files
with
68 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Function to compute the value of \eqn{\psi} | ||
.get.psi <- function(q) { | ||
|
||
k <- dim(q)[3] - 1 | ||
|
||
psi <- array(data = 0, dim = c(nrow(q), ncol(q), k + 1)) # (S, S, k + 1) | ||
psi[, , 1] <- diag(x = 1, nrow = nrow(q), ncol = ncol(q)) # k = 0 | ||
|
||
for (j in 1:k) { | ||
|
||
psi[, , j + 1] <- | ||
-Reduce('+', lapply( | ||
X = 0:(j - 1), | ||
FUN = function(l) | ||
psi[, , l + 1] %*% (-q[, , j - l + 1]) | ||
)) | ||
} | ||
|
||
return(psi) | ||
|
||
} | ||
|
||
#' Function to compute the value of the matrix-valued function \eqn{\psi} | ||
#' | ||
#' @description Function to compute the value of \eqn{\psi}, the matrix-valued | ||
#' function (See equation (3.16) p.53). | ||
#' | ||
#' @param q An array giving the values of the kernel for a giving time horizon | ||
#' \eqn{[0, \dots, k]} (This kernel `q` is the output of the method `getKernel` | ||
#' or `.get.qy`). | ||
#' @return An array giving the value of \eqn{\psi(k)} at each time between 0 | ||
#' and `k`. | ||
#' | ||
#' @export | ||
#' | ||
get.psi <- function(q) { | ||
|
||
.is.kernel(q) | ||
|
||
psi <- .get.psi(q) | ||
|
||
return(psi) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.