
Constructors
TrueAndErrorModels.TrueErrorModel — Type
TrueErrorModel{T <: Real} <: AbstractTrueErrorModel{T}A model object for a True and Error Model of Allias Paradox. Two choice sets are presented twice during the same session, meaning 4 choices are made in total. Subscript r represents risky, subscript s represents safe, and subscripts 1 and 2 represent choice set. For example, pᵣᵣ represents the probability of truely prefering the risky option in both choice sets and ϵₛ₁ represents the error probability of choosing safe given a true preference for risky in first choice set.
Fields
p::AbstractVector{T}: a vector of true preference state probabilities with elementsp = [pᵣᵣ, pᵣₛ, pₛᵣ, pₛₛ], such that sum(p) = 1.ϵ::AbstractVector{T}: a vector of error probabilities with elementsϵ = [ϵₛ₁, ϵₛ₂, ϵᵣ₁, ϵᵣ₂].
Constructors
TrueErrorModel(p, ϵ)
TrueErrorModel(; p, ϵ)
Example
using TrueAndErrorModels
dist = TrueErrorModel(; p = [0.60, .30, .05, .05], ϵ = fill(.10, 4))
data = rand(dist, 200)
logpdf(dist, data)Documentation
Full documentation can be found at https://itsdfish.github.io/TrueAndErrorModels.jl/dev/
References
Birnbaum, M. H., & Quispe-Torreblanca, E. G. (2018). TEMAP2. R: True and error model analysis program in R. Judgment and Decision Making, 13(5), 428-440.
Lee, M. D. (2018). Bayesian methods for analyzing true-and-error models. Judgment and Decision Making, 13(6), 622-635.
Core Functions
TrueAndErrorModels.compute_probs — Function
compute_probs(dist::AbstractTrueErrorModel{T})Computes the joint probability for all 16 response categories
Arguments
dist::AbstractTrueErrorModel{T}: a distribution object for a True and Error Model for two choices sets, each containing
a risky option R and a safe option S.
Output
θ::Vector{T}: vector of joint response probabilities with the following elements:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
Distributions.logpdf — Function
logpdf(dist::AbstractTrueErrorModel, data::AbstractVector{<:Integer})Computes the log loglikelihood of the data for a True and Error Model.
Arguments
dist::AbstractTrueErrorModel{T}: a distribution object for a True and Error Model for two choices sets, each containing a risky option R and a safe option S.data::AbstractVector{<:Integer}: a vector of response pattern frequencies. The elements of this vector are ordered as follows:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
Base.rand — Function
rand(dist::AbstractTrueErrorModel, n_trials::Int)Generate a vector of simulated response frequencies based on the provided True and Error Model.
dist::AbstractTrueErrorModel{T}: a distribution object for a True and Error Model for two choices sets, each containing
a risky option R and a safe option S.
n_trials: the number of simulated trials
Output
data::Vector{<:Integer}: vector of joint response frequencies with the following elements:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
Off-the-shelf Turing Models
TrueAndErrorModels.tet1_model — Function
tet1_model(data::Vector{<:Integer})A True and Error Theory model with one error parameter: ϵₛ₁ = ϵₛ₂ = ϵᵣ₁ = ϵᵣ₂
Arguments
data::Vector{<:Integer}: a vector of response frequencies in which elements corrspond to the following response patterns:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
TrueAndErrorModels.tet2_model — Function
tet2_model(data::Vector{<:Integer})A True and Error Theory model with two error parameters: ϵₛ₁ = ϵᵣ₁, ϵₛ₂ = ϵᵣ₂
Arguments
data::Vector{<:Integer}: a vector of response frequencies in which elements corrspond to the following response patterns:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
TrueAndErrorModels.tet4_model — Function
tet4_model(data::Vector{<:Integer})A True and Error Theory model with four error parameters: ϵₛ₁, ϵᵣ₁, ϵₛ₂, ϵᵣ₂
Arguments
data::Vector{<:Integer}::Union{Vector{<:Integer}, Missing}: a vector of response frequencies in which elements corrspond to the following response patterns:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
TrueAndErrorModels.eut1_model — Function
eut1_model(data::Vector{<:Integer})An expected utility theory model with one error parameter: ϵₛ₁ = ϵₛ₂ = ϵᵣ₁ = ϵᵣ₂. The preference states of all expected utility theory models are subject to the constraint that pᵣₛ = pₛᵣ = 0.
Arguments
data::Vector{<:Integer}: a vector of response frequencies in which elements corrspond to the following response patterns:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
TrueAndErrorModels.eut2_model — Function
eut2_model(data::Vector{<:Integer})An expected utility theory model with two error parameters: ϵₛ₁ = ϵᵣ₁, ϵₛ₂ = ϵᵣ₂. The preference states of all expected utility theory models are subject to the constraint that pᵣₛ = pₛᵣ = 0.
Arguments
data::Vector{<:Integer}: a vector of response frequencies in which elements corrspond to the following response patterns:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
TrueAndErrorModels.eut4_model — Function
eut4_model(data::Vector{<:Integer})An expected utility theory model with four error parameters: ϵₛ₁, ϵᵣ₁, ϵₛ₂, ϵᵣ₂. The preference states of all expected utility theory models are subject to the constraint that pᵣₛ = pₛᵣ = 0.
Arguments
data::Vector{<:Integer}: a vector of response frequencies in which elements corrspond to the following response patterns:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
where S corresponds to choosing the safe option, R corresponds to choosing the risky option, each pair (XX) is the joint choice for choice sets 1 and two, respectively for a given replication. The first pair corresponds to the first replication, and the second pair corresponds to the second replication. For example, SR,RS indicates the selection of the safe option for choice set 1 followed by the risky option for choice set 2 during the first replication, and the reversal of choices for the second replication.
Utilities
TrueAndErrorModels.get_response_labels — Function
get_response_labels()Returns a vector of response pattern labels.
TrueAndErrorModels.to_table — Function
to_table(x::Vector{<:Real})Converts a vector of response frequencies or catetory probabilities to a 4X4 table in which the columns correspond to joint responses on the first replicate and the rows correspond to the joint responses on the second replicate. Labels S correspond to safe option and R corresponds to risky option. The position of elements corresponds to choice set.
Arguments
x::Vector{<:Real}: a vector of response frequencies or catetory probabilities with the following elements:
- RR,RR
- RR,RS
- RR,SR
- RR,SS
- RS,RR
- RS,RS
- RS,SR
- RS,SS
- SR,RR
- SR,RS
- SR,SR
- SR,SS
- SS,RR
- SS,RS
- SS,SR
- SS,SS
Returns
table::NamedArray: a 2×2 table in the following form:
4×4 Named Matrix{String}
2 ╲ 1 │ RR RS SR SS
──────┼───────────────────────────────────
RR │ "RR,RR" "RS,RR" "SR,RR" "SS,RR"
RS │ "RR,RS" "RS,RS" "SR,RS" "SS,RS"
SR │ "RR,SR" "RS,SR" "SR,SR" "SS,SR"
SS │ "RR,SS" "RS,SS" "SR,SS" "SS,SS"