generalized_wishart: Generalized Wishart distance regression

Description Usage Arguments Details Value References See Also Examples

View source: R/generalized_wishart.R

Description

A function of class measurement_model that calculates likelihood, gradient, hessian, and partial derivatives of nuisance parameters and the Laplacian generalized inverse, using the generalized Wishart model described in McCullagh (2009), Peterson et al (2019).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
generalized_wishart(
  E,
  S,
  phi,
  nu,
  gradient = TRUE,
  hessian = TRUE,
  partial = TRUE,
  nonnegative = TRUE,
  validate = FALSE
)

Arguments

E

A submatrix of the generalized inverse of the graph Laplacian (e.g. a covariance matrix)

S

A matrix of observed genetic distances

phi

Nuisance parameters (see details)

nu

Number of genetic markers

gradient

Compute gradient of negative loglikelihood with regard to phi?

hessian

Compute Hessian matrix of negative loglikelihood with regard to phi?

partial

Compute second partial derivatives of negative loglikelihood with regard to phi, E, S?

nonnegative

Unused

validate

Numerical validation via package numDeriv (very slow, use for debugging small examples)

Details

The nuisance parameters are the scaling of the generalized inverse of the graph Laplacian ("tau"; can be zero) and a log scalar multiple of the identity matrix that is added to the generalized inverse ("sigma").

TODO: formula

Value

A list containing:

covariance

rows/columns of the generalized inverse of the graph Laplacian for a subset of target vertices

objective

(if objective) the negative loglikelihood

fitted

((if objective) a matrix of expected genetic distances among target vertices

boundary

(if objective) is the MLE on the boundary (e.g. no genetic structure)?

gradient

(if gradient) gradient of negative loglikelihood with respect to phi

hessian

(if hessian) Hessian matrix of the negative loglikelihood with respect to phi

gradient_E

(if partial) gradient with respect to the generalized inverse of the graph Laplacian

partial_E

(if partial) Jacobian of gradient_E with respect to phi

partial_S

(if partial) Jacobian of gradient with respect to S

jacobian_E

(if partial) a function used for reverse algorithmic differentiation

jacobian_S

(if partial) a function used for reverse algorithmic differentiation

References

McCullagh P. 2009. Marginal likelihood for distance matrices. Statistica Sinica 19 Peterson et al. 2019. TODO

See Also

radish_measurement_model

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(raster)

data(melip)

covariates <- raster::stack(list(altitude=melip.altitude, forestcover=melip.forestcover))
surface <- conductance_surface(covariates, melip.coords, directions = 8)

# inverse of graph Laplacian at null model (IBD) 
laplacian_inv <- radish_distance(theta = matrix(0, 1, 2), 
                                 formula = ~forestcover + altitude,
                                 data = surface,
                                 radish::loglinear_conductance, 
                                 covariance = TRUE)$covariance[,,1]

generalized_wishart(laplacian_inv, melip.Fst, nu = 1000, phi = c(0.1, -0.1))

nspope/radish documentation built on July 12, 2020, 11:50 a.m.