-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into documentation_polish
- Loading branch information
Showing
38 changed files
with
48,325 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
name = "HierarchicalGaussianFiltering" | ||
uuid = "63d42c3e-681c-42be-892f-a47f35336a79" | ||
authors = ["Peter Thestrup Waade [email protected]", "Anna Hedvig Møller [email protected]", "Jacopo Comoglio [email protected]", "Christoph Mathys [email protected]\n and contributors"] | ||
version = "0.3.1" | ||
authors = [ "Peter Thestrup Waade [email protected]", | ||
"Anna Hedvig Møller [email protected]", | ||
"Jacopo Comoglio [email protected]", | ||
"Christoph Mathys [email protected]"] | ||
version = "0.3.3" | ||
|
||
[deps] | ||
ActionModels = "320cf53b-cc3b-4b34-9a10-0ecb113566a3" | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" | ||
|
||
[compat] | ||
ActionModels = "0.3" | ||
ActionModels = "0.4" | ||
Distributions = "0.25" | ||
RecipesBase = "1" | ||
julia = "1.8" | ||
julia = "1.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using ActionModels, HierarchicalGaussianFiltering | ||
using CSV, DataFrames | ||
using Plots, StatsPlots | ||
using Distributions | ||
path = "docs/src/tutorials/data" | ||
|
||
#Load data | ||
data = CSV.read("$path/classic_cannonball_data.csv", DataFrame) | ||
|
||
#Create HGF | ||
hgf = premade_hgf("JGET", verbose = false) | ||
#Create agent | ||
agent = premade_agent("hgf_gaussian_action", hgf) | ||
#Set parameters | ||
parameters = Dict( | ||
"gaussian_action_precision" => 1, | ||
("x1", "volatility") => -8, | ||
("x2", "volatility") => -5, | ||
("x3", "volatility") => -5, | ||
("x4", "volatility") => -5, | ||
("x1", "x2", "volatility_coupling") => 1, | ||
("x3", "x4", "volatility_coupling") => 1, | ||
) | ||
set_parameters!(agent, parameters) | ||
|
||
inputs = data[(data.ID.==20).&(data.session.==1), :].outcome | ||
#Simulate updates and actions | ||
actions = give_inputs!(agent, inputs); | ||
#Plot belief trajectories | ||
plot_trajectory(agent, "u") | ||
plot_trajectory!(agent, "x1") | ||
plot_trajectory(agent, "x2") | ||
plot_trajectory(agent, "x3") | ||
plot_trajectory(agent, "x4") | ||
|
||
priors = Dict( | ||
"gaussian_action_precision" => LogNormal(-1, 0.1), | ||
("x1", "volatility") => Normal(-8, 1), | ||
) | ||
|
||
data_subset = data[(data.ID.∈[[20, 21]]).&(data.session.∈[[1, 2]]), :] | ||
|
||
using Distributed | ||
addprocs(6, exeflags = "--project") | ||
@everywhere @eval using HierarchicalGaussianFiltering | ||
|
||
results = fit_model( | ||
agent, | ||
priors, | ||
data_subset, | ||
independent_group_cols = [:ID, :session], | ||
input_cols = [:outcome], | ||
action_cols = [:response], | ||
n_cores = 6, | ||
) | ||
|
||
fitted_model = results[(20, 1)] | ||
|
||
plot_parameter_distribution(fitted_model, priors) | ||
|
||
|
||
|
||
|
||
posterior = get_posteriors(fitted_model) | ||
|
||
set_parameters!(agent, posterior) | ||
|
||
reset!(agent) | ||
|
||
give_inputs!(agent, inputs) | ||
|
||
get_history(agent, ("x1", "value_prediction_error")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.