Skip to contents

Model-preserving co-variation for objects of class CI.

Usage

model_pres_cov(ci, type, entry, delta)

Arguments

ci

object of class CI.

type

character string. Type of model-preserving co-variation: either "total", "partial", row or column.

entry

a vector of length two specifying the entry of the covariance matrix to vary.

delta

multiplicative variation coefficient for the entry of the covariance matrix given in entry.

Value

If the resulting covariance is positive semi-definite, model_pres_cov returns an object of class CI with an updated covariance matrix. Otherwise it returns an object of class npsd.ci, which has the same components of CI but also has a warning entry specifying that the covariance matrix is not positive semi-definite.

Details

Let the original Bayesian network have a Normal distribution \(\mathcal{N}(\mu,\Sigma)\) and let entry be equal to \((i,j)\). For a multiplicative variation of the covariance matrix by an amount \(\delta\), a variation matrix \(\Delta\) is constructed as $$\Delta_{k,l}=\left\{ \begin{array}{ll} \delta & \mbox{if } k=i, l=j\\ \delta & \mbox{if } l=i, k=j \\ 0 & \mbox{otherwise} \end{array} \right.$$ A co-variation matrix \(\tilde\Delta\) is then constructed and the resulting distribution after the variation is \(\mathcal{N}(\mu,\tilde\Delta\circ\Delta\circ\Sigma)\), assuming \(\tilde\Delta\circ\Delta\circ\Sigma\) is positive semi-definite and where \(\circ\) denotes the Schur (or element-wise) product. The matrix \(\tilde\Delta\) is so constructed to ensure that all conditional independence in the original Bayesian networks are retained after the parameter variation.

References

C. Görgen & M. Leonelli (2020), Model-preserving sensitivity analysis for families of Gaussian distributions. Journal of Machine Learning Research, 21: 1-32.

Examples

model_pres_cov(synthetic_ci,"partial",c(1,3),1.1)
#> $order
#> [1] "y1" "y2" "y3" "y4"
#> 
#> $mean
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    0
#> [4,]    0
#> 
#> $covariance
#>      [,1] [,2] [,3] [,4]
#> [1,]  1.0  2.2  2.2    7
#> [2,]  2.2  5.5  5.5   17
#> [3,]  2.2  5.5  6.0   19
#> [4,]  7.0 17.0 19.0   63
#> 
#> $cond_ind
#> $cond_ind[[1]]
#> $cond_ind[[1]]$A
#> [1] "y2"
#> 
#> $cond_ind[[1]]$B
#> character(0)
#> 
#> $cond_ind[[1]]$C
#> [1] "y1"
#> 
#> 
#> $cond_ind[[2]]
#> $cond_ind[[2]]$A
#> [1] "y3"
#> 
#> $cond_ind[[2]]$B
#> [1] "y1"
#> 
#> $cond_ind[[2]]$C
#> [1] "y2"
#> 
#> 
#> $cond_ind[[3]]
#> $cond_ind[[3]]$A
#> [1] "y4"
#> 
#> $cond_ind[[3]]$B
#> character(0)
#> 
#> $cond_ind[[3]]$C
#> [1] "y1" "y2" "y3"
#> 
#> 
#> 
#> attr(,"class")
#> [1] "CI"
model_pres_cov(synthetic_ci,"partial",c(1,3),0.9)
#> $order
#> [1] "y1" "y2" "y3" "y4"
#> 
#> $mean
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    0
#> [4,]    0
#> 
#> $covariance
#>      [,1] [,2] [,3] [,4]
#> [1,]  1.0  1.8  1.8    7
#> [2,]  1.8  4.5  4.5   17
#> [3,]  1.8  4.5  6.0   19
#> [4,]  7.0 17.0 19.0   63
#> 
#> $cond_ind
#> $cond_ind[[1]]
#> $cond_ind[[1]]$A
#> [1] "y2"
#> 
#> $cond_ind[[1]]$B
#> character(0)
#> 
#> $cond_ind[[1]]$C
#> [1] "y1"
#> 
#> 
#> $cond_ind[[2]]
#> $cond_ind[[2]]$A
#> [1] "y3"
#> 
#> $cond_ind[[2]]$B
#> [1] "y1"
#> 
#> $cond_ind[[2]]$C
#> [1] "y2"
#> 
#> 
#> $cond_ind[[3]]
#> $cond_ind[[3]]$A
#> [1] "y4"
#> 
#> $cond_ind[[3]]$B
#> character(0)
#> 
#> $cond_ind[[3]]$C
#> [1] "y1" "y2" "y3"
#> 
#> 
#> 
#> $warning
#> [1] "The covariance is not positive semidefinite"
#> 
#> attr(,"class")
#> [1] "npsd.ci"
model_pres_cov(synthetic_ci,"total",c(1,2),0.5)
#> $order
#> [1] "y1" "y2" "y3" "y4"
#> 
#> $mean
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    0
#> [4,]    0
#> 
#> $covariance
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.5  1.0  1.0  3.5
#> [2,]  1.0  2.5  2.5  8.5
#> [3,]  1.0  2.5  3.0  9.5
#> [4,]  3.5  8.5  9.5 31.5
#> 
#> $cond_ind
#> $cond_ind[[1]]
#> $cond_ind[[1]]$A
#> [1] "y2"
#> 
#> $cond_ind[[1]]$B
#> character(0)
#> 
#> $cond_ind[[1]]$C
#> [1] "y1"
#> 
#> 
#> $cond_ind[[2]]
#> $cond_ind[[2]]$A
#> [1] "y3"
#> 
#> $cond_ind[[2]]$B
#> [1] "y1"
#> 
#> $cond_ind[[2]]$C
#> [1] "y2"
#> 
#> 
#> $cond_ind[[3]]
#> $cond_ind[[3]]$A
#> [1] "y4"
#> 
#> $cond_ind[[3]]$B
#> character(0)
#> 
#> $cond_ind[[3]]$C
#> [1] "y1" "y2" "y3"
#> 
#> 
#> 
#> attr(,"class")
#> [1] "CI"
model_pres_cov(synthetic_ci,"row",c(1,3),0.98)
#> $order
#> [1] "y1" "y2" "y3" "y4"
#> 
#> $mean
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    0
#> [4,]    0
#> 
#> $covariance
#>      [,1] [,2]  [,3] [,4]
#> [1,] 1.00  2.0  1.96    7
#> [2,] 2.00  5.0  4.90   17
#> [3,] 1.96  4.9  6.00   19
#> [4,] 7.00 17.0 19.00   63
#> 
#> $cond_ind
#> $cond_ind[[1]]
#> $cond_ind[[1]]$A
#> [1] "y2"
#> 
#> $cond_ind[[1]]$B
#> character(0)
#> 
#> $cond_ind[[1]]$C
#> [1] "y1"
#> 
#> 
#> $cond_ind[[2]]
#> $cond_ind[[2]]$A
#> [1] "y3"
#> 
#> $cond_ind[[2]]$B
#> [1] "y1"
#> 
#> $cond_ind[[2]]$C
#> [1] "y2"
#> 
#> 
#> $cond_ind[[3]]
#> $cond_ind[[3]]$A
#> [1] "y4"
#> 
#> $cond_ind[[3]]$B
#> character(0)
#> 
#> $cond_ind[[3]]$C
#> [1] "y1" "y2" "y3"
#> 
#> 
#> 
#> attr(,"class")
#> [1] "CI"
model_pres_cov(synthetic_ci,"column",c(1,3),0.98)
#> $order
#> [1] "y1" "y2" "y3" "y4"
#> 
#> $mean
#>      [,1]
#> [1,]    0
#> [2,]    0
#> [3,]    0
#> [4,]    0
#> 
#> $covariance
#>      [,1]  [,2]  [,3] [,4]
#> [1,] 1.00  1.96  1.96    7
#> [2,] 1.96  5.00  5.00   17
#> [3,] 1.96  5.00  6.00   19
#> [4,] 7.00 17.00 19.00   63
#> 
#> $cond_ind
#> $cond_ind[[1]]
#> $cond_ind[[1]]$A
#> [1] "y2"
#> 
#> $cond_ind[[1]]$B
#> character(0)
#> 
#> $cond_ind[[1]]$C
#> [1] "y1"
#> 
#> 
#> $cond_ind[[2]]
#> $cond_ind[[2]]$A
#> [1] "y3"
#> 
#> $cond_ind[[2]]$B
#> [1] "y1"
#> 
#> $cond_ind[[2]]$C
#> [1] "y2"
#> 
#> 
#> $cond_ind[[3]]
#> $cond_ind[[3]]$A
#> [1] "y4"
#> 
#> $cond_ind[[3]]$B
#> character(0)
#> 
#> $cond_ind[[3]]$C
#> [1] "y1" "y2" "y3"
#> 
#> 
#> 
#> attr(,"class")
#> [1] "CI"