Description Usage Arguments Details Value Author(s) References Examples
View source: R/find-weiszfeld-median.R
Find M-posterior given list of samples from subset posteriors using Weiszfeld algorithm of Minsker et al. (2014).
1 2 | findWeiszfeldMedian(subsetAtomsList, sigma = 0.1, maxit = 100,
tol = 1e-10)
|
subsetAtomsList |
list of samples from subset posteriors; each element of the list must be a matrix |
sigma |
parameter of RBF kernel with form exp(- sigma || x - y ||^2) |
maxit |
maximum number of iterations estimating M-posterior |
tol |
tolerance for declaring convergence of Weiszfeld algorithm |
Samples from subset posteriors are represented as matrices, with
the rows representing atoms and the columns indexing
dimensions. Length of subsetAtomsList
equals the number of
subsets (and posteriors). M-posterior estimates the weights of its
atoms given the atoms of subset posteriors using Weiszfeld algorithm
as implemented in findWeiszfeldMedian
; sigma
controls the
sensitivity of distance between subset posteriors.
list containing Weiszfeld wts of subset posteriors, M-posterior atoms, and the estimation set-up
Sanvesh Srivastava sanvesh@gmail.com
Minsker, S., Srivastava, S., Lin, L., and Dunson, D.B. (2014). Robust and Scalable Bayes via a Median of Subset Posterior Measures. http://arxiv.org/abs/1403.2660
1 2 3 4 5 6 7 8 9 10 11 12 13 | set.seed(12345)
## list that contains subset posterior samples from 2-dim Gaussian density
subAtomList <- vector("list", 5)
subAtomList[[1]] <- cbind(rnorm(100, mean = 1), rnorm(100, mean = 1))
subAtomList[[2]] <- cbind(rnorm(100, mean = -1), rnorm(100, mean= -1))
subAtomList[[3]] <- cbind(rnorm(100, mean = -1), rnorm(100, mean = 1))
subAtomList[[4]] <- cbind(rnorm(100, mean = 1), rnorm(100, mean = -1))
subAtomList[[5]] <- cbind(rnorm(100, mean = 2), rnorm(100, mean = 2))
library(Mposterior)
medPosterior <- findWeiszfeldMedian(subAtomList, sigma = 0.1, maxit = 100, tol = 1e-10)
medPosterior
summary(medPosterior)
plot(medPosterior)
|
Loading required package: Rcpp
##
## Mposterior: R package for Robust and Scalable Bayes via a Median of Subset Posterior Measures
## (Version 0.1.2, built: 2014-06-01)
## Copyright (C) 2013-2019 Sanvesh Srivastava
Weiszfeld iteration: 10
Weiszfeld iteration: 20
Weiszfeld iteration: 30
Weiszfeld iteration: 40
Weiszfeld algorithm coverged at iteration: 48
Subset posteriors:
Subset Natoms WeiszfeldWts
1 1 100 0.34
2 2 100 0.14
3 3 100 0.16
4 4 100 0.19
5 5 100 0.17
M-posterior has 2 dimensions
RBF kernel with sigma= 0.1
Weiszfeld algorithm converged in 48 iterations
Subset posteriors:
Subset Natoms WeiszfeldWts
1 1 100 0.34
2 2 100 0.14
3 3 100 0.16
4 4 100 0.19
5 5 100 0.17
M-posterior has 2 dimensions
RBF kernel with sigma = 0.1
Weiszfeld algorithm converged in 48 iterations
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.