https://github.com/itsdfish/adaptivedesignoptimization.jl
A Julia package for grid-based adaptive design optimization.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.9%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A Julia package for grid-based adaptive design optimization.
Basic Info
Statistics
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 5
Topics
Metadata Files
README.md
AdaptiveDesignOptimization
This package is a grid-based approach for performing Bayesian adaptive design optimization. After each observation, the optimizer chooses an experimental design that maximizes mutual information between model parameters and design parameters. In so doing, the optimizer selects designs that minimize the variance in the posterior distribution of model parameters.
Example
In this example, we will optimize a decision making experiment for the model called Transfer of Attention Exchange (TAX; Birnbaum, 2008). Additional examples can be found in the folder titled Examples.
julia
using AdaptiveDesignOptimization, Random, UtilityModels, Distributions
include("TAX_Model.jl")
Random.seed!(25974)
Define Model
The model object contains a log likelihood function and optional prior distributions. Unless an array of distribution objects is passed as prior, uniform distributions will be used by default. Arguments in the log likelihood function must be ordered as follows:
- loglike(modelparameters..., designparameters..., data..., args...; kwargs...)
args... and kwargs... are optional arguments that may be preloaded through the Model constructor. Enter
julia
? Model
for additional details. The likelihood function for the TAX model (see TAX_Model.jl) is defined as:
julia
function loglike(δ, β, γ, θ, pa, va, pb, vb, data)
eua,eub = expected_utilities(δ, β, γ, θ, pa, va, pb, vb)
p = choice_prob(eua, eub, θ)
p = max(p, eps())
return logpdf(Bernoulli(p), data)
end
The model object is contructed with default uniform prior distributions.
```julia
model with default uniform prior
model = Model(;loglike) ```
Define Parameters
Define a NamedTuple of parameter value ranges. Note that the parameters listed in the same order that they appear in loglike.
julia
parm_list = (
δ = range(-2, 2, length=10),
β = range(.5, 1.5, length=10),
γ = range(.5, 1.2, length=10),
θ = range(.5, 3, length=10)
)
The experiment will consist of two gambles with three outcomes each. The number of dimensions in the design space is large (2X2X3X3 = 36). In this case, we will sample random gambles and select a subset of 100 with high distributional overlap. In this case, the design_list will be a Tuple of design names and design values.
```julia
outcome distribution
dist = Normal(0,10) nvals = 3 nchoices = 2 designvals = map(x->randomdesign(dist, nvals, nchoices), 1:1000)
select gambles with overlapping distributions
filter!(x->abszscore(x) ≤ .4, designvals) designnames = (:p1,:v1,:p2,:v2) designlist = (designnames,designvals[1:100]) ```
Lastly, we will define a list for the data. The value true indicates gamble A was choosen and false indicates gamble B was chosen.
julia
data_list = (choice=[true, false],)
Optimize Exeriment
In the following code blocks, we will run an optimized experiment and a random experiment. The first step is to generate the optimizer with the contructor Optimizer. Next, we specify true parameters for generating data from the model and initialize a DataFrame to collect the results on each simulated trial. In the experiment loop, data are generated with simulate. The data are passed to update in order to optimize the experiment for the next trial. Finally, the mean and standard deviation are added to the DataFrame for each parameter. A similar process is used to perform the random experiment.
```julia using DataFrames trueparms = (δ=-1.0, β=1.0, γ=.7, θ=1.5) ntrials = 100 optimizer = Optimizer(;designlist, parmlist, datalist, model) design = optimizer.bestdesign df = DataFrame(design=Symbol[], trial=Int[], meanδ=Float64[], meanβ=Float64[], meanγ=Float64[], meanθ=Float64[], stdδ=Float64[], stdβ=Float64[], stdγ=Float64[], stdθ=Float64[]) newdata = [:optimal, 0, meanpost(optimizer)..., stdpost(optimizer)...] push!(df, newdata)
for trial in 1:ntrials data = simulate(trueparms..., design...) design = update!(optimizer, data) newdata = [:optimal, trial, meanpost(optimizer)..., stdpost(optimizer)...] push!(df, newdata) end ```
Random Experiment
```julia randomizer = Optimizer(;designlist, parmlist, datalist, model, designtype=Randomize); design = randomizer.bestdesign newdata = [:random, 0, meanpost(randomizer)..., stdpost(randomizer)...] push!(df, new_data)
for trial in 1:ntrials data = simulate(trueparms..., design...) design = update!(randomizer, data) newdata = [:random, trial, meanpost(randomizer)..., stdpost(randomizer)...] push!(df, newdata) end ```
Results
As expected, in the figure below, the posterior standard deviation of δ is smaller for the optimal experiment compared to the random experiment.
julia
using StatsPlots
@df df plot(:trial, :std_δ, xlabel="trial", ylabel="σ of δ", grid=false, group=:design, linewidth=2, ylims=(0,1.5), size=(600,400))

References
Birnbaum, M. H., & Chavez, A. (1997). Tests of theories of decision making: Violations of branch independence and distribution independence. Organizational Behavior and human decision Processes, 71(2), 161-194. Birnbaum, M. H. (2008). New paradoxes of risky decision making. Psychological review, 115(2), 463.
Myung, J. I., Cavagnaro, D. R., and Pitt, M. A. (2013). A tutorial on adaptive design optimization. Journal of Mathematical Psychology, 57, 53–67.
Yang, J., Pitt, M. A., Ahn, W., & Myung, J. I. (2020). ADOpy: A Python Package for Adaptive Design Optimization. Behavior Research Methods, 1--24. https://doi.org/10.3758/s13428-020-01386-4
Owner
- Name: dfish
- Login: itsdfish
- Kind: user
- Repositories: 27
- Profile: https://github.com/itsdfish
I'm not a programmer, but I play one on TV.
GitHub Events
Total
- Watch event: 1
- Delete event: 2
- Push event: 4
- Pull request event: 4
- Create event: 2
Last Year
- Watch event: 1
- Delete event: 2
- Push event: 4
- Pull request event: 4
- Create event: 2
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 22
- Total Committers: 4
- Avg Commits per committer: 5.5
- Development Distribution Score (DDS): 0.318
Top Committers
| Name | Commits | |
|---|---|---|
| itsdfish | i****h@g****m | 15 |
| dfish | 9****h@u****m | 5 |
| github-actions[bot] | 4****]@u****m | 1 |
| CompatHelper Julia | c****y@j****g | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 3
- Total pull requests: 6
- Average time to close issues: 4 months
- Average time to close pull requests: about 5 hours
- Total issue authors: 2
- Total pull request authors: 1
- Average comments per issue: 5.67
- Average comments per pull request: 0.0
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 6
Past Year
- Issues: 0
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: about 1 hour
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 2
Top Authors
Issue Authors
- itsdfish (2)
- JuliaTagBot (1)
Pull Request Authors
- github-actions[bot] (9)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- julia 3 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 5
juliahub.com: AdaptiveDesignOptimization
A Julia package for grid-based adaptive design optimization.
- Documentation: https://docs.juliahub.com/General/AdaptiveDesignOptimization/stable/
- License: MIT
-
Latest release: 0.1.4
published about 2 years ago
Rankings
Dependencies
- JuliaRegistries/TagBot v1 composite
- actions/cache v1 composite
- actions/checkout v2 composite
- codecov/codecov-action v1 composite
- julia-actions/julia-buildpkg v1 composite
- julia-actions/julia-processcoverage v1 composite
- julia-actions/julia-runtest v1 composite
- julia-actions/setup-julia v1 composite
- julia-actions/julia-format v2 composite
- actions/checkout v4 composite
- julia-actions/cache v1 composite
- julia-actions/setup-julia v1 composite
- peter-evans/create-pull-request v6 composite