Skip to content

Commit 7cb39ce

Browse files
committed
Minor fixes, updated documentation
1 parent d3416c2 commit 7cb39ce

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

glasso_on_random_graphs.Rmd

+14-11
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ library(pracma)
1515

1616
# Experiment on random sparse graphs
1717

18-
Here, we test glasso on some random sparse graphs and draw ROC curves to select an appropriate value for the parameter rho.
18+
Here, we test glasso on some random sparse graphs and draw ROC curves to select an appropriate value for the parameter `rho`.
1919

2020

2121

22-
Generate Sigma and Theta (Sigma^{-1}) corresponding to a graph of size p and with a sparsity_level % non null coefficients in Theta. We use the fact that a diagonally dominant matrix is positive, and add 0.5 on the diagonal in order to make the smallest eigenvalue >0.
22+
Generate `Sigma` and `Theta` (`Sigma^{-1}`) corresponding to a graph of size `p` and with a sparsity_level % non null coefficients in `Theta`. We use the fact that a diagonally dominant matrix is positive, and add `0.5` on the diagonal in order to make the smallest eigenvalue `>0`.
2323

2424
```{r}
2525
# Generate a sparse positive semidefinite matrix
@@ -39,7 +39,7 @@ res <- genThetaSigma(p)
3939
4040
```
4141

42-
Use glasso package to compute the TPR and FPR for different values of rho on one graph
42+
Use glasso package to compute the TPR and FPR for different values of `rho` on one graph
4343

4444
```{r pressure, echo=FALSE}
4545
experiment <-function(p,n,lrho,thr=0.0001){
@@ -100,7 +100,7 @@ lines(c(0, 1), c(0, 1))
100100
title("ROC curve for a test example")
101101
```
102102

103-
Repeat the experiment on N different graphs
103+
Repeat the experiment on `N` different graphs
104104

105105
```{r, echo=FALSE}
106106
# Repeat experiment a given number of times N and compute statistics
@@ -164,7 +164,7 @@ if(print_to_eps){
164164
}
165165
```
166166

167-
Compute the theoretical rho as in Banerjee et al. (2008)
167+
Compute the theoretical `rho` as in Banerjee et al. (2008), depending on a parameter `alpha`.
168168

169169
```{r}
170170
# Repeat the experiment N times
@@ -205,8 +205,15 @@ trho_quant90 <- apply(trho_matrix, 1, function(m){return(quantile(m, probs=0.9))
205205
print(cbind(alpha,trho_quant10,trho_means,trho_quant90))
206206
```
207207

208+
209+
# Markov chain experiment
210+
211+
The goal is to test whether the lasso algorithm can reconstruct a Markov chain model based on experimental data.
212+
213+
208214
Generate a Markov chain
209215

216+
210217
```{r}
211218
genMarkov <- function(p){
212219
theta <- eye(p)
@@ -223,11 +230,6 @@ return(res)
223230
```
224231

225232

226-
# Markov chain experiment
227-
228-
The goal is to test whether the lasso algorithm can reconstruct a Markov chain model based on experimental data.
229-
230-
231233
Compute the number of connected components
232234

233235

@@ -262,6 +264,7 @@ num_connected_components <- function(M,thre=0.0001){
262264

263265
Experiment on the Markov chain and say whether the graph is connected
264266

267+
265268
```{r}
266269
experiment_markov <-function(p,n,lrho,thr=0.001){
267270
@@ -346,7 +349,7 @@ print(res$rho_theo)
346349
```
347350

348351

349-
Graph in function of rho
352+
Graph in function of `rho`
350353

351354

352355
```{r}

0 commit comments

Comments
 (0)