# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
sample_baseline_t_link_GP_cpp <- function(eta_t, y_ijt, w_ijt, gamma_ijt, eta_t_cov_prior_inv, lat_mean, eta_t_bar, sigma_eta_bar, directed = FALSE) {
.Call(`_DynMultiNet_sample_baseline_t_link_GP_cpp`, eta_t, y_ijt, w_ijt, gamma_ijt, eta_t_cov_prior_inv, lat_mean, eta_t_bar, sigma_eta_bar, directed)
}
sample_coord_ith_link_GP_cpp <- function(ab_ith, y_ijt, w_ijt, gamma_ijt, ab_t_sigma_prior_inv, tau_h) {
.Call(`_DynMultiNet_sample_coord_ith_link_GP_cpp`, ab_ith, y_ijt, w_ijt, gamma_ijt, ab_t_sigma_prior_inv, tau_h)
}
sample_coord_ith_shared_link_GP_cpp <- function(ab_ith, y_ijtk, w_ijtk, gamma_ijtk, ab_t_sigma_prior_inv, tau_h) {
.Call(`_DynMultiNet_sample_coord_ith_shared_link_GP_cpp`, ab_ith, y_ijtk, w_ijtk, gamma_ijtk, ab_t_sigma_prior_inv, tau_h)
}
sample_coord_ith_link_dir_GP_cpp <- function(a_ith, b_ith, y_ijt, w_ijt, gamma_ijt, ab_t_sigma_prior_inv, lat_mean, a_ith_bar, b_ith_bar, sigma_ab_bar, tau_h_send, tau_h_receive) {
.Call(`_DynMultiNet_sample_coord_ith_link_dir_GP_cpp`, a_ith, b_ith, y_ijt, w_ijt, gamma_ijt, ab_t_sigma_prior_inv, lat_mean, a_ith_bar, b_ith_bar, sigma_ab_bar, tau_h_send, tau_h_receive)
}
sample_coord_ith_shared_link_dir_GP_cpp <- function(a_ith_shared, b_ith_shared, y_ijtk, w_ijtk, gamma_ijtk, ab_t_sigma_prior_inv, lat_mean, a_ith_shared_bar, b_ith_shared_bar, sigma_ab_bar, tau_h_shared_send, tau_h_shared_receive) {
.Call(`_DynMultiNet_sample_coord_ith_shared_link_dir_GP_cpp`, a_ith_shared, b_ith_shared, y_ijtk, w_ijtk, gamma_ijtk, ab_t_sigma_prior_inv, lat_mean, a_ith_shared_bar, b_ith_shared_bar, sigma_ab_bar, tau_h_shared_send, tau_h_shared_receive)
}
sample_add_eff_it_link_cpp <- function(sp_it, sp_t_cov_prior_inv, y_ijt, w_ijt, gamma_ijt, directed = FALSE) {
.Call(`_DynMultiNet_sample_add_eff_it_link_cpp`, sp_it, sp_t_cov_prior_inv, y_ijt, w_ijt, gamma_ijt, directed)
}
sample_add_eff_it_shared_link_cpp <- function(sp_it, y_ijtk, w_ijtk, gamma_ijtk, sp_t_cov_prior_inv, lat_mean, sp_it_bar, sigma_sp_bar, directed = FALSE) {
.Call(`_DynMultiNet_sample_add_eff_it_shared_link_cpp`, sp_it, y_ijtk, w_ijtk, gamma_ijtk, sp_t_cov_prior_inv, lat_mean, sp_it_bar, sigma_sp_bar, directed)
}
sample_coeff_tp_link_cpp <- function(beta_tp, beta_t_cov_prior_inv, y_ijtk, w_ijtk, gamma_ijtk, x_ijtkp_mat, directed = FALSE) {
.Call(`_DynMultiNet_sample_coeff_tp_link_cpp`, beta_tp, beta_t_cov_prior_inv, y_ijtk, w_ijtk, gamma_ijtk, x_ijtkp_mat, directed)
}
sample_baseline_t_link_nGP_cpp <- function(eta_t, alpha_eta_t, y_ijt, w_ijt, gamma_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, directed = FALSE) {
.Call(`_DynMultiNet_sample_baseline_t_link_nGP_cpp`, eta_t, alpha_eta_t, y_ijt, w_ijt, gamma_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, directed)
}
sample_coord_ith_link_nGP_cpp <- function(ab_ith, alpha_ab_ith, y_ijt, w_ijt, gamma_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, verbose = FALSE) {
.Call(`_DynMultiNet_sample_coord_ith_link_nGP_cpp`, ab_ith, alpha_ab_ith, y_ijt, w_ijt, gamma_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, verbose)
}
sample_coord_ith_shared_link_nGP_cpp <- function(ab_ith, alpha_ab_ith, y_ijtk, w_ijtk, gamma_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t) {
.Call(`_DynMultiNet_sample_coord_ith_shared_link_nGP_cpp`, ab_ith, alpha_ab_ith, y_ijtk, w_ijtk, gamma_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t)
}
sample_coord_ith_link_dir_nGP_cpp <- function(ab_ith_send, ab_ith_receive, alpha_ab_ith_send, alpha_ab_ith_receive, y_ijt, w_ijt, gamma_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t) {
.Call(`_DynMultiNet_sample_coord_ith_link_dir_nGP_cpp`, ab_ith_send, ab_ith_receive, alpha_ab_ith_send, alpha_ab_ith_receive, y_ijt, w_ijt, gamma_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t)
}
sample_coord_ith_shared_link_dir_nGP_cpp <- function(ab_ith_send, ab_ith_receive, alpha_ab_ith_send, alpha_ab_ith_receive, y_ijtk, w_ijtk, gamma_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t) {
.Call(`_DynMultiNet_sample_coord_ith_shared_link_dir_nGP_cpp`, ab_ith_send, ab_ith_receive, alpha_ab_ith_send, alpha_ab_ith_receive, y_ijtk, w_ijtk, gamma_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t)
}
sample_baseline_tk_weight_cpp <- function(theta_t, y_ijt, mu_ijt, sigma_k, theta_t_cov_prior_inv, lat_mean, theta_t_bar, sigma_theta_bar, directed = FALSE) {
.Call(`_DynMultiNet_sample_baseline_tk_weight_cpp`, theta_t, y_ijt, mu_ijt, sigma_k, theta_t_cov_prior_inv, lat_mean, theta_t_bar, sigma_theta_bar, directed)
}
sample_coord_ith_weight_cpp <- function(uv_ith, uv_t_sigma_prior_inv, tau_h, y_ijt, mu_ijt, sigma_k) {
.Call(`_DynMultiNet_sample_coord_ith_weight_cpp`, uv_ith, uv_t_sigma_prior_inv, tau_h, y_ijt, mu_ijt, sigma_k)
}
sample_coord_ith_shared_weight_cpp <- function(uv_ith_shared, uv_t_sigma_prior_inv, tau_h, y_ijtk, mu_ijtk, sigma_k) {
.Call(`_DynMultiNet_sample_coord_ith_shared_weight_cpp`, uv_ith_shared, uv_t_sigma_prior_inv, tau_h, y_ijtk, mu_ijtk, sigma_k)
}
sample_coord_ith_weight_dir_cpp <- function(u_ith, v_ith, y_ijt, mu_ijt, sigma_k, uv_t_sigma_prior_inv, lat_mean, u_ith_bar, v_ith_bar, sigma_uv_bar, tau_h_send, tau_h_receive) {
.Call(`_DynMultiNet_sample_coord_ith_weight_dir_cpp`, u_ith, v_ith, y_ijt, mu_ijt, sigma_k, uv_t_sigma_prior_inv, lat_mean, u_ith_bar, v_ith_bar, sigma_uv_bar, tau_h_send, tau_h_receive)
}
sample_coord_ith_shared_weight_dir_cpp <- function(u_ith_shared, v_ith_shared, y_ijtk, mu_ijtk, sigma_k, uv_t_sigma_prior_inv, lat_mean, u_ith_shared_bar, v_ith_shared_bar, sigma_uv_bar, tau_h_shared_send, tau_h_shared_receive) {
.Call(`_DynMultiNet_sample_coord_ith_shared_weight_dir_cpp`, u_ith_shared, v_ith_shared, y_ijtk, mu_ijtk, sigma_k, uv_t_sigma_prior_inv, lat_mean, u_ith_shared_bar, v_ith_shared_bar, sigma_uv_bar, tau_h_shared_send, tau_h_shared_receive)
}
sample_add_eff_it_weight_cpp <- function(sp_it, sp_t_cov_prior_inv, y_ijt, mu_ijt, sigma_k, directed = FALSE) {
.Call(`_DynMultiNet_sample_add_eff_it_weight_cpp`, sp_it, sp_t_cov_prior_inv, y_ijt, mu_ijt, sigma_k, directed)
}
sample_add_eff_it_shared_weight_cpp <- function(sp_it, y_ijtk, mu_ijtk, sigma_k, sp_t_cov_prior_inv, lat_mean, sp_it_bar, sigma_sp_bar, directed = FALSE) {
.Call(`_DynMultiNet_sample_add_eff_it_shared_weight_cpp`, sp_it, y_ijtk, mu_ijtk, sigma_k, sp_t_cov_prior_inv, lat_mean, sp_it_bar, sigma_sp_bar, directed)
}
sample_coeff_tp_weight_cpp <- function(beta_tp, beta_t_cov_prior_inv, y_ijtk, mu_ijtk, sigma_k, x_ijtkp_mat, directed = FALSE) {
.Call(`_DynMultiNet_sample_coeff_tp_weight_cpp`, beta_tp, beta_t_cov_prior_inv, y_ijtk, mu_ijtk, sigma_k, x_ijtkp_mat, directed)
}
sample_var_weight_cpp <- function(sigma_k, sigma_k_prop_int, y_ijt, mu_ijt, directed = FALSE) {
.Call(`_DynMultiNet_sample_var_weight_cpp`, sigma_k, sigma_k_prop_int, y_ijt, mu_ijt, directed)
}
sample_baseline_t_weight_nGP_cpp <- function(eta_t, alpha_eta_t, y_ijt, mu_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k, directed = FALSE) {
.Call(`_DynMultiNet_sample_baseline_t_weight_nGP_cpp`, eta_t, alpha_eta_t, y_ijt, mu_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k, directed)
}
sample_coord_ith_weight_nGP_cpp <- function(sp_ith, alpha_sp_ith, y_ijt, mu_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k, verbose = FALSE) {
.Call(`_DynMultiNet_sample_coord_ith_weight_nGP_cpp`, sp_ith, alpha_sp_ith, y_ijt, mu_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k, verbose)
}
sample_coord_ith_shared_weight_nGP_cpp <- function(sp_ith, alpha_sp_ith, y_ijtk, mu_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k) {
.Call(`_DynMultiNet_sample_coord_ith_shared_weight_nGP_cpp`, sp_ith, alpha_sp_ith, y_ijtk, mu_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k)
}
sample_coord_ith_weight_dir_nGP_cpp <- function(sp_ith_send, sp_ith_receive, alpha_sp_ith_send, alpha_sp_ith_receive, y_ijt, mu_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k) {
.Call(`_DynMultiNet_sample_coord_ith_weight_dir_nGP_cpp`, sp_ith_send, sp_ith_receive, alpha_sp_ith_send, alpha_sp_ith_receive, y_ijt, mu_ijt, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k)
}
sample_coord_ith_shared_weight_dir_nGP_cpp <- function(sp_ith_send, sp_ith_receive, alpha_sp_ith_send, alpha_sp_ith_receive, y_ijtk, mu_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k) {
.Call(`_DynMultiNet_sample_coord_ith_shared_weight_dir_nGP_cpp`, sp_ith_send, sp_ith_receive, alpha_sp_ith_send, alpha_sp_ith_receive, y_ijtk, mu_ijtk, nGP_G_t, nGP_H_t, nGP_Wchol_t, sigma_k)
}
#' @description
#' Performs Kalman filtering and smoothing or simulation smoothing.
#'
#' @param y matrix. Matrix with observations. dim(y)=c(nobs,T_steps).
#'
#' @param ZZ cube (3D array). Mapping matrix of the states into observations. dim(ZZ)=c(nobs,nstates,T_steps).
#' @param HHchol cube. Cholesky of the covariance of the shocks for the observations. dim(HHchol)=c(nobs,nobsshocks,T_steps).
#'
#' @param TT cube. Mapping matrix of the states. dim(TT)=c(nstates,nstates,T_steps).
#' @param RR cube. Cholesky of the covariance of the shocks for the states. dim(RR)=c(nstates,nstatesshocks,T_steps).
#'
#' @param a1 matrix. Mean of the initial state. dim(a1)=c(nstates,1).
#' @param P1chol matrix. Cholesky of the covariance of the initial states. dim(P1chol)=c(nstates,nstates).
#'
#' @param ind_output integer. Indicates the output that for the function, see details.
#' @param verbose boolean. Verbose execution.
#'
#' @details
#' The model assumes a latent variable approach.
#'
#' y(t) = ZZ(t) * a(t) + eps(t), eps(t) ~ N(0,HH(t))
#' a(t+1) = TT(t) * a(t) + RR(t) * eta(t), eta(t) ~ N(0,QQ(t))
#' a(1) ~ N(a1,P1)
#'
#' The simulation smoother is a version of Algorithm 2 of Durbin and Koopman (2002)
#' *WITH* the efficient modification that saves one pass of the filter/smoother.
#'
#' The initialization of the simulation smoother follows:
#' Jarocinski (2015) A note on implementing the Durbin and Koopman simulation smoother,
#'
#' - Missing data not allowed (y does not contain any NaN)
#'
#' @return
#' A list with the following components:
#' \describe{
#' \item{\code{aaa}}{if \code{ind_output=1}, the mean of the states conditional on y, nstates x T.}
#' \item{\code{loglik}}{log likelihood of each observation of y, 1 x T.}
#' }
#'
#' @export
kfsim <- function(y, ZZ, HHchol, TT, RR, QQchol, a1, P1chol, ind_output, verbose = FALSE) {
.Call(`_DynMultiNet_kfsim`, y, ZZ, HHchol, TT, RR, QQchol, a1, P1chol, ind_output, verbose)
}
#' @export
kfsim_cpp <- function(y, ZZ, HHchol, TT, RR, QQchol, a1, P1chol) {
.Call(`_DynMultiNet_kfsim_cpp`, y, ZZ, HHchol, TT, RR, QQchol, a1, P1chol)
}
# Register entry points for exported C++ functions
methods::setLoadAction(function(ns) {
.Call('_DynMultiNet_RcppExport_registerCCallable', PACKAGE = 'DynMultiNet')
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.