GithubHelp home page GithubHelp logo

markkukuismin / mcpese Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 143 KB

Monte Carlo Penalty Selection for graphical lasso

License: GNU General Public License v3.0

R 100.00%
gaussian-graphical-models graphical-lasso huge networks rejection-sampling r-package tuning-parameters metropolis-hastings monte monte-carlo-simulation model-selection

mcpese's Introduction

GitHub

MCPeSe

Monte Carlo Penalty Selection (MCPeSe) for graphical lasso.

Example

library(huge)

source("mcpese.R")

##########################################################

# Initialize seed number:

#seed = Sys.time()

#seed = as.integer(seed)

#seed = seed %% 100000

seed = 59040

set.seed(seed)

##########################################################

# Graphical model simulation:

p = 200

n = 210

Model = "hub"

HugeData = huge.generator(n=n, d=p, graph=Model) 

nlambda = 100

##########################################################

# Compute Glasso solution path:

L = huge(HugeData$data, nlambda=nlambda, method="glasso")

##########################################################

# Run the A-R selection (uniform prior),

ARSelect = mcpese(L, n=n, M=1000)

names(ARSelect)

rhos = ARSelect$rhos

ARSelect$accept.rate

##########################################################

# Run the M-H selection (uniform prior),

MHSelect = mcpese(L, n=n, nSteps=1000, method="M-H")

names(MHSelect)

rhos = MHSelect$rhos

MHSelect$accept.rate

plot(rhos, type="l")

##########################################################

MHMCMCSample

# Either use the mean of rho values...

mean(rhos)

#ThetaARSelect = huge(Y, lambda=mean(rhos), method="glasso")
#ThetaAR = as.matrix(ThetaARSelect$icov[[1]])

# ... or pick the smallest tuning parameter value from the solution path
# which is larger or equal to the mean value:

optARrhoIndx = ARSelect$opt.index # This is sup{i : rho[i] >= mean(rhos)}

optMHrhoIndx = MHSelect$opt.index

huge.plot(HugeData$theta)

title("Ground truth")

##########################################################

GroundTruthGraph

huge.plot(L$path[[optARrhoIndx]])

title("Accept-Reject sampling")

##########################################################

ARGraph

huge.plot(L$path[[optMHrhoIndx]])

title("Metropolis-Hastings sampling")

MHGraph

Reference

The MCPeSe method is described in:

Kuismin and Sillanpaa (2020). MCPeSe: Monte Carlo penalty selection for graphical lasso, Bioinformatics, https://doi.org/10.1093/bioinformatics/btaa734.

File "CodeCollection.zip" is a collection of scripts used to prepare the material in this paper.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.