-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement likelihood functions * export likelihood and loglikelihood * add tests * bump version * add docs
- Loading branch information
Showing
6 changed files
with
56 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "ItemResponseFunctions" | ||
uuid = "18e85bec-f2a0-4122-b3a6-37651333b522" | ||
authors = ["Philipp Gewessler <[email protected]>"] | ||
version = "0.1.6" | ||
version = "0.1.7" | ||
|
||
[deps] | ||
AbstractItemResponseModels = "0ab3451c-659c-47cd-a7a9-a2d579e209dd" | ||
|
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,35 @@ | ||
""" | ||
$(SIGNATURES) | ||
Evaluate the likelihood of an item response model `M` at `theta`, given item parameters | ||
`betas` and response pattern `responses`. | ||
Items are assumed to be independent. Then, the likelihood function is defined as, | ||
`` | ||
L(\\boldsymbol{u} | \\theta, \\boldsymbol{\\beta}) = \\prod_{j=1}^J P(Y_j = y | \\theta, \\boldsymbol{\\beta}_j) | ||
`` | ||
See also [`loglikelihood`](@ref). | ||
""" | ||
function likelihood(M::Type{<:ItemResponseModel}, theta, betas, responses) | ||
L = one(theta) | ||
|
||
for (beta, y) in zip(betas, responses) | ||
L *= irf(M, theta, beta, y) | ||
end | ||
|
||
return L | ||
end | ||
|
||
""" | ||
$(SIGNATURES) | ||
Evaluate the log-likelihood of an item response model `M` at `theta`, given item parameters | ||
`betas` and response pattern `responses`, | ||
See also [`likelihood`](@ref). | ||
""" | ||
function loglikelihood(M::Type{<:ItemResponseModel}, theta, betas, responses) | ||
return log(likelihood(M, theta, betas, responses)) | ||
end |
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,11 @@ | ||
@testset "likelihood" begin | ||
betas = [(; b = 0.0) for _ in 1:4] | ||
@test likelihood(OnePL, Inf, betas, ones(length(betas))) == 1.0 | ||
@test likelihood(OnePL, -Inf, betas, ones(length(betas))) == 0.0 | ||
|
||
@test likelihood(OnePL, Inf, betas, zeros(length(betas))) == 0.0 | ||
@test likelihood(OnePL, -Inf, betas, zeros(length(betas))) == 1.0 | ||
|
||
@test loglikelihood(OnePL, Inf, betas, ones(length(betas))) == 0.0 | ||
@test loglikelihood(OnePL, -Inf, betas, ones(length(betas))) == -Inf | ||
end |
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
2298687
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
2298687
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/111491
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: