Title: | Binary Causality Inference Framework |
---|---|
Description: | A framework to infer causality on binary data using techniques in frequent pattern mining and estimation statistics. Given a set of individual vectors S={x} where x(i) is a realization value of binary variable i, the framework infers empirical causal relations of binary variables i,j from S in a form of causal graph G=(V,E) where V is a set of nodes representing binary variables and there is an edge from i to j in E if the variable i causes j. The framework determines dependency among variables as well as analyzing confounding factors before deciding whether i causes j. The publication of this package is at Chainarong Amornbunchornvej, Navaporn Surasvadi, Anon Plangprasopchok, and Suttipong Thajchayapong (2023) <doi:10.1016/j.heliyon.2023.e15947>. |
Authors: | Chainarong Amornbunchornvej [aut, cre]
|
Maintainer: | Chainarong Amornbunchornvej <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.4 |
Built: | 2025-02-03 04:54:33 UTC |
Source: | https://github.com/darkeyes/bicausality |
This function evaluates the P(Y=yflag|do(X=xflag)) given only marginal distributions using parent adjustment method.
adjustmentProb(EValHat, mat, yflag = 1, xflag = 1)
adjustmentProb(EValHat, mat, yflag = 1, xflag = 1)
EValHat |
is an adjacency matrix of weighted directed causal graph where edge weights are P(Y=yflag|X=xflag) or probabilities of effect being 1 given cause being either 1 for positive association or 0 for negative association. |
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
yflag |
is value set for Y in P(Y=yflag|X=xflag,z) for the adjustment method. |
xflag |
is value set for X in P(Y=yflag|X=xflag,z) for the adjustment method. |
This function returns an adjacency matrix of weighted directed causal graph where the edge weights are P(Y=yflag|do(X=xflag) ).
adjustmentProb(resC$CausalGRes$EValHat,mat)
adjustmentProb(resC$CausalGRes$EValHat,mat)
This function provides association signs (positive/negative association) inference between i and j. If there is a positive association, it implies i and j trend to have a similar value. For a negative association, however, i and j trend to have an opposite value.
assocSignTest(mat, i, j, z = c(), alpha = 0.05, IndpThs = 0.05, nboot = 100)
assocSignTest(mat, i, j, z = c(), alpha = 0.05, IndpThs = 0.05, nboot = 100)
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
i |
is an ith dimension in |
j |
is an jth dimension in |
z |
is a conditioning d-dimensional vector on |
alpha |
is a significance threshold for hypothesis tests (Mann Whitney) that deploys for testing degrees of dependency, association direction, and causal direction. The default is 0.5. |
IndpThs |
is a threshold for the degree of dependency. In the independence test, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
nboot |
is a number of bootstrap replicates for bootstrapping deployed to infer confidence intervals and distributions for hypothesis tests. The default is 100. |
This function returns results of inference of association signs (positive/negative association) between i and j.
bmean |
A mean of sign dependency degrees between variables i and j. |
confInv |
An |
testRes |
A Mann-Whitney hypothesis test result for an independence test between variables i and j. The null hypothesis is that the distributions of dependency degrees of i,j differ by a location shift of |
assocSignTest(mat=mat,i=1,j=2)
assocSignTest(mat=mat,i=1,j=2)
This function convertes a binary vector into its decimal value.
bin2dec(X)
bin2dec(X)
X |
is a binary vector where |
This function returns a decimal value of X
.
bin2dec(X=c(1,1,1,0))
bin2dec(X=c(1,1,1,0))
This function infers dependency for a pair of variables i,j with bootstrapping.
bIndpTest( mat, i, j, z = c(), alpha = 0.05, IndpThs = 0.05, nboot = 100, pflag = FALSE )
bIndpTest( mat, i, j, z = c(), alpha = 0.05, IndpThs = 0.05, nboot = 100, pflag = FALSE )
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
i |
is an ith dimension in |
j |
is an jth dimension in |
z |
is a conditioning d-dimensional vector on |
alpha |
is a significance threshold for hypothesis tests (Mann Whitney) that deploys for testing degrees of dependency, association direction, and causal direction. The default is 0.5. |
IndpThs |
is a threshold for the degree of dependency. In the independence test, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
nboot |
is a number of bootstrap replicates for bootstrapping deployed to infer confidence intervals and distributions for hypothesis tests. The default is 100. |
pflag |
is a flag for printing progress message (TRUE). The default is FALSE (no printing). |
This function returns results of dependency inference between i and j.
bmean |
A mean of dependency degrees between variables i and j. |
confInv |
An |
testRes |
A Mann-Whitney hypothesis test result for an independence test between variables i and j. The null hypothesis is that the distributions of dependency degrees of i,j differ by a location shift of |
bIndpTest(mat=mat,i=1,j=2)
bIndpTest(mat=mat,i=1,j=2)
This function infers a causal graph from a result of confounding factor filtering by bSCMdeConfoundingGraphFunc()
.
bSCMCausalGraphFunc(E1, Dboot, alpha = 0.05, SignThs = 0.05, CausalThs = 0.25)
bSCMCausalGraphFunc(E1, Dboot, alpha = 0.05, SignThs = 0.05, CausalThs = 0.25)
E1 |
is an adjacency matrix of undirected graph after filtering associations without true causal directions from any confounding factor. |
Dboot |
is a list of |
alpha |
is a significance threshold for hypothesis tests (Mann Whitney) that deploys for testing degrees of dependency, association direction, and causal direction. The default is 0.5. |
SignThs |
is a threshold for the degree of dependency for association direction inference. In the independence test of sign direction, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
CausalThs |
is a threshold for the degree of causal direction In the causal-direction test, to claim that any variables have causal relations, the degree of causal direction must greater than this value significantly. The default is 0.1. |
This function returns causal inference results from E1 matrix that is an output of bSCMdeConfoundingGraphFunc
.
Ehat |
An adjacency matrix of directed causal graph where |
EValHat |
An adjacency matrix of weighted directed causal graph where edge weights are estimated means of probabilities of effect being 1 given cause being either 1 for positive association or 0 for negative association using CondProb() and bootstrapping to estimate. |
i |
An index |
j |
An index |
causalInfo$'i , j'$CDirConfValInv
|
An |
causalInfo$'i , j'$CDirConfInv
|
An |
causalInfo$'i , j'$CDirmean
|
A mean-estimated-causal-direction degree of i cause j. |
causalInfo$'i , j'$testRes2
|
A Mann-Whitney hypothesis test result for existence of causal direction. The null hypothesis is that the distributions of causal-direction degrees of i,j differ by a location shift of |
causalInfo$'i , j'$testRes1
|
A Mann-Whitney hypothesis test result for existence of association by odd differences from |
causalInfo$'i , j'$sign
|
A direction of i,j association: 1 for positive, 0 for negative, and -1 for no association. |
causalInfo$'i , j'$SignConfInv
|
An |
causalInfo$'i , j'$Signmean
|
A mean of i,j odd difference from bootstrapping. |
bSCMCausalGraphFunc(resC$ConfoundRes$E1,resC$depRes$Dboot)
bSCMCausalGraphFunc(resC$ConfoundRes$E1,resC$depRes$Dboot)
This function removes any association/dependency of variables i,j that have any confounding factor k s.t. given k, i and j are independent.
bSCMdeConfoundingGraphFunc(dat, IndpThs = 0.05, alpha = 0.05)
bSCMdeConfoundingGraphFunc(dat, IndpThs = 0.05, alpha = 0.05)
dat |
is the result of inferring dependencies between all pairs of variables from |
IndpThs |
is a threshold for the degree of dependency. In the independence test, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
alpha |
is a significance threshold for hypothesis tests (Mann Whitney) that deploys for testing degrees of dependency, association direction, and causal direction. The default is 0.5. |
This function returns an adjacency matrix of dependencies that have no confounding factors.
E1 |
An adjacency matrix of undirected graph after filtering associations without true causal directions from any confounding factor. |
E2 |
A matrix of associations that have confounding factors where |
bSCMdeConfoundingGraphFunc(resC$depRes)
bSCMdeConfoundingGraphFunc(resC$depRes)
This function infers dependencies for all pairs of variables without bootstrapping.
bSCMDepndentGraphFastFunc(mat, IndpThs = 0.05)
bSCMDepndentGraphFastFunc(mat, IndpThs = 0.05)
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
IndpThs |
is a threshold for the degree of dependency. In the independence test, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
This function returns results of dependency inference among variables.
E0 |
An adjacency matrix of undirected graph where there is an edge between any pair of variables if they are dependent. |
E0raw |
A matrix of the degree of dependency of variable pairs. |
bSCMDepndentGraphFastFunc(mat)
bSCMDepndentGraphFastFunc(mat)
This function infers dependencies for all pairs of variables with bootstrapping.
bSCMDepndentGraphFunc( mat, nboot = 100, alpha = 0.05, IndpThs = 0.05, pflag = FALSE )
bSCMDepndentGraphFunc( mat, nboot = 100, alpha = 0.05, IndpThs = 0.05, pflag = FALSE )
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
nboot |
is a number of bootstrap replicates for bootstrapping deployed to infer confidence intervals and distributions for hypothesis tests. The default is 100. |
alpha |
is a significance threshold for hypothesis tests (Mann Whitney) that deploys for testing degrees of dependency, association direction, and causal direction. The default is 0.5. |
IndpThs |
is a threshold for the degree of dependency. In the independence test, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
pflag |
is a flag for printing progress message (TRUE). The default is FALSE (no printing). |
This function returns results of dependency inference among variables.
E0 |
An adjacency matrix of undirected graph where there is an edge between any pair of variables if they are dependent. |
E0pval |
A matrix of p-values from independence test of pairs of variables. |
E0mean |
A matrix of means of dependency degrees between variables. |
E0lowbound |
A matrix of lower bounds of dependency-degree confidence intervals between variables. |
depInfo$'i , j'$bmean
|
A mean of dependency degrees between variables i and j. |
depInfo$'i , j'$confInv
|
An |
depInfo$'i , j'$testRes
|
A Mann-Whitney hypothesis test result for an independence test between variables i and j. The null hypothesis is that the distributions of dependency degrees of i,j differ by a location shift of |
depInfo$'i , j'$indices
|
A pair of indices of i and j in a numeric vector. |
Dboot |
A list of |
bSCMDepndentGraphFunc(mat, nboot=50)
bSCMDepndentGraphFunc(mat, nboot=50)
A framework to infer causality on binary data using techniques in frequent pattern mining and estimation statistics. Given a set of individual vectors S={x} where x(i) is a realization value of binary variable i, the framework infers empirical causal relations of binary variables i,j from S in a form of causal graph G=(V,E) where V is a set of nodes representing binary variables and there is an edge from i to j in E if the variable i causes j. The framework determines dependency among variables as well as analyzing confounding factors before deciding whether i causes j.
Note that all statistics (e.g. means) and confidence intervals as well as hypothesis testing are inferred by bootstrapping.
CausalGraphInferMainFunc( mat, alpha = 0.05, nboot = 100, IndpThs = 0.05, CausalThs = 0.1 )
CausalGraphInferMainFunc( mat, alpha = 0.05, nboot = 100, IndpThs = 0.05, CausalThs = 0.1 )
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
alpha |
is a significance threshold for hypothesis tests (Mann Whitney) that deploys for testing degrees of dependency, association direction, and causal direction. The default is 0.5. |
nboot |
is a number of bootstrap replicates for bootstrapping deployed to infer confidence intervals and distributions for hypothesis tests. The default is 100. |
IndpThs |
is a threshold for the degree of dependency. In the independence test, to claim that any variables are dependent, the dependency degree must greater than this value significantly. The default is 0.05. |
CausalThs |
is a threshold for the degree of causal direction In the causal-direction test, to claim that any variables have causal relations, the degree of causal direction must greater than this value significantly. The default is 0.1. |
This function returns causal inference results. #TODO: provide list of results.
depRes |
The result of inferring dependencies between all pairs of variables. |
ConfoundRes |
The result of filtering associations without true causal directions from any confounding factor. |
CausalGRes |
The result of inferring causal directions between all pairs of dependent variables that have no confounding factors. |
depRes$E0 |
An adjacency matrix of undirected graph where there is an edge between any pair of variables if they are dependent. |
depRes$E0pval |
A matrix of p-values from independence test of pairs of variables. |
depRes$E0mean |
A matrix of means of dependency degrees between variables. |
depRes$E0lowbound |
A matrix of lower bounds of dependency-degree confidence intervals between variables. |
depRes$depInfo$'i , j'$bmean
|
A mean of dependency degrees between variables i and j. |
depRes$depInfo$'i , j'$confInv
|
An |
depRes$depInfo$'i , j'$testRes
|
A Mann-Whitney hypothesis test result for an independence test between variables i and j. The null hypothesis is that the distributions of dependency degrees of i,j differ by a location shift of |
depRes$depInfo$'i , j'$indices
|
A pair of indices of i and j in a numeric vector. |
depRes$Dboot |
A list of |
ConfoundRes$E1 |
An adjacency matrix of undirected graph after filtering associations without true causal directions from any confounding factor. |
ConfoundRes$E2 |
A matrix of associations that have confounding factors where |
CausalGRes$Ehat |
An adjacency matrix of directed causal graph where |
CausalGRes$EValHat |
An adjacency matrix of weighted directed causal graph where edge weights are estimated means of probabilities of effect being 1 given cause being either 1 for positive association or 0 for negative association using CondProb() and bootstrapping to estimate |
CausalGRes$causalInfo$'i , j'$CDirConfValInv
|
An |
CausalGRes$causalInfo$'i , j'$CDirConfInv
|
An |
CausalGRes$causalInfo$'i , j'$CDirmean
|
A mean-estimated-causal-direction degree of i cause j. |
CausalGRes$causalInfo$'i , j'$testRes2
|
A Mann-Whitney hypothesis test result for existence of causal direction. The null hypothesis is that the distributions of causal-direction degrees of i,j differ by a location shift of |
CausalGRes$causalInfo$'i , j'$testRes1
|
A Mann-Whitney hypothesis test result for existence of association by odd differences from |
CausalGRes$causalInfo$'i , j'$sign
|
A direction of i,j association: 1 for positive, 0 for negative, and -1 for no association. |
CausalGRes$causalInfo$'i , j'$SignConfInv
|
An |
CausalGRes$causalInfo$'i , j'$Signmean
|
A mean of i,j odd difference from bootstrapping. |
resC<-CausalGraphInferMainFunc(mat = mat, nboot =50)
resC<-CausalGraphInferMainFunc(mat = mat, nboot =50)
comparePredAdjMatrix2TrueAdjMat is a support function that can compare two adjacency matrices: ground-truth and inferred matrices.
comparePredAdjMatrix2TrueAdjMat(trueAdjMat, adjMat)
comparePredAdjMatrix2TrueAdjMat(trueAdjMat, adjMat)
trueAdjMat |
a ground-truth matrix. |
adjMat |
an inferred matrix. |
This function returns a list of precision prec
, recall rec
, and F1 score F1
of inferred vs. groundtruth matrices.
# Generate simulation data G<-matrix(FALSE,10,10) # groundtruth G[1,c(4,7,8,10)]<-TRUE G[2,c(5,7,9,10)]<-TRUE G[3,c(6,8,9,10)]<-TRUE comparePredAdjMatrix2TrueAdjMat(trueAdjMat=G,adjMat=G)
# Generate simulation data G<-matrix(FALSE,10,10) # groundtruth G[1,c(4,7,8,10)]<-TRUE G[2,c(5,7,9,10)]<-TRUE G[3,c(6,8,9,10)]<-TRUE comparePredAdjMatrix2TrueAdjMat(trueAdjMat=G,adjMat=G)
This function computes a confidence value of y
given c
or conf(y|z)
from an aligned list D
.
For anyy[i],z[j]
, their values are -1 by default.
The function computes the numbers of transactions
that satisfy the following conditions.
All transactions must have values at any k position equal to z[k]
for any z[k]
that is not -1.
Let count
be the number of these transactions in D
.
All transactions must have values at any k position equal to either z[k]
or y[k]
that is not -1. Let countTotal
be the number of these transactions in D
.
CondProb(D, y, z)
CondProb(D, y, z)
D |
is an aligned list of transactions that was converted from any matrix n by d |
y |
is a d-dimensional vector. |
z |
is a d-dimensional vector. |
This function returns the ratio condP=count/countTotal
, which is the confidence of y
given z
.
condP |
The confidence of |
nD |
The subset of |
count |
A number of transactions that have values at any position similar
to either |
countTotal |
A number of transactions in |
d=10 # dimensions of example vectors z<-numeric(d)-1 y<-numeric(d)-1 y[1]<-c(1) z[c(2,3)]<-c(1,1) CondProb(BiCausality::D,y=y,z=z)$condP # conf(inx1 is 1 |inx 2,3 are 1 ) y|z
d=10 # dimensions of example vectors z<-numeric(d)-1 y<-numeric(d)-1 y[1]<-c(1) z[c(2,3)]<-c(1,1) CondProb(BiCausality::D,y=y,z=z)$condP # conf(inx1 is 1 |inx 2,3 are 1 ) y|z
This function Computes a confidence network in data mining.
Given a set of n transactions or samples in mat
s.t. each transaction has d binary items.
The conf(mat[,j]=1|mat[,i]=1)
is a ratio of a number of samples in jth and ith dimensions that have values equal to
one divided by a number of samples in the ith dimension that has a value equal to one.
The confNetFunc computes the network where the nodes are dimensions and the edge weights are conf(mat[,j]=1|mat[,i]=1)
for any directed edge from i to j.
confNetFunc(mat, ths = 0.1)
confNetFunc(mat, ths = 0.1)
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
ths |
is a threshold parameter for cutting of the edge weights. There exists the directed edge from i to j if its edge weight if above or equal |
This function returns a binary adjacency matrix confNet
and the weighted adjacency matrix confValMat
.
confNet |
A binary adjacency matrix that has |
confValMat |
A weighted adjacency matrix where |
res<-confNetFunc(mat)
res<-confNetFunc(mat)
A dataset containing simulated data that is used for examples in the package.
The D
is an aligned list of transactions that was converted by using D<-VecAlignment(mat)
.
D
D
An aligned list of a matrix with 200 samples and 10 dimensions generated from Bernoulli distribution.
It is an aligned list of transactions that was converted from mat
.
getReachableNodes is a support function for inferring reachable nodes that have some directed path to a node targetNode
.
This function uses Breadth-first search (BFS) algorithm.
getReachableNodes(adjMat, targetNode)
getReachableNodes(adjMat, targetNode)
adjMat |
is an adjacency matrix of a directed graph of which its elements are binary: zero for no edge, and one for having an edge. |
targetNode |
is a node in a graph that we want to find a set of nodes that can reach this target node via some paths. |
This function returns a set of node IDs that have some directed path to a node targetNode
.
# Given an example of adjacency matrix A<-matrix(FALSE,5,5) A[2,1]<-TRUE A[c(3,4),2]<-TRUE A[5,3]<-TRUE # Get a set of reachable nodes of targetNode. followers<-getReachableNodes(adjMat=A,targetNode=1)
# Given an example of adjacency matrix A<-matrix(FALSE,5,5) A[2,1]<-TRUE A[c(3,4),2]<-TRUE A[5,3]<-TRUE # Get a set of reachable nodes of targetNode. followers<-getReachableNodes(adjMat=A,targetNode=1)
getTransitiveClosureMat is a support function for inferring a transitive-closure adjacency matrix.
getTransitiveClosureMat(adjMat)
getTransitiveClosureMat(adjMat)
adjMat |
is an adjacency matrix of a directed graph of which its elements are binary: zero for no edge, and one for having an edge. |
This function returns a transitive-closure adjacency matrix.
# Given an example of adjacency matrix A<-matrix(FALSE,5,5) A[2,1]<-TRUE A[c(3,4),2]<-TRUE A[5,3]<-TRUE # Get a set of reachable nodes of targetNode. trsClosureMat<-getTransitiveClosureMat(adjMat=A)
# Given an example of adjacency matrix A<-matrix(FALSE,5,5) A[2,1]<-TRUE A[c(3,4),2]<-TRUE A[5,3]<-TRUE # Get a set of reachable nodes of targetNode. trsClosureMat<-getTransitiveClosureMat(adjMat=A)
This function computes the degree of dependency between variables.
Let i and j be variables, if they are independent, then |p(i,j) -p(i)*p(j)| should be zero.
Given the samples in the n by d matrix mat
where n is a number of samples and d is a number of dimensions,
an aligned list of transactions D
is computed by
D<-VecAlignment(mat)
.
indpFunc(D, i, j, z = c())
indpFunc(D, i, j, z = c())
D |
is an aligned list of transactions that was converted from |
i |
is an ith dimension in |
j |
is an jth dimension in |
z |
is a conditioning d-dimensional vector on |
This function returns the degree of dependency between variables: zero implies both variables are independent, and non-zero value implies the degree of dependency (higher implies more dependent degree).
indpFunc(D,i=1,j=2)
indpFunc(D,i=1,j=2)
A dataset containing simulated data that is used for examples in the package.
The matrix mat
is generated by the following code.
seedN<-2022
n<-200
# 200 individuals
d<-10
# 10 variables
mat<-matrix(nrow=n,ncol=d)
# the input of framework
#Simulate binary data from Bernoulli distribution distribution where the probability of value being 1 is 0.5.
for(i in seq(n))
{ set.seed(seedN+i)
mat[i,] <- rbinom(n=d, size=1, prob=0.5) }
mat[,1]<-mat[,2] | mat[,3]
# 1 causes by 2 and 3
mat[,4] <-mat[,2] | mat[,5]
# 4 causes by 2 and 5
mat[,6] <- mat[,1] | mat[,4]
# 6 causes by 1 and 4
mat
mat
A matrix with 200 samples and 10 dimensions generated from Bernoulli distribution.
It is a 200 by 10 matrix where n is a number of transactions or samples and d is a number of dimensions.
...
Given a natural number and number of bits, the function provides an n-dimensional vector of bits that represents num
.
The ith bits of binary vector represents the ith bit of num
.
For example, if vec<-num2Bits(num=2,n=4)
, the first bit vec[1]
is 0 and the second bit vec[2]
is 1.
num2Bits(num, n = 32)
num2Bits(num, n = 32)
num |
is a natural number. |
n |
is a number of bits representing |
This function returns an n-dimensional vector of bits that represents num
.
num2Bits(num=10,n=4)
num2Bits(num=10,n=4)
Given the samples in the n by d matrix mat
where n is a number of samples and d is a number of dimensions.
This function computes an odd difference value of variables of ith and jth dimensions from
a given an aligned list of transactions D
(compute by D<-VecAlignment(mat)
).
oddDiffFunc(D, i, j, z = c())
oddDiffFunc(D, i, j, z = c())
D |
is an aligned list of transactions that was converted from |
i |
is an ith dimension in |
j |
is an jth dimension in |
z |
is a conditioning d-dimensional vector on |
This function returns an odd difference value of variables of ith and jth dimensions from D
.
oddDiffFunc(D,i=1,j=2)
oddDiffFunc(D,i=1,j=2)
Given the samples in the n by d matrix mat
where n is a number of samples and d is a number of dimensions.
This function computes an odd ratio value of variables of ith and jth dimensions from
a given an aligned list of transactions D
(compute by D<-VecAlignment(mat)
).
oddRatioFunc(D, i, j, z = c(), slack = 0.001)
oddRatioFunc(D, i, j, z = c(), slack = 0.001)
D |
is an aligned list of transactions that was converted from |
i |
is an ith dimension in |
j |
is an jth dimension in |
z |
is a conditioning d-dimensional vector on |
slack |
is a parameter to prevent the issue of division by zero. |
This function returns an odd ratio value of variables of ith and jth dimensions from D
.
oddRatioFunc(D,i=1,j=2)
oddRatioFunc(D,i=1,j=2)
A dataset containing a result of causal inference from simulated data that is used for examples in the package.
resC
resC
A result of causal inference using mat
as an input.
It is a result of causal inference using simData$mat as an input by running
resC<-BiCausality::CausalGraphInferMainFunc(mat = mat,CausalThs=0.1, nboot =50, IndpThs=0.05)
.
.
This function computes a support value from a matrix X
given a values
.
supp(X, values)
supp(X, values)
X |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions for each sample. |
values |
is a d-dimensional vector
we use to count how many of it within |
This function returns the support of values
in X
by counting
the ratio of how many samples in X
are similar to values
x <- rbinom(n=100, size=1, prob=0.5) ny<-rbinom(n=100, size=1, prob=0.25) y <- x | ny supp(X=cbind(x,y),values=c(1,1) )
x <- rbinom(n=100, size=1, prob=0.5) ny<-rbinom(n=100, size=1, prob=0.25) y <- x | ny supp(X=cbind(x,y),values=c(1,1) )
This function rearranges the samples in the mat
into
an aligned list of transactions, which is mainly used by other functions in the package.
Suppose mat[i,]
is a binary vector we are interested, we use A<-bin2dec(mat[i,])
to store the decimal value of mat[i,]
in A
. Then, we call D[[A]]$count
to get number of samples in mat
that are similar to mat[i,]
and
the D[[A]]$name
is mat[i,]
.
VecAlignment(mat)
VecAlignment(mat)
mat |
is a matrix n by d where n is a number of transactions or samples and d is a number of dimensions. |
This function returns an aligned list of transactions D
, is an aligned list of transactions that was converted from any matrix n by d mat
.
VecAlignment(mat=mat)
VecAlignment(mat=mat)