drawing

Core Functions

TrueAndErrorModels.@make_modelMacro
make_model model_type n_options n_reps

Generates a struct named model_type, constructors and a method for compute_probs based on n_options and n_reps. The struct for model_type and method for compute_probs includes auto-generated documentation.

Arguments

  • model_type: the name of the struct representing the model.
  • n_options::Vector{Int}: the number of options in each choice set, e.g., [2,3] indicates 2 options in

the first choice set and 3 in the second choice set.

  • n_reps: the number of times each choice set is presented. Each repetition occurs in seperate blocks with filler choices.

Example

using TrueAndErrorModels

@make_model MyCoolModel [2,2] 3

model = MyCoolModel(; p = [0.3, 0.40, 0.3, 0.0], ϵ = [0.4, 0.2, 0.2, 0.1])
source
TrueAndErrorModels.compute_probsFunction
compute_probs(model::AbstractTrueErrorModel)

Computes the response probability for each response pattern.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
TrueAndErrorModels.get_error_parm_countFunction
get_error_parm_count(model::AbstractTrueErrorModel)

Returns the number of error parameters.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_error_parm_count(_::Type{<:AbstractTrueErrorModel})

Returns the number of error parameters.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_error_parm_labelsFunction
get_error_parm_labels(model::AbstractTrueErrorModel)

Returns a vector of names corresponding to each error parameter.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_error_parm_labels(_::Type{<:AbstractTrueErrorModel})

Returns a vector of names corresponding to each error parameter.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_equationsFunction
get_equations(model::AbstractTrueErrorModel)

Returns all model equations as a string.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_equations(_::Type{<:AbstractTrueErrorModel})

Returns all model equations as a string.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_equation_countFunction
get_equation_count(model::AbstractTrueErrorModel)

Returns the number of equations in the model which corresponds to the number of response patterns.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_equation_count(_::Type{<:AbstractTrueErrorModel})

Returns the number of equations in the model which corresponds to the number of response patterns.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_n_optionsFunction
get_n_options(model::AbstractTrueErrorModel)

Returns a vector where each element corresponds to the number of options in a choice set.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_n_options(_::Type{<:AbstractTrueErrorModel})

Returns a vector where each element corresponds to the number of options in a choice set.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_n_repsFunction
get_n_reps(model::AbstractTrueErrorModel)

Returns the number of times the choice sets are presented.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_n_reps(_::Type{<:AbstractTrueErrorModel})

Returns the number of times the choice sets are presented.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_response_labelsFunction
get_response_labels(model::AbstractTrueErrorModel)

Returns a vector of labels for the response patterns.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_response_labels(_::Type{<:AbstractTrueErrorModel})

Returns a vector of labels for the response patterns.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_true_parm_labelsFunction
get_true_parm_labels(model::AbstractTrueErrorModel)

Returns a vector of names corresponding to each true parameter.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_true_parm_labels(_::Type{<:AbstractTrueErrorModel})

Returns a vector of names corresponding to each true parameter.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
TrueAndErrorModels.get_true_parm_countFunction
get_true_parm_count(model::AbstractTrueErrorModel)

Returns the number of true parameters.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
get_true_parm_count(_::Type{<:AbstractTrueErrorModel})

Returns the number of true parameters.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
Distributions.logpdfFunction
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
  • data::AbstractVector{<:Integer}: a vector of response pattern frequencies.

Example

using TrueAndErrorModels

n_options = [2, 2]
n_reps = 2
@make_model TestModel n_options n_reps

model = TestModel(; p = [0.3, 0.40, 0.3, 0.0], ϵ = [0.4, 0.2, 0.2, 0.1])
data = rand(model, 100)
LL = logpdf(model, data)
source
TrueAndErrorModels.show_equationsFunction
show_equations(model::AbstractTrueErrorModel)

Displays all model equations.

Arguments

  • model::AbstractTrueErrorModel: a generic true and error model
source
show_equations(_::Type{<:AbstractTrueErrorModel})

Displays all model equations.

Arguments

  • ::Type{<:AbstractTrueErrorModel}: a generic true and error model type
source
Base.randFunction
rand(
    rng::Random.AbstractRNG,
    dist::AbstractTrueErrorModel,
    n_trials::Int64
)

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
  • n_trials: the number of simulated trials

Output

  • data::Vector{<:Integer}: vector of joint response frequencies with the following elements:

Example

using TrueAndErrorModels

n_options = [2, 2]
n_reps = 2
@make_model TestModel n_options n_reps

model = TestModel(; p = [0.3, 0.40, 0.3, 0.0], ϵ = [0.4, 0.2, 0.2, 0.1])
data = rand(model, 100)
source

Utilities

TrueAndErrorModels.to_tableFunction
to_table(
    model::Type{<:AbstractTrueErrorModel},
    x::Vector;
    labels
)

Transforms a vector into a joint response table in which each dimension represents choices in the corresponding block.

Example

using NamedArrays
using TrueAndErrorModels

n_options = [2, 2]
n_reps = 2
@make_model TestModel n_options n_reps

labels = get_response_labels(TestModel)
table = to_table(TestModel, labels)
4×4 Named Matrix{String}
1 ╲ 2 │         (1,1)          (2,1)          (1,2)          (2,2)
──────┼───────────────────────────────────────────────────────────
(1,1) │ "(1,1),(1,1)"  "(1,1),(2,1)"  "(1,1),(1,2)"  "(1,1),(2,2)"
(2,1) │ "(2,1),(1,1)"  "(2,1),(2,1)"  "(2,1),(1,2)"  "(2,1),(2,2)"
(1,2) │ "(1,2),(1,1)"  "(1,2),(2,1)"  "(1,2),(1,2)"  "(1,2),(2,2)"
(2,2) │ "(2,2),(1,1)"  "(2,2),(2,1)"  "(2,2),(1,2)"  "(2,2),(2,2)"
source