INLA_DIST
|
Computes the Posterior of the hyperparameters theta. More...
#include <PostTheta.h>
Public Member Functions | |
PostTheta (int ns, int nt, int nb, int no, MatrixXd B, Vect y, Vect theta_prior, Vect mu_initial, string likelihood, Vect extraCoeffVecLik, string solver_type, const bool constr, const MatrixXd Dxy, const bool validate, const Vect w) | |
constructor for regression model (no random effects). | |
PostTheta (int ns, int nt, int nb, int no, SpMat Ax, Vect y, SpMat c0, SpMat g1, SpMat g2, Vect theta_prior, Vect mu_initial, string likelihood, Vect extraCoeffVecLik, string solver_type, int dim_spatial_domain, string manifold, const bool constr, const MatrixXd Dx, const MatrixXd Dxy, const bool validate, const Vect w) | |
constructor for spatial model (order 2). | |
PostTheta (int ns, int nt, int nb, int no, SpMat Ax, Vect y, SpMat c0, SpMat g1, SpMat g2, SpMat g3, SpMat M0, SpMat M1, SpMat M2, Vect theta_prior, Vect mu_initial, string likelihood, Vect extraCoeffVecLik, string solver_type, int dim_spatial_domain, string manifold, const bool constr, const MatrixXd Dx, const MatrixXd Dxy, const bool validate, const Vect w) | |
constructor for spatial temporal model. | |
PostTheta (int ns, int nt, int nss, int nb, int no, SpMat Ax, Vect y, SpMat c0, SpMat g1, SpMat g2, SpMat g3, SpMat M0, SpMat M1, SpMat M2, Vect theta_prior_param, Vect mu_initial, string likelihood, Vect extraCoeffVecLik, string solver_type, int dim_spatial_domain, string manifold, const bool constr, const MatrixXd Dx, const MatrixXd Dxy, const bool validate, const Vect w) | |
constructor for spatial temporal model w/ add. spatial field | |
double | operator() (Vect &theta, Vect &grad) |
structure required by BFGS solver, requires : theta, gradient theta | |
double | compute_error_bfgs (Vect &theta) |
void | computeG (Vect &theta) |
overwriting G every time, not explicitly listed, better way to do this? needs to be stored after every iteration for smart hessian ... | |
int | get_fct_count () |
void | convert_theta2interpret (Vect &theta, Vect &theta_interpret) |
void | convert_interpret2theta (Vect &theta_interpret, Vect &theta) |
void | convert_theta2interpret_spatTemp (double lgamE, double lgamS, double lgamT, double &sigU, double &ranS, double &ranT) |
convert hyperparameters theta from the model parametrisation to the interpretable parametrisation ie. from log(gamma_E, gamma_s, gamma_t) to log(sigma.u, rangeS, rangeT) | |
void | convert_interpret2theta_spatTemp (double sigU, double ranS, double ranT, double &lgamE, double &lgamS, double &lgamT) |
convert hyperparameters theta from the interpretable parametrisation to the model parametrisation ie. from log(sigma.u, rangeS, rangeT) to log(gamma_E, gamma_s, gamma_t) | |
void | convert_interpret2theta_spat (double lranS, double lsigU, double &lgamS, double &lgamE) |
convert hyperparameters theta from the interpretable parametrisation to the model parametrisation ie. from log(rangeS, sigma.u) to log(gamma_s, gamma_E) for spatial model order 2 | |
void | convert_theta2interpret_spat (double lgamS, double lgamE, double &lranS, double &lsigU) |
convert hyperparameters theta from the interpretable parametrisation to the model parametrisation ie. from log(rangeS, sigma.u) to log(gamma_s, gamma_E) for spatial model order 2 | |
void | get_mu (Vect &theta, Vect &mu_) |
get conditional mean mu for theta – Gaussian case. | |
Vect | get_grad () |
returns current gradient of theta. | |
void | get_Qprior (Vect theta, SpMat &Qprior) |
MatrixXd | get_Covariance (Vect theta, double eps) |
Compute Covariance matrix of hyperparameters theta, at theta. | |
MatrixXd | get_Cov_interpret_param (Vect interpret_theta, double eps) |
double | f_eval (Vect &theta) |
void | get_marginals_f (Vect &theta, Vect &mu, Vect &vars) |
Compute the marginal variances of the latent parameters at theta. Using selected inversion procedure. | |
void | get_fullFact_marginals_f (Vect &theta, SpMat &Qinv) |
Compute the marginal variances of the latent parameters at theta. Using selected inversion procedure. | |
void | compute_fullInverseQ (Vect &theta, MatrixXd &Qinv) |
MatrixXd | hess_eval (Vect theta, double eps) |
computes the hessian at theta using second order finite difference. Is used be get_Covariance. | |
MatrixXd | hess_eval_interpret_theta (Vect interpret_theta, double eps) |
void | check_pos_def (MatrixXd &hess) |
check if Hessian positive definite (matrix assumed to be dense & small since dim(theta) small) | |
double | eval_post_theta (Vect &theta, Vect &mu) |
Core function. Evaluate posterior of theta. mu are latent parameters. | |
void | eval_log_gaussian_prior_hp (Vect &theta_param, Vect &theta_prior_param, double &log_prior) |
evaluate log prior of the hyperparameters using original theta value | |
void | eval_log_pc_prior_hp (double &log_sum, Vect &lambda, Vect &theta_interpret) |
evaluate log prior using PC prior | |
void | update_mean_constr (const MatrixXd &D, Vect &e, Vect &sol, MatrixXd &V, MatrixXd &W, MatrixXd &U, Vect &updated_sol) |
void | eval_log_dens_constr (Vect &x, Vect &mu, SpMat &Q, double &log_det_Q, const MatrixXd &D, MatrixXd &W, double &val_log_dens) |
void | eval_log_prior_lat (Vect &theta, Vect &mu, double &val) |
evaluate log prior of random effects | |
void | eval_likelihood (Vect &theta, Vect &mu, double &log_det, double &val) |
compute log likelihood : log_det tau*no and value -theta*yTy | |
void | construct_Q_spatial (Vect &theta, SpMat &Qs) |
spatial model : SPDE discretisation – matrix construction | |
void | construct_Q_spat_temp (Vect &theta, SpMat &Qst) |
spatial temporal model : SPDE discretisation. DEMF(1,2,1) model. | |
void | construct_Qprior (Vect &theta, SpMat &Qx) |
void | construct_Q (Vect &theta, Vect &mu, SpMat &Q) |
construct precision matrix. Calls spatial, spatial-temporal, etc. | |
void | construct_b (Vect &theta, Vect &rhs) |
Assemble right-handside. | |
void | eval_denominator (Vect &theta, double &val, SpMat &Q, Vect &rhs, Vect &mu) |
Evaluate denominator: conditional probability of Qx|y. | |
double | cond_LogPriorLat (SpMat &Qprior, Vect &x) |
evaluate Gaussian log prior (without log determinant!!), mean assumed to be zero | |
double | cond_LogPoisLik (Vect &eta) |
evaluate log Poisson likelihood | |
double | cond_negLogPoisLik (Vect &eta) |
evaluate negative log Poisson likelihood | |
Vect | grad_cond_negLogPoisLik (Vect &eta) |
evaluate analytical negative gradient log Poisson likelihood | |
Vect | diagHess_cond_negLogPoisLik (Vect &eta) |
evaluate analytical negative diagonal Hessian of log Poisson likelihood | |
double | cond_negLogPois (SpMat &Qprior, Vect &x) |
evaluate negative condiational log Poisson + Gaussian prior | |
void | link_f_sigmoid (Vect &x, Vect &sigmoidX) |
link function. vectorized evaluation of sigmoid function for each entry | |
double | cond_negLogBinomLik (Vect &eta) |
evaluate negative log Binomial likelihood | |
double | cond_negLogBinom (SpMat &Qprior, Vect &x) |
evaluate negative condiational log Poisson + Gaussian prior | |
double | cond_negLogDist (SpMat &Qprior, Vect &x, function< double(Vect &, Vect &)> lik_func) |
evaluate negative condiational log likelihood + Gaussian prior | |
void | FD_gradient (Vect &eta, Vect &grad) |
compute finite difference gradient. 1st order central difference. currently stepsize h fixed. | |
void | FD_diag_hessian (Vect &eta, Vect &diag_hess) |
compute finite difference diagonal of hessian. 2nd order central difference. currently stepsize h fixed. | |
void | NewtonIter (Vect &theta, Vect &x, SpMat &Q, double &log_det) |
Newton iteration to find optimum of conditional distribution latent parameters of prior & likelihood. | |
void | record_times (std::string file_name, int iter_count, double t_Ftheta_ext, double t_thread_nom, double t_priorHyp, double t_priorLat, double t_priorLatAMat, double t_priorLatChol, double t_likel, double t_thread_denom, double t_condLat, double t_condLatAMat, double t_condLatChol, double t_condLatSolve) |
~PostTheta () | |
class destructor. Frees memory allocated by PostTheta class. | |
Private Attributes | |
int | MPI_size |
int | MPI_rank |
int | threads_level1 |
int | threads_level2 |
int | ns |
int | nt |
int | nss |
int | nb |
int | no |
int | nst |
int | nu |
int | n |
size_t | nnz_Qst |
size_t | nnz_Qs |
int | dim_th |
int | dim_spatial_domain |
string | manifold |
int | dim_grad_loop |
int | num_solvers |
Solver * | solverQ |
Solver * | solverQst |
int | threadID_solverQst |
int | threadID_solverQ |
string | likelihood |
Vect | extraCoeffVecLik |
string | solver_type |
std::string | prior |
int | fct_count |
int | iter_count |
int | iter_acc |
Vect | y |
Vect | theta_prior_param |
Vector3i | dimList |
SpMat | Ax |
MatrixXd | B |
SpMat | c0 |
SpMat | g1 |
SpMat | g2 |
SpMat | g3 |
SpMat | M0 |
SpMat | M1 |
SpMat | M2 |
SpMat | Qb |
SpMat | Qu |
SpMat | Qst |
SpMat | Qs |
SpMat | Qx |
SpMat | Qxy |
double | yTy |
Vect | BTy |
Vect | AxTy |
SpMat | AxTAx |
Vect | mu_initial |
Vect | mu |
Vect | mu_midpoint |
MatrixXd | mu_matrix |
Vect | t_grad |
double | min_f_theta |
double | w_sum |
int | no_f_eval |
ArrayXi | task_to_rank_list_grad |
MatrixXd | G |
const bool | constr |
const MatrixXd | Dx |
const MatrixXd | Dxy |
const bool | validate |
const Vect | w |
bool | printed_eps_flag = false |
double | t_priorLatChol |
double | t_condLatChol |
double | t_condLatSolve |
double | t_bfgs_iter |
Computes the Posterior of the hyperparameters theta.
Computes the posterior of theta for a given theta and its gradient using a central finite difference approximation. Can additionally compute an approximation to the Hessian.
PostTheta::PostTheta | ( | int | ns, |
int | nt, | ||
int | nb, | ||
int | no, | ||
MatrixXd | B, | ||
Vect | y, | ||
Vect | theta_prior, | ||
Vect | mu_initial, | ||
string | likelihood, | ||
Vect | extraCoeffVecLik, | ||
string | solver_type, | ||
const bool | constr, | ||
const MatrixXd | Dxy, | ||
const bool | validate, | ||
const Vect | w | ||
) |
constructor for regression model (no random effects).
[in] | ns_ | number of spatial grid points per time step. |
[in] | nt_ | number of temporal time steps. |
[in] | nb_ | number of fixed effects. |
[in] | no_ | number of observations. |
[in] | B_ | covariate matrix. |
[in] | y_ | vector with observations. |
PostTheta::PostTheta | ( | int | ns, |
int | nt, | ||
int | nb, | ||
int | no, | ||
SpMat | Ax, | ||
Vect | y, | ||
SpMat | c0, | ||
SpMat | g1, | ||
SpMat | g2, | ||
Vect | theta_prior, | ||
Vect | mu_initial, | ||
string | likelihood, | ||
Vect | extraCoeffVecLik, | ||
string | solver_type, | ||
int | dim_spatial_domain, | ||
string | manifold, | ||
const bool | constr, | ||
const MatrixXd | Dx, | ||
const MatrixXd | Dxy, | ||
const bool | validate, | ||
const Vect | w | ||
) |
constructor for spatial model (order 2).
[in] | ns_ | number of spatial grid points per time step. |
[in] | nt_ | number of temporal time steps. |
[in] | nb_ | number of fixed effects. |
[in] | no_ | number of observations. |
[in] | Ax_ | covariate matrix. |
[in] | y_ | vector with observations. |
[in] | c0_ | diagonalised mass matrix. |
[in] | g1_ | stiffness matrix. |
[in] | g2_ | defined as : g1 * c0^-1 * g1 |
PostTheta::PostTheta | ( | int | ns, |
int | nt, | ||
int | nb, | ||
int | no, | ||
SpMat | Ax, | ||
Vect | y, | ||
SpMat | c0, | ||
SpMat | g1, | ||
SpMat | g2, | ||
SpMat | g3, | ||
SpMat | M0, | ||
SpMat | M1, | ||
SpMat | M2, | ||
Vect | theta_prior, | ||
Vect | mu_initial, | ||
string | likelihood, | ||
Vect | extraCoeffVecLik, | ||
string | solver_type, | ||
int | dim_spatial_domain, | ||
string | manifold, | ||
const bool | constr, | ||
const MatrixXd | Dx, | ||
const MatrixXd | Dxy, | ||
const bool | validate, | ||
const Vect | w | ||
) |
constructor for spatial temporal model.
constructor for spatial model (order 2).
[in] | ns_ | number of spatial grid points per time step. |
[in] | nt_ | number of temporal time steps. |
[in] | nb_ | number of fixed effects. |
[in] | no_ | number of observations. |
[in] | Ax_ | covariate matrix. |
[in] | y_ | vector with observations. |
[in] | c0_ | diagonalised mass matrix space. |
[in] | g1_ | stiffness matrix space. |
[in] | g2_ | defined as : g1 * c0^-1 * g1 |
[in] | g3_ | defined as : g1 * (c0^-1 * g1)^2 |
[in] | M0_ | diagonalised mass matrix time. |
[in] | M1_ | diagonal matrix with diag(0.5, 0, ..., 0, 0.5) -> account for boundary |
[in] | M2_ | stiffness matrix time. |
[in] | theta_prior | prior hyperparameters |
[in] | solver_type | linear solver: currently PARDISO, BTA |
[in] | dim_spatial_domain | dimension spatial field 1D/2D ... |
[in] | manifold | plane: "", "sphere", can add more later |
[in] | constr | constraints, mainly sum-to-zero |
PostTheta::PostTheta | ( | int | ns, |
int | nt, | ||
int | nss, | ||
int | nb, | ||
int | no, | ||
SpMat | Ax, | ||
Vect | y, | ||
SpMat | c0, | ||
SpMat | g1, | ||
SpMat | g2, | ||
SpMat | g3, | ||
SpMat | M0, | ||
SpMat | M1, | ||
SpMat | M2, | ||
Vect | theta_prior_param, | ||
Vect | mu_initial, | ||
string | likelihood, | ||
Vect | extraCoeffVecLik, | ||
string | solver_type, | ||
int | dim_spatial_domain, | ||
string | manifold, | ||
const bool | constr, | ||
const MatrixXd | Dx, | ||
const MatrixXd | Dxy, | ||
const bool | validate, | ||
const Vect | w | ||
) |
constructor for spatial temporal model w/ add. spatial field
constructor for both spatial models (order 2).
[in] | ns_ | number of spatial grid points per time step. |
[in] | nt_ | number of temporal time steps. |
[in] | nss_ | number of spatial grid points in add. spatial field |
[in] | nb_ | number of fixed effects. |
[in] | no_ | number of observations. |
[in] | Ax_ | covariate matrix. |
[in] | y_ | vector with observations. |
[in] | c0_ | diagonalised mass matrix space. |
[in] | g1_ | stiffness matrix space. |
[in] | g2_ | defined as : g1 * c0^-1 * g1 |
[in] | g3_ | defined as : g1 * (c0^-1 * g1)^2 |
[in] | M0_ | diagonalised mass matrix time. |
[in] | M1_ | diagonal matrix with diag(0.5, 0, ..., 0, 0.5) -> account for boundary |
[in] | M2_ | stiffness matrix time. |
void PostTheta::check_pos_def | ( | MatrixXd & | hess | ) |
check if Hessian positive definite (matrix assumed to be dense & small since dim(theta) small)
[in,out] | updates | hessian to only the diagonal entries if not positive definite. |
double PostTheta::cond_LogPoisLik | ( | Vect & | eta | ) |
evaluate log Poisson likelihood
[in] | eta | Vector. linear predictor eta = A*x |
[out] | f_val | double. evaluated log density |
double PostTheta::cond_LogPriorLat | ( | SpMat & | Qprior, |
Vect & | x | ||
) |
evaluate Gaussian log prior (without log determinant!!), mean assumed to be zero
[in] | Qprior | precision matrix |
[in] | x | current x vector |
[out] | f_val | evaluated log density |
double PostTheta::cond_negLogBinom | ( | SpMat & | Qprior, |
Vect & | x | ||
) |
evaluate negative condiational log Poisson + Gaussian prior
[in] | extraCoeffVecLik | Vector. ntrials. |
[in] | Qprior | SpMat. precision matrix. |
[in] | x | Vector. current vector x. |
[out] | f_val | double. evaluated negative log density |
double PostTheta::cond_negLogBinomLik | ( | Vect & | eta | ) |
evaluate negative log Binomial likelihood
[in] | extraCoeffVecLik | Vector. ntrials. |
[in] | eta | Vector. linear predictor eta = A*x. |
[out] | f_val | double. evaluated negative log density. |
double PostTheta::cond_negLogDist | ( | SpMat & | Qprior, |
Vect & | x, | ||
function< double(Vect &, Vect &)> | lik_func | ||
) |
evaluate negative condiational log likelihood + Gaussian prior
[in] | extraCoeffVecLik | Vector. |
[in] | Qprior | SpMat. precision matrix. |
[in] | x | Vector. current vector x. |
[in] | lik_func | function. defines the likelihood |
[out] | f_val | double. evaluated negative log density |
double PostTheta::cond_negLogPois | ( | SpMat & | Qprior, |
Vect & | x | ||
) |
evaluate negative condiational log Poisson + Gaussian prior
[in] | Qprior | SpMat. precision matrix. |
[in] | x | Vector. current vector x. |
[out] | f_val | double. evaluated negative log density |
double PostTheta::cond_negLogPoisLik | ( | Vect & | eta | ) |
evaluate negative log Poisson likelihood
[in] | eta | Vector. linear predictor eta = A*x |
[out] | f_val | double. evaluated negative log density |
void PostTheta::construct_b | ( | Vect & | theta, |
Vect & | rhs | ||
) |
Assemble right-handside.
[in] | theta | current theta vector |
[in,out] | rhs | right-handside /todo Could compute Ax^T*y once, and only multiply with appropriate exp_theta. |
void PostTheta::construct_Q | ( | Vect & | theta, |
Vect & | mu, | ||
SpMat & | Q | ||
) |
construct precision matrix. Calls spatial, spatial-temporal, etc.
[in] | theta | current theta vector |
[in] | mu | mode latent parameters |
[in,out] | Q | fills precision matrix |
void PostTheta::construct_Q_spat_temp | ( | Vect & | theta, |
SpMat & | Qst | ||
) |
spatial temporal model : SPDE discretisation. DEMF(1,2,1) model.
[in] | theta | current theta vector |
[in,out] | Qst | fills spatial-temporal precision matrix |
void PostTheta::construct_Q_spatial | ( | Vect & | theta, |
SpMat & | Qs | ||
) |
spatial model : SPDE discretisation – matrix construction
[in] | theta | current theta vector |
[in,out] | Qs | fills spatial precision matrix |
void PostTheta::convert_interpret2theta_spat | ( | double | lranS, |
double | lsigU, | ||
double & | lgamS, | ||
double & | lgamE | ||
) |
convert hyperparameters theta from the interpretable parametrisation to the model parametrisation ie. from log(rangeS, sigma.u) to log(gamma_s, gamma_E) for spatial model order 2
[in] | log(ranS) | spatial range |
[in] | log(sigma.u) | precision of random effects |
[in,out] | log(gamma_s) | |
[in,out] | log(gamma_E) |
void PostTheta::convert_interpret2theta_spatTemp | ( | double | sigU, |
double | ranS, | ||
double | ranT, | ||
double & | lgamE, | ||
double & | lgamS, | ||
double & | lgamT | ||
) |
convert hyperparameters theta from the interpretable parametrisation to the model parametrisation ie. from log(sigma.u, rangeS, rangeT) to log(gamma_E, gamma_s, gamma_t)
[in] | log(sigma.u) | precision of random effects |
[in] | log(ranS) | spatial range |
[in] | log(ranT) | temporal range |
[in,out] | log(gamma_E) | |
[in,out] | log(gamma_s) | |
[in,out] | log(gamma_t) |
void PostTheta::convert_theta2interpret_spat | ( | double | lgamS, |
double | lgamE, | ||
double & | lranS, | ||
double & | lsigU | ||
) |
convert hyperparameters theta from the interpretable parametrisation to the model parametrisation ie. from log(rangeS, sigma.u) to log(gamma_s, gamma_E) for spatial model order 2
[in] | log(gamma_s) | |
[in] | log(gamma_E) | |
[in,out] | log(ranS) | spatial range |
[in,out] | log(sigma.u) | precision of random effects |
void PostTheta::convert_theta2interpret_spatTemp | ( | double | lgamE, |
double | lgamS, | ||
double | lgamT, | ||
double & | sigU, | ||
double & | ranS, | ||
double & | ranT | ||
) |
convert hyperparameters theta from the model parametrisation to the interpretable parametrisation ie. from log(gamma_E, gamma_s, gamma_t) to log(sigma.u, rangeS, rangeT)
[in] | log(gamma_E) | |
[in] | log(gamma_s) | |
[in] | log(gamma_t) | |
[in,out] | log(sigma.u) | precision of random effects |
[in,out] | log(ranS) | spatial range |
[in,out] | log(ranT) | temporal range |
Vect PostTheta::diagHess_cond_negLogPoisLik | ( | Vect & | eta | ) |
evaluate analytical negative diagonal Hessian of log Poisson likelihood
[in] | eta | Vector. linear predictor eta = A*x |
[out] | diagHess | Vect. diagonal of Hessian (off-diagonal entries are zero) |
void PostTheta::eval_denominator | ( | Vect & | theta, |
double & | val, | ||
SpMat & | Q, | ||
Vect & | rhs, | ||
Vect & | mu | ||
) |
Evaluate denominator: conditional probability of Qx|y.
[in] | theta | current theta vector |
[in,out] | log_det | fill log determinant of conditional distribution of denominator |
[in,out] | val | fill value with mu*Q*mu |
[in,out] | Q | construct precision matrix |
[in,out] | rhs | construct right-handside |
[in,out] | mu | insert mean of latent parameters |
void PostTheta::eval_likelihood | ( | Vect & | theta, |
Vect & | mu, | ||
double & | log_det, | ||
double & | val | ||
) |
compute log likelihood : log_det tau*no and value -theta*yTy
[in] | theta | current theta vector |
[in,out] | log_det | inserts log determinant of log likelihood. |
[in,out] | val | inserts the value of -theta*yTy |
void PostTheta::eval_log_gaussian_prior_hp | ( | Vect & | theta_param, |
Vect & | theta_prior_param, | ||
double & | log_prior | ||
) |
evaluate log prior of the hyperparameters using original theta value
[in] | thetai | current theta_i value |
[in] | thetai_original | original theta_i value |
[in,out] | log | prior is being updated. |
variance / precision of 1 : no normalising constant. computed through -0.5 * (theta_i* - theta_i)*(theta_i*-theta_i)
void PostTheta::eval_log_pc_prior_hp | ( | double & | log_sum, |
Vect & | lambda, | ||
Vect & | theta_interpret | ||
) |
evaluate log prior using PC prior
[in,out] | log | sum |
[in] | lambda | : parameters for penalised complexity prior |
[in] | theta_interpret | current theta value in interpretable scale |
complicated prior. check appropriate references for details.
void PostTheta::eval_log_prior_lat | ( | Vect & | theta, |
Vect & | mu, | ||
double & | val | ||
) |
evaluate log prior of random effects
[in] | theta | current theta vector |
[in,out] | log_det | inserts log determinant. |
double PostTheta::eval_post_theta | ( | Vect & | theta, |
Vect & | mu | ||
) |
Core function. Evaluate posterior of theta. mu are latent parameters.
[in] | theta | hyperparameter vector |
[in,out] | mu | vector of the conditional mean |
void PostTheta::FD_diag_hessian | ( | Vect & | eta, |
Vect & | diag_hess | ||
) |
compute finite difference diagonal of hessian. 2nd order central difference. currently stepsize h fixed.
[in] | extraCoeffVecLik | Vector. |
[in] | eta | Vector. linear predictor eta = A*x. |
[in] | lik_func | function. defines the likelihood |
[in,out] | diag_hess | Vector. diagonal of Hessian. |
void PostTheta::FD_gradient | ( | Vect & | eta, |
Vect & | grad | ||
) |
compute finite difference gradient. 1st order central difference. currently stepsize h fixed.
[in] | extraCoeffVecLik | Vector. |
[in] | eta | Vector. linear predictor eta = A*x. |
[in] | lik_func | function. defines the likelihood |
[in,out] | grad | Vector. gradient. |
MatrixXd PostTheta::get_Covariance | ( | Vect | theta, |
double | eps | ||
) |
Compute Covariance matrix of hyperparameters theta, at theta.
computes the hessian of f(theta) using a second order finite difference stencil and then inverts the hessian. Gaussian assumption.
[in] | theta | hyperparameter Vector |
void PostTheta::get_fullFact_marginals_f | ( | Vect & | theta, |
SpMat & | Qinv | ||
) |
Compute the marginal variances of the latent parameters at theta. Using selected inversion procedure.
[in] | Vector | theta. |
[in,out] | Vector | with selected inverse for all non-zero entries of Q. |
Vect PostTheta::get_grad | ( | ) |
returns current gradient of theta.
void PostTheta::get_marginals_f | ( | Vect & | theta, |
Vect & | mu, | ||
Vect & | vars | ||
) |
Compute the marginal variances of the latent parameters at theta. Using selected inversion procedure.
[in] | Vector | theta. |
[in,out] | Vector | with marginals of f. |
void PostTheta::get_mu | ( | Vect & | theta, |
Vect & | mu_ | ||
) |
get conditional mean mu for theta – Gaussian case.
[in] | theta | hyperparameter vector |
[in,out] | mu_ | vector of the conditional mean |
Vect PostTheta::grad_cond_negLogPoisLik | ( | Vect & | eta | ) |
evaluate analytical negative gradient log Poisson likelihood
[in] | eta | Vector. linear predictor eta = A*x |
[out] | grad | Vect. gradient. |
MatrixXd PostTheta::hess_eval | ( | Vect | theta, |
double | eps | ||
) |
computes the hessian at theta using second order finite difference. Is used be get_Covariance.
[in] | theta | hyperparameter vector |
void PostTheta::link_f_sigmoid | ( | Vect & | x, |
Vect & | sigmoidX | ||
) |
link function. vectorized evaluation of sigmoid function for each entry
[in] | x | Vector. current vector x. |
[in,out] | sigmoidX | Vector. sigmoid(x) element-wise. |
void PostTheta::NewtonIter | ( | Vect & | theta, |
Vect & | x, | ||
SpMat & | Q, | ||
double & | log_det | ||
) |
Newton iteration to find optimum of conditional distribution latent parameters of prior & likelihood.
[in] | theta | hyperparameters. can be an empty vector. |
[in,out] | x | latent parameters. contains initial guess of mode on entry and found mode on exit. |
[in,out] | Q | SpMat. precision matrix. |
[in,out] | x | log det of Q. |
double PostTheta::operator() | ( | Vect & | theta, |
Vect & | grad | ||
) |
structure required by BFGS solver, requires : theta, gradient theta
|
private |
sparse matrix of size no x (nu+nb). Projects observation locations onto FEM mesh and includes covariates at the end.
|
private |
conmpute t(Ax)*Ax once. spat/spat temp model
|
private |
compute t(Ax)*y once. spat/spat temp model
|
private |
if space (-time) model included in last columns of Ax. For regression only B exists.
|
private |
compute t(B)*y once. regression model only
|
private |
Diagonal mass matrix spatial part.
|
private |
true if there is a sum to zero constraint
|
private |
dimension of gradient loop
|
private |
dimension of hyperparameter vector theta
|
private |
constraint vector, sum to zero constraint
|
private |
constraint vector, sum to zero constraint
|
private |
count total number of function evaluations
|
private |
orthonormal basis for finite difference stencil is Identity if smart gradient disabled
|
private |
stiffness matrix space.
|
private |
defined as : g1 * c0^-1 * g1
|
private |
defined as : g1 * (c0^-1 * g1)^2.
|
private |
count total number of operator() call
|
private |
assumed likelihood of the observations
|
private |
diagonalised mass matrix time.
|
private |
diagonal matrix with diag(0.5, 0, ..., 0, 0.5) -> account for boundary
|
private |
stiffness matrix time.
|
private |
in R^d or on the sphere
|
private |
minimum of function
|
private |
personal mpi rank
|
private |
number of mpi ranks
|
private |
conditional mean
|
private |
store all mu values from previous iteration, dim(mu_matrix) = (n, 2*dim_th+1)
|
private |
conditional mean, at mid point \theta^k
|
private |
total number of unknowns, i.e. ns*nt + nb
|
private |
number of fixed effects
|
private |
number of observations
|
private |
number of function evaluations per iteration
|
private |
number of spatial grid points per timestep
|
private |
size of add. spatial field, not def = 0
|
private |
ns*nt, equal to nu if nss =0
|
private |
number of temporal time steps
|
private |
number of random effects, that ns*nu
|
private |
number of pardiso solvers
|
private |
type of pripr to be used
|
private |
setup indices once. Only prior fixed effects.
|
private |
setup indices once. Only prior random effects
|
private |
setup indices once. Includes Prior RE + FE.
|
private |
setup indices for Qxy once.
|
private |
gradient of theta
|
private |
vector with prior values. Constructs normal distribution with sd = 1 around these values.
|
private |
number of threads on first level
|
private |
only used if validate is true
|
private |
vector of observations y. has length no.
|
private |
compute t(y)*y once.