mcmc_ddepn: mcmc_ddepn - Perform MCMC sampling for DDEPN.

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

MCMC sampling for DDEPN. Takes an initial network and samples from the posterior. runmcmc is a wrapper function for multiple calls of mcmc_ddepn, in case that multiple cores are used for parallel MCMC runs.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
mcmc_ddepn(dat, phiorig=NULL, phi=NULL, stimuli=NULL,
    th=0.8, multicores=FALSE, outfile=NULL, maxiterations=10000,
    usebics=FALSE, cores=2, lambda=NULL, B=NULL,Z=NULL,
    samplelambda=NULL, hmmiterations=30, fanin=4,
    gam=NULL, it=NULL, K=NULL, burnin=1000, priortype="laplaceinhib",
    plotresults=TRUE,always_sample_sf=FALSE, scale_lik=FALSE, 
    allow.stim.off=TRUE,debug=0,retobj=NULL, implementation="C")
    
runmcmc(x,dat,phiorig,phi,stimuli,th,multicores,outfile,maxiterations,
		usebics,cores,lambda,B,Z,samplelambda,hmmiterations,
		fanin,gam,it,K,burnin,priortype,
		plotresults=TRUE,always_sample_sf=FALSE, 
		scale_lik=FALSE, allow.stim.off=TRUE,debug=0,
		retobj=NULL, implementation="C")

Arguments

dat

The data matrix.

phiorig

The reference network to compare to. Can be NULL.

phi

The start network. Empty if NULL.

stimuli

The stimuli list.

th

Threshold for inclusion of an edge in the final network.

multicores

Use multiple cores. Not used here.

outfile

File to which the network should be drawn.

maxiterations

Integer. Maximum number of MCMC iterations.

usebics

Use bics for model selection.

cores

Not used here.

lambda

NULL, Numeric or NA. The Prior influence hyperparameter for the laplace prior. If numeric, used as fixed prior strength or starting value for prior strength sampling (when samplelambda is numeric, too). If NA, lambda is integrated out in the calculation of the prior. If NULL, no laplace prior is used.

B

The Prior information matrix. See prior for details.

Z

Normalisation factor for prior.

hmmiterations

Maximum iterations in the HMM.

fanin

Integer: maximal indegree for nodes.

gam

Prior influence strength in scalefree prior.

it

Number of iterations to generate background distribution in scalefree prior.

K

Proportionality factor in scalefree prior

samplelambda

Numeric or NULL. If NULL, the Laplace hyperparameter lambda is kept fix during the MCMC inference. If numeric, lambda is sampled uniformly around the initial value of lambda, with an interval size defined by samplelambda.

x

List containing two items: An adjacency matrix phi and a string outfile describing a path.

burnin

Integer. Specifies the number of iterations used as burnin phase for mcmc_ddepn.

priortype

Character. One of none, laplaceinhib, laplace or scalefree for use of the respective prior type. Ignored if usebics=TRUE. For netga, usebics=FALSE, priortype="none" means optimising the likelihood directly, for mcmc_ddepn, none is not allowed.

plotresults

Boolean. If TRUE, some statistics are plotted while inhibMCMC is running.

always_sample_sf

Boolean. Update scaling factor in inhibMCMC sampling through the whole sampling if TRUE. Keep scaling factor fixed after burn-in if FALSE.

scale_lik

Boolean. Perform scaling of the likelihood according to how many data points were used to calculate the overall likelihood.

allow.stim.off

Boolean. If TRUE, the stimulus can become passive at some time. This will generate additional reachable system states, in particular all states from the normal state matrix, generated by the propagation, but with the stimulus node set to 0.

debug

Numeric. If 0, a status bar indicates the progress of the algorithm. If 1 or 2, extra information is printed to the console (for debug=2 more information than for debug=1).

retobj

List. The output generated during an inhibMCMC run (see ddepn for argument inference="mcmc"). Passed by function resume_ddepn to resume the inference.

implementation

String. One of "C","R","R_globalest","C_globalest". Different implementations of the HMM in perform.hmmsearch. If "R", the original pure R-implementation is used, if "C", a ported C-implementation is used. If "R_globalest", an experimental version of the parameter estimation is used in the HMM, "C_globalest" is the C-port of this version. See details for a description.

Details

Usually this function is called internally by ddepn.

Value

A list of the following elements:

phi

The inferred network.

L

Likelihood.

aic

Akaikes Information Criterion.

bic

Bayesian Information Criterion.

posterior

Posterior probability.

dat

The data matrix.

theta

The parameter matrix for the gaussians.

gamma

The state transition matrix.

gammaposs

The theoretical state transition matrix, as generated by the effect propagation.

tps

A list. Each element is a vector of time points for each experiment in the data matrix.

stimuli

List of stimuli.

reps

Number of replicates for each experiment.

hmmiterations

Maximum number of iterations during an HMM run.

lastmove

Type of the last change that was performed.

coords

Position in the network where the last change was performed.

lambda

Laplace prior hyperparameter.

B

Laplace prior matrix.

Z

Laplace prior normalisation factor. (Not used at the moment.)

pegm

Probability of performing the last move.

pegmundo

Probability of reverting the last move.

nummoves

Total number of possible moves in the current step.

fanin

Maximal indegree for nodes.

gam

Sparsity prior hyperparameter.

it

Sparsity prior iterations.

K

Sparsity prior scaling factor.

conf.act

Matrix of beliefs that an edge is an activation. (equals freqa/eoccur)

conf.inh

Matrix of beliefs that an edge is an inhibition. (equals freqi/eoccur)

eoccur

Matrix of total occurrences of edges.

phi.orig

Adjacency of reference network, if given.

stats

Matrix of scores and statistics recorded during MCMC.

freqa

Counts how often an edge was an activation.

freqi

Counts how often an edge was an activation.

mu_run

The running mean values of the parameters in theta.

Qi

A helper for the calculation of sd_run.

sd_run

The running standard deviations of the parameters in theta.

Note

TODO

Author(s)

Christian Bender

References

TODO

See Also

ddepn

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
## load package
library(ddepn)

## sample a network
n <- 6
signet <- signalnetwork(n=n, nstim=2, cstim=0, prop.inh=0.2)
phit <- signet$phi
stimuli <- signet$stimuli

## sample data
dataset <- makedata(phit, stimuli, mu.bg=1200, sd.bg=400, 
	mu.signal.a=2000, sd.signal.a=1000)

## prior normalisation factor
lambda <- 0.01 

## network to start with
V <- rownames(dataset$datx)
phistart <- matrix(0, nrow=n, ncol=n, dimnames=list(V,V))

## use original network as prior matrix
## reset all entries for inhibiting edges 
## to -1
B <- phit
B[B==2] <- -1

## now the sampling
ret <- mcmc_ddepn(dataset$datx, phiorig=phit, phi=phistart, stimuli=stimuli,
            th=0.8, multicores=FALSE, outfile=NULL, maxiterations=300,
            usebics=FALSE, cores=1, lambda=lambda, B=B,
            hmmiterations=100, fanin=4, burnin=100, priortype="laplaceinhib")

## End(Not run)

ddepn documentation built on May 2, 2019, 4:42 p.m.