HGF

Documentation for ActionModels.

Tutorials

Functions

ActionModels.fit_modelMethod

"" fitmodel(agent::Agent,inputs::Array,actions::Vector,parampriors::Dict,fixedparameters::Dict = Dict(); sampler = NUTS(),niterations = 1000, n_chains = 1,verbose = true,)

Returns a summary of the fitted parameters (parameters specified with param_prios).

Arguments

  • 'agent::Agent': a specified agent created with either premade agent or init_agent.
  • 'inputs:Array': array of inputs.
  • 'actions::Array': array of actions.
  • 'param_priors::Dict': priors (written as distributions) for the parameters you wish to fit.
  • 'fixed_parameters::Dict = Dict()': fixed parameters.
  • 'imputemissingactions = false': if true, include missing actions in the fitting process.
  • 'sampler = NUTS()': specify the type of sampler.
  • 'n_iterations = 1000': iterations pr. chain.
  • 'n_chains = 1': amount of chains.
  • 'verbose = true': set to false to hide warnings
ActionModels.get_parametersMethod
get_parameters(agent::Agent, target_param::Union{String,Tuple})

Get out target parameter from agent

ActionModels.get_parametersMethod
get_parameters(agent::Agent, target_parameters::Vector)

Returns a vector of the target parameters specefied in target_parameters

get_parameters(agent::Agent)

Returns all parameters from agent

ActionModels.get_statesMethod
get_states(agent::Agent, target_state::Union{String,Tuple})

extract target state from agent's states.

ActionModels.get_statesMethod
get_states(agent::Agent, target_states::Vector)

specify a vector of target states you wish to extract.

ActionModels.give_inputs!Method
give_inputs!(agent::Agent, inputs::Array)

Function for inputting multiple observations to an agent. Input is structured as an Array, with each row being a single input consisting of multiple numbers.

ActionModels.give_inputs!Method
give_inputs!(agent::Agent, inputs::Real)

Convenience method for inputting multiple observations to an agent. Input is here just a single value.

ActionModels.give_inputs!Method
give_inputs!(agent::Agent, inputs::Vector)

Function for inputting multiple observations to an agent. Input is structured as an Array, with each row being a single input consisting of multiple numbers.

ActionModels.multiple_actionsMethod
multiple_actions(agent::Agent, input::Any)

If an agent is specified with multiple action models

Runs each action model sequentially and returns the action distributions for each action model given agent and input.

ActionModels.plot_predictive_simulationMethod

plotpredictivesimulation(paramdistributions::Union{Chains,Dict}, agent::Agent, inputs::Array, targetstate::Union{String,Tuple}; fixedparameters::Dict = Dict(), nsimulations::Int = 100, verbose::Bool = true, mediancolor::Union{String,Symbol} = :red, title::String = "Sampled trajectories", label::Union{String,Tuple} = targetstate, alpha::Real = 0.1, linewidth::Real = 2, )

compute predictive simulation of target state/states given a set of parameter distributions.

Arguments

  • 'param_distributions::Union{Chains,Dict}': The parameter distributions you want to sample from during the predictive simulation. This can be a turing chain of posteriors or a regular parameter distribution.
  • 'agent::Agent': specified premade agent or custom made agent.
  • 'inputs::Array': input observations to your agent
  • 'target_state::Union{String,Tuple}': the state(s) or actions you want to do simulate. Note that the target state(s) need to be in the agents history.
  • 'fixed_parameters::Dict = Dict()': The fixed parameters which do not vary during the simulation.
  • 'n_simulations::Int = 100': amount of simulations you want to run.
  • 'verbose::Bool = true': if you wish to hide warnings set to false
  • 'median_color::Union{String,Symbol} = :red': specify color of median value in the plot
  • 'label::Union{String,Tuple} = target_state': label on graph
  • 'alpha::Real = 0.1':
  • 'linewidth::Real = 2': specify linewidth on your plot
ActionModels.premade_agentFunction
function premade_agent(
    model_name::String, parameters_list::NamedTuple = (;)
)

Making a premade agent consisting of a model (a premade agent), and a list of configuations (parameter values) for the agent.

ActionModels.set_parameters!Method
set_parameters!(agent::Agent, parameters::Dict)

Setting multiple parameters in dictionary where parameter name is specified followed by parameter value.

ActionModels.set_parameters!Method

setparameters!(agent::Agent, targetparam::Union{String,Tuple}, param_value::Any)

Function for setting a single parameter in an agent. Input to the function is an agent, the parameter name and the parameter value.