Skip to content

Commit

Permalink
Fix dragon (#306)
Browse files Browse the repository at this point in the history
* add DRAGON outline

* implemented vars and esqs, added tests

* added optim

* Added fn to get shrunken cov and unit tests

* Update DESCRIPTION

* Update DESCRIPTION

* mechanics for prec mat and parcor

* added testdata directory

* fixed test paths

* Update test-dragon.R

* added export function and tests

* updated docs

* added ex datasets

* fixed bug w/self-edges in GGM

* fixed GGM diagonal issue

* fixed merge conflicts in docs

* fixed more merge conflicts
  • Loading branch information
katehoffshutta authored Dec 1, 2023
1 parent d64817e commit c0ca530
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/DRAGON.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# X_mean = np.mean(X_temp, axis=0)
# return (X_temp - X_mean) / X_std


scale = function(x,bias=FALSE)
{
# sd does 1/(n-1), python does 1/n
Expand Down Expand Up @@ -234,7 +235,7 @@ estimatePenaltyParameters = function(X1,X2)
lower=c(0,0),
upper=c(1,1),
control = list(trace=TRUE,pgtol = 1e-15))

# reparameterize
lambdas = c(1-res$par[1]^2, 1-res$par[2]^2)
return(list("lambdas"=lambdas,"gammas"=res$par,"optim_result"=res,"risk_grid" = riskgrid))
Expand Down Expand Up @@ -296,12 +297,13 @@ get_precision_matrix_dragon = function(X1, X2, lambdas)
# mu = np.mean(X, axis=0)
}


get_partial_correlation_from_precision = function(Theta,selfEdges=FALSE)
{
# by default, does not return self edges (diagonal is set to zero)
ggm = -cov2cor(Theta)
if(!selfEdges)
ggm[diag(ggm)] = 0
diag(ggm) = 0
return(ggm)
}

Expand Down

0 comments on commit c0ca530

Please sign in to comment.