iterative_grid_search {viking} | R Documentation |
Iterative Grid Search
Description
iterative_grid_search
is an iterative method to choose hyper-parameters of
the linear Gaussian State-Space Model with time-invariant variances.
Usage
iterative_grid_search(
X,
y,
q_list,
Q_init = NULL,
max_iter = 0,
delay = 1,
use = NULL,
restrict = NULL,
mode = "gaussian",
p1 = 0,
ncores = 1,
train_theta1 = NULL,
train_Q = NULL,
verbose = TRUE
)
Arguments
X |
the explanatory variables |
y |
the observations |
q_list |
the possible values of |
Q_init |
(default |
max_iter |
(optional 0) maximal number of iterations. If 0 then optimization is done as long as we can improve the log-likelihood |
delay |
(optional, default 1) to predict |
use |
(optional, default |
restrict |
(optional, default |
mode |
(optional, default |
p1 |
(optional, default |
ncores |
(optional, default |
train_theta1 |
(optional, default |
train_Q |
(optional, default |
verbose |
(optional, default |
Details
We restrict ourselves to a diagonal matrix Q
and we optimize Q / sig^2
on
a grid. Each diagonal coefficient is assumed to belong to a pre-defined q_list
.
We maximize the log-likelihood on that region of search in an iterative fashion.
At each step, we change the diagonal coefficient improving the most the log-likelihood.
We stop when there is no possible improvement. This doesn't guarantee an optimal point
on the grid, but the computational time is much lower.
Value
a list containing values for P,theta,sig,Q
, as well as LOGLIK
,
the evolution of the log-likelihood during the search.
Examples
set.seed(1)
### Simulate data
n <- 100
d <- 5
Q <- diag(c(0,0,0.25,0.25,0.25))
sig <- 1
X <- cbind(matrix(rnorm((d-1)*n,sd=1),n,d-1),1)
theta <- matrix(rnorm(d), d, 1)
theta_arr <- matrix(0, n, d)
for (t in 1:n) {
theta_arr[t,] <- theta
theta <- theta + matrix(mvtnorm::rmvnorm(1,matrix(0,d,1),Q),d,1)
}
y <- rowSums(X * theta_arr) + rnorm(n, sd=sig)
l <- viking::iterative_grid_search(X, y, seq(0,1,0.25))
print(l$Q)
print(l$sig)