Title: | Filtering Algorithms for the State Space Models on the Stiefel Manifold |
---|---|
Description: | Provides the filtering algorithms for the state space models on the Stiefel manifold as well as the corresponding sampling algorithms for uniform, vector Langevin-Bingham and matrix Langevin-Bingham distributions on the Stiefel manifold. |
Authors: | Yukai Yang [aut, cre] |
Maintainer: | Yukai Yang <[email protected]> |
License: | GPL-3 |
Version: | 1.0.4 |
Built: | 2025-02-11 05:12:28 UTC |
Source: | https://github.com/yukai-yang/smfilter |
This function Compute the squared Frobenius distance between two matrices.
FDist2(mX, mY)
FDist2(mX, mY)
mX |
a |
mY |
another |
The Frobenius distance between two matrices is defined to be
where .
The Frobenius distance is a possible measure of the distance between two points on the Stiefel manifold.
the Frobenius distance.
Yukai Yang, [email protected]
FDist2(runif_sm(1,4,2)[1,,], runif_sm(1,4,2)[1,,])
FDist2(runif_sm(1,4,2)[1,,], runif_sm(1,4,2)[1,,])
This function implements the filtering algorithm for the type one model. See Details part below.
FilterModel1(mY, mX, mZ, beta, mB = NULL, Omega, vD, U0, method = "max_1")
FilterModel1(mY, mX, mZ, beta, mB = NULL, Omega, vD, U0, method = "max_1")
mY |
the matrix containing Y_t with dimension |
mX |
the matrix containing X_t with dimension |
mZ |
the matrix containing Z_t with dimension |
beta |
the |
mB |
the coefficient matrix |
Omega |
covariance matrix of the errors. |
vD |
vector of the diagonals of |
U0 |
initial value of the alpha sequence. |
method |
a string representing the optimization method from c('max_1','max_2','max_3','min_1','min_2'). |
The type one model on Stiefel manifold takes the form:
where is a
-vector of the dependent variable,
and
are explanatory variables wit dimension
and
,
and
have no overlap,
matrix
is the coefficients for
,
is the error vector.
The matrices and
have dimensions
and
, respectively.
Note that
is strictly smaller than both
and
.
and
are both non-singular matrices.
is time-varying while
is time-invariant.
Furthermore, fulfills the condition
,
and therefor it evolves on the Stiefel manifold.
denotes the Matrix Langevin distribution or matrix von Mises-Fisher distribution on the Stiefel manifold.
Its density function takes the form
where denotes
,
and
is the (0,1)-type hypergeometric function for matrix.
an array aAlpha
containing the modal orientations of alpha in the prediction step.
Yukai Yang, [email protected]
iT = 50 ip = 2 ir = 1 iqx = 4 iqz=0 ik = 0 Omega = diag(ip)*.1 if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha_0 = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) mB=NULL vD = 100 ret = SimModel1(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha_0=alpha_0, beta=beta, mB=mB, vD=vD, Omega=Omega) mYY=as.matrix(ret$dData[,1:ip]) fil = FilterModel1(mY=mYY, mX=mX, mZ=mZ, beta=beta, mB=mB, Omega=Omega, vD=vD, U0=alpha_0)
iT = 50 ip = 2 ir = 1 iqx = 4 iqz=0 ik = 0 Omega = diag(ip)*.1 if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha_0 = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) mB=NULL vD = 100 ret = SimModel1(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha_0=alpha_0, beta=beta, mB=mB, vD=vD, Omega=Omega) mYY=as.matrix(ret$dData[,1:ip]) fil = FilterModel1(mY=mYY, mX=mX, mZ=mZ, beta=beta, mB=mB, Omega=Omega, vD=vD, U0=alpha_0)
This function implements the filtering algorithm for the type two model. See Details part below.
FilterModel2(mY, mX, mZ, alpha, mB = NULL, Omega, vD, U0, method = "max_1")
FilterModel2(mY, mX, mZ, alpha, mB = NULL, Omega, vD, U0, method = "max_1")
mY |
the matrix containing Y_t with dimension |
mX |
the matrix containing X_t with dimension |
mZ |
the matrix containing Z_t with dimension |
alpha |
the |
mB |
the coefficient matrix |
Omega |
covariance matrix of the errors. |
vD |
vector of the diagonals of |
U0 |
initial value of the alpha sequence. |
method |
a string representing the optimization method from c('max_1','max_2','max_3','min_1','min_2'). |
The type two model on Stiefel manifold takes the form:
where is a
-vector of the dependent variable,
and
are explanatory variables wit dimension
and
,
and
have no overlap,
matrix
is the coefficients for
,
is the error vector.
The matrices and
have dimensions
and
, respectively.
Note that
is strictly smaller than both
and
.
and
are both non-singular matrices.
is time-varying while
is time-invariant.
Furthermore, fulfills the condition
,
and therefor it evolves on the Stiefel manifold.
denotes the Matrix Langevin distribution or matrix von Mises-Fisher distribution on the Stiefel manifold.
Its density function takes the form
where denotes
,
and
is the (0,1)-type hypergeometric function for matrix.
an array aAlpha
containing the modal orientations of alpha in the prediction step.
Yukai Yang, [email protected]
iT = 50 ip = 2 ir = 1 iqx = 4 iqz=0 ik = 0 Omega = diag(ip)*.1 if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta_0 = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) mB=NULL vD = 100 ret = SimModel2(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha=alpha, beta_0=beta_0, mB=mB, vD=vD) mYY=as.matrix(ret$dData[,1:ip]) fil = FilterModel2(mY=mYY, mX=mX, mZ=mZ, alpha=alpha, mB=mB, Omega=Omega, vD=vD, U0=beta_0)
iT = 50 ip = 2 ir = 1 iqx = 4 iqz=0 ik = 0 Omega = diag(ip)*.1 if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta_0 = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) mB=NULL vD = 100 ret = SimModel2(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha=alpha, beta_0=beta_0, mB=mB, vD=vD) mYY=as.matrix(ret$dData[,1:ip]) fil = FilterModel2(mY=mYY, mX=mX, mZ=mZ, alpha=alpha, mB=mB, Omega=Omega, vD=vD, U0=beta_0)
This function draws a sample from the matrix Langevin-Bingham on the Stiefel manifold.
rmLB_sm(num, mJ, mH, mC, mX, ir)
rmLB_sm(num, mJ, mH, mC, mX, ir)
num |
number of observations or sample size. |
mJ |
symmetric ip*ip matrix |
mH |
symmetric ir*ir matrix |
mC |
ip*ir matrix |
mX |
ip*ir matrix, the initial value |
ir |
ir |
The matrix Langevin-Bingham distribution on the Stiefel manifold has the density kernel:
where satisfies
, and
and
are symmetric matrices.
an array containing a sample of draws from the matrix Langevin-Bingham on the Stiefel manifold.
Yukai Yang, [email protected]
#' @section References: Hoff, P. D. (2009) "Simulation of the Matrix Bingham—von Mises—Fisher Distribution, With Applications to Multivariate and Relational Data", Journal of Computational and Graphical Statistics, Vol. 18, pp. 438-456.
This function draws a sample from the uniform distribution on the Stiefel manifold.
runif_sm(num, ip, ir)
runif_sm(num, ip, ir)
num |
number of observations or sample size. |
ip |
the first dimension |
ir |
the second dimension |
The Stiefel manifold with dimension and
(
) is a space whose points are
-frames in
.
A set of
orthonormal vectors in
is called an
-frame in
.
The Stiefel manifold is a collection of
full rank matrices
such that
.
an array with dimension num
, ip
and ir
containing a sample of draws from the uniform distribution on the Stiefel manifold.
Yukai Yang, [email protected]
runif_sm(10,4,2)
runif_sm(10,4,2)
This function draws a sample from the vector Langevin-Bingham on the Stiefel manifold.
rvlb_sm(num, mA, vc, vx)
rvlb_sm(num, mA, vc, vx)
num |
number of observations or sample size. |
mA |
the matrix A which is symmetric ip*ip matrix. |
vc |
the vector c with dimension ip. |
vx |
the vector x, the initial value. |
The vector Langevin-Bingham distribution on the Stiefel manifold has the density kernel:
where satisfies
, and
is a symmetric matrix.
an array containing a sample of draws from the vector Langevin-Bingham on the Stiefel manifold.
Hoff, P. D. (2009) "Simulation of the Matrix Bingham—von Mises—Fisher Distribution, With Applications to Multivariate and Relational Data", Journal of Computational and Graphical Statistics, Vol. 18, pp. 438-456.
Yukai Yang, [email protected]
This function simulates from the type one model on Stiefel manifold. See Details part below.
SimModel1(iT, mX = NULL, mZ = NULL, mY = NULL, alpha_0, beta, mB = NULL, Omega = NULL, vD, burnin = 100)
SimModel1(iT, mX = NULL, mZ = NULL, mY = NULL, alpha_0, beta, mB = NULL, Omega = NULL, vD, burnin = 100)
iT |
the sample size. |
mX |
the matrix containing X_t with dimension |
mZ |
the matrix containing Z_t with dimension |
mY |
initial values of the dependent variable for |
alpha_0 |
the initial alpha, |
beta |
the |
mB |
the coefficient matrix |
Omega |
covariance matrix of the errors. |
vD |
vector of the diagonals of |
burnin |
burn-in sample size (matrix Langevin). |
The type one model on Stiefel manifold takes the form:
where is a
-vector of the dependent variable,
and
are explanatory variables wit dimension
and
,
and
have no overlap,
matrix
is the coefficients for
,
is the error vector.
The matrices and
have dimensions
and
, respectively.
Note that
is strictly smaller than both
and
.
and
are both non-singular matrices.
is time-varying while
is time-invariant.
Furthermore, fulfills the condition
,
and therefor it evolves on the Stiefel manifold.
denotes the Matrix Langevin distribution or matrix von Mises-Fisher distribution on the Stiefel manifold.
Its density function takes the form
where denotes
,
and
is the (0,1)-type hypergeometric function for matrix.
Note that the function does not add intercept automatically.
A list containing the sampled data and the dynamics of alpha.
The object is a list containing the following components:
dData |
a data.frame of the sampled data |
aAlpha |
an array of the |
Yukai Yang, [email protected]
iT = 50 # sample size ip = 2 # dimension of the dependent variable ir = 1 # rank number iqx=2 # number of variables in X iqz=2 # number of variables in Z ik = 1 # lag length if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha_0 = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) if(ip*ik+iqz==0) mB=NULL else mB = matrix(c(runif_sm(num=1,ip=(ip*ik+iqz)*ip,ir=1)), ip, ip*ik+iqz) vD = 50 ret = SimModel1(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha_0=alpha_0, beta=beta, mB=mB, vD=vD)
iT = 50 # sample size ip = 2 # dimension of the dependent variable ir = 1 # rank number iqx=2 # number of variables in X iqz=2 # number of variables in Z ik = 1 # lag length if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha_0 = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) if(ip*ik+iqz==0) mB=NULL else mB = matrix(c(runif_sm(num=1,ip=(ip*ik+iqz)*ip,ir=1)), ip, ip*ik+iqz) vD = 50 ret = SimModel1(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha_0=alpha_0, beta=beta, mB=mB, vD=vD)
This function simulates from the type two model on Stiefel manifold. See Details part below.
SimModel2(iT, mX = NULL, mZ = NULL, mY = NULL, beta_0, alpha, mB = NULL, Omega = NULL, vD, burnin = 100)
SimModel2(iT, mX = NULL, mZ = NULL, mY = NULL, beta_0, alpha, mB = NULL, Omega = NULL, vD, burnin = 100)
iT |
the sample size. |
mX |
the matrix containing X_t with dimension |
mZ |
the matrix containing Z_t with dimension |
mY |
initial values of the dependent variable for |
beta_0 |
the initial beta, iqx+ip*ik, y_1,t-1,y_1,t-2,...,y_2,t-1,y_2,t-2,.... |
alpha |
the |
mB |
the coefficient matrix |
Omega |
covariance matrix of the errors. |
vD |
vector of the diagonals of |
burnin |
burn-in sample size (matrix Langevin). |
The type two model on Stiefel manifold takes the form:
where is a
-vector of the dependent variable,
and
are explanatory variables wit dimension
and
,
and
have no overlap,
matrix
is the coefficients for
,
is the error vector.
The matrices and
have dimensions
and
, respectively.
Note that
is strictly smaller than both
and
.
and
are both non-singular matrices.
is time-varying while
is time-invariant.
Furthermore, fulfills the condition
,
and therefor it evolves on the Stiefel manifold.
denotes the Matrix Langevin distribution or matrix von Mises-Fisher distribution on the Stiefel manifold.
Its density function takes the form
where denotes
,
and
is the (0,1)-type hypergeometric function for matrix.
Note that the function does not add intercept automatically.
A list containing the sampled data and the dynamics of beta.
The object is a list containing the following components:
dData |
a data.frame of the sampled data |
aBeta |
an array of the |
Yukai Yang, [email protected]
iT = 50 ip = 2 ir = 1 iqx =3 iqz=2 ik = 1 if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta_0 = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) if(ip*ik+iqz==0) mB=NULL else mB = matrix(c(runif_sm(num=1,ip=(ip*ik+iqz)*ip,ir=1)), ip, ip*ik+iqz) vD = 50 ret = SimModel2(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha=alpha, beta_0=beta_0, mB=mB, vD=vD)
iT = 50 ip = 2 ir = 1 iqx =3 iqz=2 ik = 1 if(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx) if(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz) if(ik==0) mY=NULL else mY = matrix(0, ik, ip) alpha = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir) beta_0 = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir) if(ip*ik+iqz==0) mB=NULL else mB = matrix(c(runif_sm(num=1,ip=(ip*ik+iqz)*ip,ir=1)), ip, ip*ik+iqz) vD = 50 ret = SimModel2(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha=alpha, beta_0=beta_0, mB=mB, vD=vD)
The package implements the filtering algorithms for the state-space models on the Stiefel manifold. It also implements sampling algorithms for uniform, vector Langevin-Bingham and matrix Langevin-Bingham distributions on the Stiefel manifold.
Two types of the state-space models on the Stiefel manifold are considered.
The type one model on Stiefel manifold takes the form:
where is a
-vector of the dependent variable,
and
are explanatory variables wit dimension
and
,
and
have no overlap,
matrix
is the coefficients for
,
is the error vector.
The matrices and
have dimensions
and
, respectively.
Note that
is strictly smaller than both
and
.
and
are both non-singular matrices.
is time-varying while
is time-invariant.
Furthermore, fulfills the condition
,
and therefor it evolves on the Stiefel manifold.
denotes the Matrix Langevin distribution or matrix von Mises-Fisher distribution on the Stiefel manifold.
Its density function takes the form
where denotes
,
and
is the (0,1)-type hypergeometric function for matrix.
The type two model on Stiefel manifold takes the form:
where is a
-vector of the dependent variable,
and
are explanatory variables wit dimension
and
,
and
have no overlap,
matrix
is the coefficients for
,
is the error vector.
The matrices and
have dimensions
and
, respectively.
Note that
is strictly smaller than both
and
.
and
are both non-singular matrices.
is time-varying while
is time-invariant.
Furthermore, fulfills the condition
,
and therefor it evolves on the Stiefel manifold.
denotes the Matrix Langevin distribution or matrix von Mises-Fisher distribution on the Stiefel manifold.
Its density function takes the form
where denotes
,
and
is the (0,1)-type hypergeometric function for matrix.
Yukai Yang
Department of Statistics, Uppsala University
Yang, Yukai and Bauwens, Luc. (2018) "State-Space Models on the Stiefel Manifold with a New Approach to Nonlinear Filtering", Econometrics, 6(4), 48.
SimModel1
simulate from the type one state-space model on the Stiefel manifold.
SimModel2
simulate from the type two state-space model on the Stiefel manifold.
FilterModel1
filtering algorithm for the type one model.
FilterModel2
filtering algorithm for the type two model.
runif_sm
sample from the uniform distribution on the Stiefel manifold.
rvlb_sm
sample from the vector Langevin-Bingham distribution on the Stiefel manifold.
rmLB_sm
sample from the matrix Langevin-Bingham distribution on the Stiefel manifold.
version
shows the version number and some information of the package.
This function shows the version number and some information of the package.
version()
version()
Yukai Yang, [email protected]