Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

88 flipped hitc #89

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions R/toplikelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#' toplikelihood(fname, cutoff = 1, conc, resp, ps, top, mll)
#' toplikelihood(fname, cutoff = 1.2, conc, resp, ps, top, mll)
toplikelihood = function(fname, cutoff, conc, resp, ps, top, mll, errfun = "dt4"){
#cutoff needs to account for sign otherwise reparameterization will flip the model
cutoff = cutoff*sign(top)

#reparameterize so that top is exactly at cutoff
if(fname == "exp2"){
Expand All @@ -60,8 +62,8 @@ toplikelihood = function(fname, cutoff, conc, resp, ps, top, mll, errfun = "dt4"
#get loglikelihood of top exactly at cutoff, use likelihood profile test
# to calculate probability of being above cutoff
loglik = tcplObj(p = ps, conc = conc, resp = resp, fname = fname, errfun = errfun)
if(abs(top) >= cutoff) out = (1 + pchisq(2*(mll - loglik), 1))/2
if(abs(top) < cutoff) out = (1 - pchisq(2*(mll - loglik), 1))/2
if(abs(top) >= abs(cutoff)) out = (1 + pchisq(2*(mll - loglik), 1))/2
if(abs(top) < abs(cutoff)) out = (1 - pchisq(2*(mll - loglik), 1))/2

return(out)

Expand Down