Learn R Programming

aghq (version 0.4.1)

summary.aghq: Summary statistics computed using AGHQ

Description

The summary.aghq method computes means, standard deviations, and quantiles of the transformed parameter. The associated print method prints these along with diagnostic and other information about the quadrature.

Usage

# S3 method for aghq
summary(object, ...)

Value

A list of class aghqsummary, which has a print method. Elements:

  • mode: the mode of the log posterior

  • hessian: the hessian of the log posterior at the mode

  • covariance: the inverse of the hessian of the log posterior at the mode

  • cholesky: the upper Cholesky triangle of the hessian of the log posterior at the mode

  • quadpoints: the number of quadrature points used in each dimension

  • dim: the dimension of the parameter space

  • summarytable: a table containing the mean, median, mode, standard deviation and quantiles of each transformed parameter, computed according to the posterior normalized using AGHQ

Arguments

object

The return value from aghq::aghq. Summaries are computed for object$transformation$fromtheta(theta).

...

not used.

See Also

Other quadrature: aghq(), get_hessian(), get_log_normconst(), get_mode(), get_nodesandweights(), get_numquadpoints(), get_opt_results(), get_param_dim(), laplace_approximation(), marginal_laplace_tmb(), marginal_laplace(), nested_quadrature(), normalize_logpost(), optimize_theta(), plot.aghq(), print.aghqsummary(), print.aghq(), print.laplacesummary(), print.laplace(), print.marginallaplacesummary(), summary.laplace(), summary.marginallaplace()

Examples

Run this code

logfteta2d <- function(eta,y) {
  # eta is now (eta1,eta2)
  # y is now (y1,y2)
  n <- length(y)
  n1 <- ceiling(n/2)
  n2 <- floor(n/2)
  y1 <- y[1:n1]
  y2 <- y[(n1+1):(n1+n2)]
  eta1 <- eta[1]
  eta2 <- eta[2]
  sum(y1) * eta1 - (length(y1) + 1) * exp(eta1) - sum(lgamma(y1+1)) + eta1 +
    sum(y2) * eta2 - (length(y2) + 1) * exp(eta2) - sum(lgamma(y2+1)) + eta2
}
set.seed(84343124)
n1 <- 5
n2 <- 5
n <- n1+n2
y1 <- rpois(n1,5)
y2 <- rpois(n2,5)
objfunc2d <- function(x) logfteta2d(x,c(y1,y2))
funlist2d <- list(
  fn = objfunc2d,
  gr = function(x) numDeriv::grad(objfunc2d,x),
  he = function(x) numDeriv::hessian(objfunc2d,x)
)

thequadrature <- aghq(funlist2d,3,c(0,0))
# Summarize and automatically call its print() method when called interactively:
summary(thequadrature)
# or, compute the summary and save for further processing:
ss <- summary(thequadrature)
str(ss)

Run the code above in your browser using DataLab