Premade HGF's in the Hierarchical Gaussian Filtering package

For information on states and parameters of the nodes see section on HGF nodes [LINK]

#Load data for examples

using HierarchicalGaussianFiltering
using ActionModels
using CSV
using DataFrames
using StatsPlots





Continuous 2-level HGF

continuous 2-level graph

The continuous 2-level HGF is structured with following nodes:

  • input node: continuous
  • state nodes:
    • 1st level: continuous (value coupling to input node)
    • 2nd level: continous (volatility coupling to 1st level)
#Create HGF and Agent
continuous_2_level = premade_hgf("continuous_2level");

action_model = ActionModel(HGFGaussian(; HGF = continuous_2_level))

agent_continuous_2_level = init_agent(action_model);

Evolve agent plot trajetories

simulate!(agent_continuous_2_level, inputs_continuous);
plot(
    agent_continuous_2_level,
    "xvol",
    color = "blue",
    size = (1300, 500),
    xlims = (0, 615),
    xlabel = "Trading days since 1 January 2010",
    title = "Volatility parent trajectory",
)

JGET HGF

  • input node: continuous
  • state nodes:
    • 1st level: continuous (value coupling to input node)
    • 2nd level: continous (volatility coupling to 1st level)
    • 3rd level: continous (volatility coupling to input node)
    • 4th level: continous (volatility coupling to 3rd level)
#Create HGF and Agent
JGET = premade_hgf("JGET");

action_model_JGET = ActionModel(HGFGaussian(; HGF = JGET));
agent_JGET = init_agent(action_model_JGET);

Evolve agent plot trajetories

simulate!(agent_JGET, inputs_continuous);
plot(
    agent_JGET,
    "xvol",
    color = "blue",
    size = (1300, 500),
    xlims = (0, 615),
    xlabel = "Trading days since 1 January 2010",
    title = "Volatility parent trajectory",
)

Binary 2-level HGF

continuous 2-level graph

  • input node: binary
  • state nodes:
    • 1st level: binary (value coupling to input node)
    • 2nd level: continous (volatility coupliong to 1st level)
hgf_binary_2_level = premade_hgf("binary_2level", verbose = false);

action_model_binary_2_level = ActionModel(HGFSoftmax(; HGF = hgf_binary_2_level))
-- ActionModel --
Action model function: hgf_softmax
Number of parameters: 1
Number of states: 0
Number of observations: 1
Number of actions: 1
submodel type: HierarchicalGaussianFiltering.HGF

Create an agent

agent_binary_2_level = init_agent(action_model_binary_2_level);

Evolve agent plot trajetories

simulate!(agent_binary_2_level, inputs_binary);
plot(agent_binary_2_level, ("u", "input_value"))
plot!(agent_binary_2_level, ("xbin", "prediction"))
plot(agent_binary_2_level, ("xprob", "posterior"))

Binary 3-level HGF

  • input node: Binary
  • state nodes:
    • 1st level: binary (value coupling to input node)
    • 2nd level: continous (value coupling to 1st level)
    • 3rd level: continous (volatility coupling to 2nd level)
hgf_binary_3_level = premade_hgf("binary_3level", verbose = false);

action_model_binary_3_level = ActionModel(HGFSoftmax(; HGF = hgf_binary_3_level))
-- ActionModel --
Action model function: hgf_softmax
Number of parameters: 1
Number of states: 0
Number of observations: 1
Number of actions: 1
submodel type: HierarchicalGaussianFiltering.HGF

Create an agent

agent_binary_3_level = init_agent(action_model_binary_3_level);

Evolve agent plot trajetories

simulate!(agent_binary_3_level, inputs_binary);
plot(agent_binary_3_level, ("u", "input_value"))
plot!(agent_binary_3_level, ("xbin", "prediction"))
plot(agent_binary_3_level, ("xprob", "posterior"))
plot(agent_binary_3_level, ("xvol", "posterior"))

Categorical 3-level HGF

continuous 2-level graph

The categorical 3-level HGF model takes an input from one of m categories and learns the probability of a category appearing.

  • input node: categorical
  • state nodes:
    • 1st level: categorical (value coupling to input node)
    • 2nd level: m binary (all value couplings to 1st level)
    • 3rd level: continuous (shared volatility coupling to all m nodes in 2nd level)

Categorical 3-level state transition HGF

The categorical 3-level HGF model learns state transition probabilities between a set of categorical states.

  • input node: categorical input nodes
  • state nodes:
    • 1st level: categorical state nodes (value coupling to input node)
    • 2nd level: binary state nodes for each categorical state node (value coupling from each categorical state node to binary state nodes)
    • 3rd level: continous (volatility coupling to all nodes in 2nd level)

This page was generated using Literate.jl.