Description Usage Arguments Value Details and user-defined distance function Examples
View source: R/estimate_state_adj_matrix.R
This function estimates the adjacency matrix \mathbf{A} of all pairwise equivalent FLC distributions given the states s_1, …, s_K. See Details below.
1 2 |
states |
vector of length N with entry i being the label k = 1, …, K of PLC i |
FLCs |
N \times n_f matrix of FLCs (only
necessary if |
pdfs.FLC |
N \times K matrix of all K
state-conditional FLC densities evaluated at each FLC
\ell^{+}_i, i=1, …, N (only necessary if
|
alpha |
significance level for testing. Default:
|
distance |
either a Kolmogorov-Smirnov test
( Default: |
A K \times K adjacency matrix with a trimmed
version of exp(-distance) or p-values. If
alpha!=NULL
then it returns the thresholded
0/1 matrix. However, here 1 stands for
equivalent, i.e. not rejecting. The matrix is obtained by
checking for pval>alpha
(rather than the usual
pval<alpha
).
The (i,j)th element of the adjacency matrix is defined as
\mathbf{A}_{ij} = distance(P(X \mid s_i), P(X \mid s_j)) = distance(f, g),
where
distance
is either
in the function space of pdfs f and g, or
for H_0: f=g, e.g. a
Kolmogorov-Smirnov test (distance="KS"
).
Again we use a functional programming approach and allow
the user to specify any valid distance/similarity
function distance = function(f, g) return(...)
.
If distance="KS"
the adjacency matrix contains
p-values of a Kolmogorov-Smirnov test or the thresholded
versions (if alpha!=NULL
) - see Return for
details.
Otherwise distance
is an R function that takes as
an input two vectors f
and g
(e.g. the
wKDE
estimates for two states), and returns
a non-negative, real number to estimate their distance.
Default is the L_1 distance distance =
function(f, g) return(mean(abs(f-g)))
.
1 2 3 4 5 6 7 8 9 10 11 | WW <- matrix(runif(10000), ncol = 10)
WW <- normalize(WW)
temp_flcs <- cbind(rnorm(nrow(WW)))
temp_pdfs.FLC <- estimate_LC_pdfs(temp_flcs, WW)
AA_ks <- estimate_state_adj_matrix(states = weight_matrix2states(WW), FLCs = temp_flcs,
distance = "KS")
AA_L1 <- estimate_state_adj_matrix(pdfs.FLC = temp_pdfs.FLC)
par(mfrow = c(1, 2), mar = c(1, 1, 2, 1))
image2(AA_ks, zlim = c(0, 1), legend = FALSE, main = "Kolmogorov-Smirnov")
image2(AA_L1, legend = FALSE, main = "L1 distance")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.