bisection {irtQ} | R Documentation |
The bisection method to find a root
Description
This function is a modified version of the bisetion
function
in the cmna R package (Howard, 2017) to find a root of the function .funs
with respect to its first argument. Unlike the bisetion
of the cmna,
this bisetion
function accepts additional arguments of the function .fun
.
Usage
bisection(.fun, ..., lb, ub, tol = 1e-04, max.it = 100)
Arguments
.fun |
A function for which the root is searched. |
... |
Additional arguments to be passed to |
lb |
A lower bound of the interval to be searched. |
ub |
An upper bound of the interval to be searched. |
tol |
The tolerance of error. Default is 1e-4. |
max.it |
The maximum number of iterations. Default is 100. |
Details
The bisection method is a well-known root finding numerical algorithm that works for any continuous
function when the lower (lb
) and upper (ub
) bounds with opposite signs are provided.
This method repeatedly bisects the defined interval by two values with opposite signs until the absolute
difference of two values becomes less than the error tolerance (tol
) or the maximum
number of iterations (max.it
) is reached.
Value
A list with three internal objects. The first object is the root found, the second object is the number of iterations used, and the third object is the approximate accuracy of the root (i.e., absolute difference between the final two values with opposite signs).
References
Howard, J. P. (2017). Computational methods for numerical analysis with R. New York: Chapman and Hall/CRC.
See Also
Examples
## example: find a theta corresponding to the probability of
## correct answer using the item response function of 2PLM
## (a = 1, b = 0.2)
# set a function of theta
find.th <- function(theta, p) {p - drm(theta=theta, a=1, b=0.2, D=1)}
# find the theta corresponding to p = 0.2
bisection(.fun=find.th, p=0.2, lb=-10, ub=10)$root
# find the theta corresponding to p = 0.8
bisection(.fun=find.th, p=0.8, lb=-10, ub=10)$root