linear_model#

AB2intAB#

gunfolds.estimation.linear_model.AB2intAB(A, B, th=0.09)[source]#
Parameters:
  • A

  • B

  • th (float) – (GUESS)threshold for discarding edges in A and B

Returns:

Return type:

amap#

gunfolds.estimation.linear_model.amap(f, a)[source]#
Parameters:
  • f

  • a

Returns:

Return type:

bnf2CG#

gunfolds.estimation.linear_model.bnf2CG(fname)[source]#
Parameters:

fname

Returns:

Return type:

data2AB#

gunfolds.estimation.linear_model.data2AB(data, x0=None)[source]#
Parameters:
  • data

  • x0

Returns:

Return type:

data2graph#

gunfolds.estimation.linear_model.data2graph(data, x0=None, th=0.0)[source]#
Parameters:
  • data

  • x0

Returns:

Return type:

data2VARgraph#

gunfolds.estimation.linear_model.data2VARgraph(data, pval=0.05)[source]#
Parameters:
  • data

  • pval (float) –

Returns:

Return type:

decide_absences#

gunfolds.estimation.linear_model.decide_absences(As)[source]#

Given a list of binary matrices returns a binary mask for absence and presence of edges

Parameters:

As – a list of binary matrices

Returns:

Return type:

drawsamplesLG#

gunfolds.estimation.linear_model.drawsamplesLG(A, nstd=0.1, samples=100)[source]#
Parameters:
  • A

  • nstd (float) –

  • samples (integer) –

Returns:

Return type:

drawsamplesMA#

gunfolds.estimation.linear_model.drawsamplesMA(A, nstd=0.1, samples=100, order=5)[source]#
Parameters:
  • A

  • nstd (float) –

  • samples (integer) –

  • order (integer) –

Returns:

Return type:

estimateG#

gunfolds.estimation.linear_model.estimateG(G, YY, XX, YX, T, x0=None)[source]#
Parameters:
  • G (dictionary (gunfolds graph)) – gunfolds format graph

  • YY

  • XX

  • YX

  • T

  • x0

Returns:

Return type:

estimateSVAR#

gunfolds.estimation.linear_model.estimateSVAR(data, th=0.09)[source]#
Parameters:
  • data

  • th ((guess)float) – (GUESS)threshold for discarding edges in A and B

Returns:

Return type:

G2AH#

gunfolds.estimation.linear_model.G2AH(G)[source]#
Parameters:

G (dictionary (gunfolds graph)) – gunfolds format graph

Returns:

Return type:

G2SVAR#

gunfolds.estimation.linear_model.G2SVAR(G)[source]#
Parameters:

G (dictionary (gunfolds graph)) – gunfolds format graph

Returns:

Return type:

genData#

gunfolds.estimation.linear_model.genData(n, rate=2, density=0.1, burnin=100, ssize=2000, noise=0.1, dist='beta')[source]#

Given a number of nodes this function randomly generates a ring SCC and the corresponding stable transition matrix. It tries until succeeds and for some graph densities and parameters of the distribution of transition matrix values it may take forever. Please play with the dist parameter to stableVAR. Then using this transition matrix it generates ssize samples of data and undersamples them by rate discarding the burnin number of samples at the beginning.

Parameters:
  • n ((guess)integer) – number of nodes in the desired graph

  • rate (integer) – undersampling rate (1 - no undersampling)

  • density ((guess) float) – density of the graph to be generted

  • burnin (integer) – number of samples to discard since the beginning of VAR sampling

  • ssize ((guess)integer) – how many samples to keep at the causal sampling rate

  • noise ((guess)float) – noise standard deviation for the VAR model

  • dist ((guess)string) – (GUESS)distribution from which to sample the weights. Available options are flat, flatsigned, beta, normal, uniform

Returns:

Return type:

getAgraph#

gunfolds.estimation.linear_model.getAgraph(n, mp=2, st=0.5, verbose=True)[source]#
Parameters:
  • n

  • mp ((guess)integer) –

  • st (float) –

  • verbose (boolean) –

Returns:

Return type:

getAring#

gunfolds.estimation.linear_model.getAring(n, density=0.1, st=0.5, verbose=True, dist='flatsigned')[source]#
Parameters:
  • n

  • density (float) – (guess)ratio of total nodes to n^2 possible nodes

  • st (float) –

  • verbose (boolean) –

  • dist (string) –

Returns:

Return type:

initRandomMatrix#

gunfolds.estimation.linear_model.initRandomMatrix(A, edges, distribution='beta')[source]#

possible distributions: flat flatsigned beta normal uniform

Parameters:
  • A

  • edges

  • distribution (string) – (GUESS)distribution from which to sample the weights. Available options are flat, flatsigned, beta, normal, uniform

Returns:

Return type:

listplace#

gunfolds.estimation.linear_model.listplace(l, a, b)[source]#
Parameters:
  • l

  • a

  • b

Returns:

Return type:

nllf#

gunfolds.estimation.linear_model.nllf(x, A, B, Y, aidx, bidx)[source]#
Parameters:
  • x

  • A

  • B

  • Y

  • aidx

  • bidx

Returns:

Return type:

nllf2#

gunfolds.estimation.linear_model.nllf2(x, A, B, YY, XX, YX, T, aidx, bidx)[source]#
Parameters:
  • x

  • A

  • B

  • YY

  • XX

  • YX

  • T

  • aidx

  • bidx

Returns:

Return type:

noiseData#

gunfolds.estimation.linear_model.noiseData(data, noise=0.1)[source]#
Parameters:
  • data

  • noise ((guess)float) – (GUESS)noise standard deviation for the VAR model

Returns:

Return type:

npG2SVAR#

gunfolds.estimation.linear_model.npG2SVAR(G)[source]#
Parameters:

G (dictionary (gunfolds graph)) – gunfolds format graph

Returns:

Return type:

presence_probs#

gunfolds.estimation.linear_model.presence_probs(As)[source]#

Given a list of binary matrices returns a frequency of edge presence

Parameters:

As – a list of binary matrices

Returns:

Return type:

randomSVAR#

gunfolds.estimation.linear_model.randomSVAR(n, rate=2, density=0.1, th=0.09, burnin=100, ssize=2000, noise=0.1, dist='beta')[source]#

Given a number of nodes this function randomly generates a ring SCC and the corresponding stable transition matrix. It tries until succeeds and for some graph densities and parameters of the distribution of transition matrix values it may take forever. Please play with the dist parameter to stableVAR. Then using this transition matrix it generates ssize samples of data and undersamples them by rate discarding the burnin number of samples at the beginning. For these data the funcion solves the SVAR estimation maximizing log likelihood and returns the A and B matrices.

Parameters:
  • n ((guess)integer) – number of nodes in the desired graph

  • rate (integer) – undersampling rate (1 - no undersampling)

  • density ((guess)float) – density of the graph to be generted

  • th ((guess)float) – threshold for discarding edges in A and B

  • burnin ((guess)integer) – number of samples to discard since the beginning of VAR sampling

  • ssize ((guess)integer) – how many samples to keep at the causal sampling rate

  • noise ((guess)float) – noise standard deviation for the VAR model

  • dist ((guess)string) – (GUESS)distribution from which to sample the weights. Available options are flat, flatsigned, beta, normal, uniform

Returns:

Return type:

randomSVARs#

gunfolds.estimation.linear_model.randomSVARs(n, repeats=100, rate=2, density=0.1, th=0.09, burnin=100, ssize=2000, noise=0.1, strap_noise=0.1)[source]#

does what requested - help is on the way

Parameters:
  • n (integer) – number of nodes in the desired graph

  • repeats (integer) – how many times to add noise and re-estiamte

  • rate (integer) – undersampling rate (1 - no undersampling)

  • density ((guess)float) – density of the graph to be generted

  • th ((guess)float) – threshold for discarding edges in A and B

  • burnin (integer) – number of samples to discard since the beginning of VAR sampling

  • ssize (integer) – how many samples to keep at the causal sampling rate

  • noise (float) – noise standard deviation for the VAR model

  • strap_noise (float) – amount of noise for bootstrapping

Returns:

Return type:

randweights#

gunfolds.estimation.linear_model.randweights(n, c=0.1, factor=9)[source]#
Parameters:
  • n

  • c (float) –

  • factor ((guess)integer) –

Returns:

Return type:

sampleWeights#

gunfolds.estimation.linear_model.sampleWeights(n, minstrength=0.1)[source]#
Parameters:
  • n

  • minstrength (float) –

Returns:

Return type:

scoreAGraph#

gunfolds.estimation.linear_model.scoreAGraph(G, data, x0=None)[source]#
Parameters:
  • G (dictionary (gunfolds graph)) – gunfolds format graph

  • data

  • x0

Returns:

Return type:

stableVAR#

gunfolds.estimation.linear_model.stableVAR(n, density=0.1, dist='beta')[source]#

This function keeps trying to create a random graph and a random corresponding transition matrix until it succeeds.

Parameters:
  • n ((guess)integer) – number of nodes in the graph

  • density ((guess)float) – ratio of total nodes to n^2 possible nodes

  • dist ((guess)string) – distribution from which to sample the weights. Available options are flat, flatsigned, beta, normal, uniform

Returns:

Return type:

symchol#

gunfolds.estimation.linear_model.symchol(M)[source]#
Parameters:

M

Returns:

Return type:

transitionMatrix#

gunfolds.estimation.linear_model.transitionMatrix(cg, minstrength=0.1)[source]#
Parameters:
  • cg

  • minstrength (float) –

Returns:

Return type:

transitionMatrix2#

gunfolds.estimation.linear_model.transitionMatrix2(cg, minstrength=0.1)[source]#
Parameters:
  • cg

  • minstrength (float) –

Returns:

Return type:

transitionMatrix3#

gunfolds.estimation.linear_model.transitionMatrix3(cg, x0=None, minstrength=0.1)[source]#
Parameters:
  • cg

  • x0

  • minstrength (float) –

Returns:

Return type:

transitionMatrix4#

gunfolds.estimation.linear_model.transitionMatrix4(g, minstrength=0.1, distribution='normal', maxtries=1000)[source]#
Parameters:
  • g (dictionary (gunfolds graph)) – gunfolds graph

  • minstrength (float) –

  • distribution (string) – (GUESS)distribution from which to sample the weights. Available options are flat, flatsigned, beta, normal, uniform

  • maxtries ((guess)integer) –

Returns:

Return type:

VARbic#

gunfolds.estimation.linear_model.VARbic(nllf, K, T)[source]#
Parameters:
  • nllf

  • K

  • T

Returns:

Return type:

weight_and_mask#

gunfolds.estimation.linear_model.weight_and_mask(As)[source]#

Given a list o fbinary matrices returns a weight matrix for presences and absences and a mask to identify which are which

Parameters:

As – a list of binary matrices

Returns:

Return type:

x2M#

gunfolds.estimation.linear_model.x2M(x, A, B, aidx, bidx)[source]#
Parameters:
  • x

  • A

  • B

  • aidx

  • bidx

Returns:

Return type: