double GHSW::log_transition_density( const Vector &new_state, const Vector &old_state, int old_time, const Vector ¶meters) const { ParameterHolder params(model_.get(), parameters); Vector scaled_change = model_->state_error_expander(old_time)->left_inverse( new_state - (*model_->state_transition_matrix(old_time)) * old_state); // The distribution of 'change' is RQR, which may be less than full rank. // The distribution of scaled_change is Q. // Deal with variances through the Cholesky decomposition, so that you // don't need to decompose twice (for inverse and log determinant of the // inverse). The log determinant of the inverse matrix is -1 times the // log determinant of the original. Cholesky variance_cholesky(model_->state_error_variance(old_time)->dense()); return dmvn_zero_mean(scaled_change, variance_cholesky.inv(), -variance_cholesky.logdet(), true); }
double ZMMM::pdf(Ptr<Data> dp, bool logscale)const{ Ptr<VectorData> dpp = DAT(dp); return dmvn_zero_mean(dpp->value(), siginv(), ldsi(), logscale); }