|
1 | 1 | # HGF
|
2 |
| - |
3 | 2 | [](https://ilabcode.github.io/HierarchicalGaussianFiltering.jl)
|
4 | 3 | [](https://github.com/ilabcode/HierarchicalGaussianFiltering.jl/actions/workflows/CI_full.yml?query=branch%3Amain)
|
5 | 4 | [](https://codecov.io/gh/ilabcode/HierarchicalGaussianFiltering.jl)
|
6 | 5 | [](<https://www.gnu.org/licenses/>)
|
| 6 | + |
| 7 | + |
| 8 | +# Welcome to The Hierarchical Gaussian Filtering Package! |
| 9 | + |
| 10 | +Hierarchical Gaussian Filtering (HGF) is a novel and adaptive package for doing cognitive and behavioral modelling. With the HGF you can fit time series data fit participant-level individual parameters, measure group differences based on model-specific parameters or use the model for any time series with underlying change in uncertainty. |
| 11 | + |
| 12 | +The HGF consists of a network of probabilistic nodes hierarchically structured. The hierarchy is determined by the coupling between nodes. A node (child node) in the network can inheret either its value or volatility sufficient statistics from a node higher in the hierarchy (a parent node). |
| 13 | + |
| 14 | +The presentation of a new observation at the lower level of the hierarchy (i.e. the input node) trigger a recursuve update of the nodes belief throught the bottom-up propagation of precision-weigthed prediction error. |
| 15 | + |
| 16 | +The HGF will be explained in more detail in the theory section of the documentation |
| 17 | + |
| 18 | +It is also recommended to check out the ActionModels.jl pacakge for stronger intuition behind the use of agents and action models. |
| 19 | + |
| 20 | +## Getting started |
| 21 | + |
| 22 | +The last official release can be downloaded from Julia with |
| 23 | + |
| 24 | +````@example index |
| 25 | +"] add Luxor" |
| 26 | +```` |
| 27 | + |
| 28 | +We provide a script for getting started with commonly used functions and use cases |
| 29 | + |
| 30 | +Load packages |
| 31 | + |
| 32 | +````@example index |
| 33 | +using HierarchicalGaussianFiltering |
| 34 | +using ActionModels |
| 35 | +```` |
| 36 | + |
| 37 | +### Get premade agent |
| 38 | + |
| 39 | +````@example index |
| 40 | +premade_agent("help") |
| 41 | +```` |
| 42 | + |
| 43 | +### Create agent |
| 44 | + |
| 45 | +````@example index |
| 46 | +agent = premade_agent("hgf_binary_softmax_action") |
| 47 | +```` |
| 48 | + |
| 49 | +### Get states and parameters |
| 50 | + |
| 51 | +````@example index |
| 52 | +get_states(agent) |
| 53 | +```` |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +````@example index |
| 58 | +get_parameters(agent) |
| 59 | +```` |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +Set a new parameter for initial precision of x2 and define some inputs |
| 64 | + |
| 65 | +````@example index |
| 66 | +set_parameters!(agent, ("x2", "initial_precision"), 0.9) |
| 67 | +inputs = [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0]; |
| 68 | +nothing #hide |
| 69 | +```` |
| 70 | + |
| 71 | +### Give inputs to the agent |
| 72 | + |
| 73 | +````@example index |
| 74 | +actions = give_inputs!(agent, inputs) |
| 75 | +```` |
| 76 | + |
| 77 | +### Plot state trajectories of input and prediction |
| 78 | + |
| 79 | +````@example index |
| 80 | +using StatsPlots |
| 81 | +using Plots |
| 82 | +plot_trajectory(agent, ("u", "input_value")) |
| 83 | +plot_trajectory!(agent, ("x1", "prediction")) |
| 84 | +```` |
| 85 | + |
| 86 | + |
| 87 | +Plot state trajectory of input value, action and prediction of x1 |
| 88 | + |
| 89 | +````@example index |
| 90 | +plot_trajectory(agent, ("u", "input_value")) |
| 91 | +plot_trajectory!(agent, "action") |
| 92 | +plot_trajectory!(agent, ("x1", "prediction")) |
| 93 | +```` |
| 94 | + |
| 95 | +### Fitting parameters |
| 96 | + |
| 97 | +````@example index |
| 98 | +using Distributions |
| 99 | +prior = Dict(("x2", "evolution_rate") => Normal(1, 0.5)) |
| 100 | +
|
| 101 | +model = fit_model(agent, prior, inputs, actions, n_iterations = 20) |
| 102 | +```` |
| 103 | + |
| 104 | +### Plot chains |
| 105 | + |
| 106 | +````@example index |
| 107 | +plot(model) |
| 108 | +```` |
| 109 | + |
| 110 | +### Plot prior angainst posterior |
| 111 | + |
| 112 | +````@example index |
| 113 | +plot_parameter_distribution(model, prior) |
| 114 | +```` |
| 115 | + |
| 116 | +### Get posterior |
| 117 | + |
| 118 | +````@example index |
| 119 | +get_posteriors(model) |
| 120 | +```` |
| 121 | + |
| 122 | +--- |
0 commit comments