Title: | Computing Expectations and Marginal Likelihoods for Permutations |
---|---|
Description: | A set of functions for computing expected permutation matrices given a matrix of likelihoods for each individual assignment. It has been written to accompany the forthcoming paper 'Computing expectations and marginal likelihoods for permutations'. Publication details will be updated as soon as they are finalized. |
Authors: | Ben Powell |
Maintainer: | Ben Powell <[email protected]> |
License: | GPL-3 |
Version: | 1.6 |
Built: | 2025-01-20 06:33:50 UTC |
Source: | CRAN |
A set of functions for computing expected permutation matrices given a matrix of likelihoods for each individual assignment. It has been written to accompany the forthcoming paper 'Computing expectations and marginal likelihoods for permutations'. Publication details will be updated as soon as they are finalized.
The DESCRIPTION file:
Package: | expperm |
Type: | Package |
Title: | Computing Expectations and Marginal Likelihoods for Permutations |
Version: | 1.6 |
Date: | 2019-05-23 |
Author: | Ben Powell |
Maintainer: | Ben Powell <[email protected]> |
Description: | A set of functions for computing expected permutation matrices given a matrix of likelihoods for each individual assignment. It has been written to accompany the forthcoming paper 'Computing expectations and marginal likelihoods for permutations'. Publication details will be updated as soon as they are finalized. |
License: | GPL-3 |
Depends: | R (>= 2.10) |
Imports: | Rcpp (>= 1.0.1) |
LinkingTo: | Rcpp |
LazyData: | true |
RoxygenNote: | 6.1.1 |
Suggests: | testthat |
NeedsCompilation: | yes |
Packaged: | 2019-05-28 17:26:38 UTC; ben |
Repository: | CRAN |
Date/Publication: | 2019-05-28 21:03:06 UTC |
Index of help topics:
A A small random matrix BG The Brualdi-Gibson method for computing an expected permutation matrix BG_cpp The Brualdi-Gibson method for computing an expected permutation matrix using C++ brute Brute-force calculation of an expected permutation matrix brute_cpp Brute-force calculation of an expected permutation matrix using C++ df1 A small data frame of simulated records df2 A (second) small data frame of simulated records expperm-package Computing Expectations and Marginal Likelihoods for Permutations is.tridiagonal Checking a matrix is tridiagonal ryser The Ryser method for computing an expected permutation matrix ryser_cpp The Ryser method for computing an expected permutation matrix using C++ sink A variational approximation of an expected permutation matrix sink_cpp A variational approximation of an expected permutation matrix using C++ triA A small random tridiagonal matrix
The package serves primarily to demonstrate the algorithms described in the accompanying paper, which is currently under review.
We include versions, which are as similar as reasonably possible, of algorithms written in both R and C++. The R code is intended to facilitate testing, modification and re-use of the code while the C++ code is intended to implement the algorithms most efficiently for application to real problems.
Ben Powell
Maintainer: Ben Powell <[email protected]>
Powell B., Smith P.A. (2019). "Computing expectations and marginal likelihoods for permutations." (In Submission).
A small random matrix used only to demonstrate the package's algorithms in the examples
sections of the package documentation.
A
A
An object of class matrix
with 7 rows and 7 columns.
Computes the expected permutation matrix and marginal likelihood from a tridiagonal matrix of assignment likelihoods using the Brualdi-Gibson method.
BG(A, return.permanent = FALSE)
BG(A, return.permanent = FALSE)
A |
A tridiagonal matrix of assignment likelihoods. |
return.permanent |
A logical value indicating whether the function should also return the permanent of |
E(P)
, the expected permutation matrix corresponding to A
.
data(triA) BG(triA)
data(triA) BG(triA)
Computes the expected permutation matrix and marginal likelihood from a tridiagonal matrix of assignment likelihoods using the Brualdi-Gibson method.
BG_cpp(A)
BG_cpp(A)
A |
A tridiagonal matrix of assignment likelihoods. |
E(P)
, the expected permutation matrix corresponding to A
.
data(triA) BG_cpp(triA)
data(triA) BG_cpp(triA)
Computes an expected permutation matrix and marginal likelihood from a matrix of assignment likelihoods. The function literally enumerates all permutations so will be impractial for matrices with more than 10 rows.
brute(A, return.permanent = FALSE)
brute(A, return.permanent = FALSE)
A |
A matrix of assignment likelihoods. |
return.permanent |
A logical value indicating whether the function should also return the permanent of |
E(P)
, the expected permutation matrix corresponding to A
.
data(A) brute(A)
data(A) brute(A)
Computes an expected permutation matrix and marginal likelihood from a matrix of assignment likelihoods. The function literally enumerates all permutations so will be impractial for matrices with more than 10 rows.
brute_cpp(A)
brute_cpp(A)
A |
A matrix of assignment likelihoods. |
E(P)
, the expected permutation matrix corresponding to A
.
data(A) brute_cpp(A)
data(A) brute_cpp(A)
A small data frame of simulated records as might be found in a population census. This data is used to demonstrate the package's algorithms in a more realistic setting. It also allows for reproduction of the example towards the end of the paper that accompanies this package. The data is a subset of a larger set simulated by of P. McLeod, R. Heasman and I. Forbes of the UK's Office for National Statistics. At the time of publication this data is available at https://ec.europa.eu/eurostat/cros/content/job-training_en. The example below shows how we could compute a distance matrix for the records in dataframes df1
and df2
.
df1
df1
An object of class tbl_df
(inherits from tbl
, data.frame
) with 18 rows and 3 columns.
## Not run: library(stringdist) D<-matrix(,n,n) for(i in 1:n){for(j in 1:n){ D[i,j]<-stringdist(df1$PERNAME1[i],df2$PERNAME1[j]) + stringdist(df1$PERNAME2[i],df2$PERNAME2[j],method="dl") + stringdist(df1$DOB_YEAR[i],df2$DOB_Y#' EAR[j],method="dl") }} ## End(Not run)
## Not run: library(stringdist) D<-matrix(,n,n) for(i in 1:n){for(j in 1:n){ D[i,j]<-stringdist(df1$PERNAME1[i],df2$PERNAME1[j]) + stringdist(df1$PERNAME2[i],df2$PERNAME2[j],method="dl") + stringdist(df1$DOB_YEAR[i],df2$DOB_Y#' EAR[j],method="dl") }} ## End(Not run)
A small data frame of simulated records as might be found in a population census. This data is used to demonstrate the package's algorithms in a more realistic setting. It also allows for reproduction of the example towards the end of the paper that accompanies this package. The data is a subset of a larger set simulated by of P. McLeod, R. Heasman and I. Forbes of the UK's Office for National Statistics. At the time of publication this data is available at https://ec.europa.eu/eurostat/cros/content/job-training_en.
df2
df2
An object of class tbl_df
(inherits from tbl
, data.frame
) with 18 rows and 3 columns.
A function for checking whether a matrix is tridiagonal. The check is used before attempting to apply the BG method for computing the permanent, since the method is only applicable to tridiagonal matrices.
is.tridiagonal(A)
is.tridiagonal(A)
A |
A matrix. |
A logical variable. TRUE
if the A
is tridiagonal, FALSE
otherwise.
data(A) is.tridiagonal(A) data(triA) is.tridiagonal(triA)
data(A) is.tridiagonal(A) data(triA) is.tridiagonal(triA)
Computes the expected permutation matrix and marginal likelihood from a matrix of assignment likelihoods using the Ryser method.
ryser(A, return.permanent = FALSE)
ryser(A, return.permanent = FALSE)
A |
A matrix of assignment likelihoods. |
return.permanent |
A logical value indicating whether the function should also return the permanent of |
E(P)
, the expected permutation matrix corresponding to A
.
data(A) ryser(A)
data(A) ryser(A)
Computes the expected permutation matrix and marginal likelihood from a matrix of assignment likelihoods using the Ryser algorithm.
ryser_cpp(A)
ryser_cpp(A)
A |
A matrix of assignment likelihoods. |
E(P)
, the expected permutation matrix corresponding to A
.
data(A) ryser_cpp(A)
data(A) ryser_cpp(A)
Computes an approximate expected permutation matrix and marginal likelihood from a matrix of assignment likelihoods. The approximation minimizes a constrained KL divergence from the likelihood, and is computed via the repeated renormalization of the input's rows and columns.
sink(A, maxit = 99, return.permanent.bound = FALSE)
sink(A, maxit = 99, return.permanent.bound = FALSE)
A |
A matrix of assignment likelihoods. |
maxit |
An integer specifying the maximum number of steps used in the optimization. |
return.permanent.bound |
A logical value indicating whether the function should also return an upper bound on the permanent of |
E(P)
, the expected permutation matrix corresponding to A
.
data(A) sink(A)
data(A) sink(A)
Computes an approximate expected permutation matrix and marginal likelihood from a matrix of assignment likelihoods. The approximation minimizes a constrained KL divergence from the likelihood, and is computed via the repeated renormalization of the input's rows and columns.
sink_cpp(A, maxit = 99)
sink_cpp(A, maxit = 99)
A |
A matrix of assignment likelihoods. |
maxit |
An integer specifying the maximum number of steps used in the optimization. |
E(P)
, the expected permutation matrix corresponding to A
.
data(A) sink_cpp(A)
data(A) sink_cpp(A)
A small random tridiagonal matrix used only to demonstrate the package's algorithms in the examples
sections of the package documentation.
triA
triA
An object of class matrix
with 7 rows and 7 columns.