C:/programs/etirm/src/ExamineeThetaMLE.h

Go to the documentation of this file.
00001 /*! \file ExamineeThetaMLE.h
00002  
00003   \brief
00004   Compute maximum likelihood estimate of latent variable (theta)
00005   for an examinee.
00006 
00007   Estimation Toolkit for Item Response Models (ETIRM)
00008   http://www.smallwaters.com/software/cpp/etirm.html
00009 
00010   Author(s): 
00011   Werner Wothke, maintenance (http://www.smallwaters.com)
00012   Brad Hanson (http://www.b-a-h.com/)
00013   See the file LICENSE for information on usage and redistribution.
00014 
00015   Copyright (C) 2008, Werner Wothke
00016   Copyright (c) 2000-2001, Bradley A. Hanson
00017  */
00018 
00019 #ifndef ETIRM_EXAMINEETHETAMLE_H_
00020 #define ETIRM_EXAMINEETHETAMLE_H_
00021 
00022 #ifdef ETIRM_NO_DIR_PREFIX
00023 #include "ThetaLogLikelihood.h"
00024 #else
00025 #include "etirm/ThetaLogLikelihood.h"
00026 #endif
00027 
00028 // Function ExamineeThetaMLE uses Fmin univariate minimization
00029 // function which is part of the Uncmin++ package
00030 // (http://www.smallwaters.com/software/cpp/uncmin.html).
00031 #include "Fmin.h"
00032 
00033 namespace etirm
00034 {
00035   /*! 
00036     \brief
00037    Compute latent variable estimate for an examinee using 
00038    maximum likelihood. Returns the latent trait estimate for the examinee.
00039    
00040    \section template_args Template Parameter
00041    
00042      \param L Function type returning minus the loglihood. An object of this
00043      type is passed to minimization procedure.
00044    
00045    \section function_args Function Parameters
00046 
00047      \param [in]  minTheta  Minimum value of theta estimate
00048      \param [in]  maxTheta  Maximum value of theta estimate 
00049      \param [in]  precision Length of interval in which MLE is determined to lie.
00050        This should be greater than, roughly, 3.0e-8.
00051      \param [in]  likelihood  The function to minimize (minus the loglikelihood).
00052    */
00053   template<class L> Real ExamineeThetaMLE(Real minTheta, Real maxTheta, Real precision,
00054       L &likelihood)
00055   {
00056     Real midTheta = (minTheta + maxTheta) / 2.0;
00057 
00058     // See if middle value is bracketed
00059     Real fmin = likelihood(minTheta);
00060     Real fmid = likelihood(midTheta);
00061     Real fmax = likelihood(maxTheta);
00062 
00063     Real theta;
00064 
00065     // Compute minimum on two intervals and take the one corresponding to the largest
00066     // likelihood. This reduces the chances of a local minimum being identified by Fmin when the
00067     // function is multimodal and is not bracketed.
00068     fmin = Fmin(minTheta, midTheta, likelihood, precision);
00069     fmax = Fmin(midTheta, maxTheta, likelihood, precision);
00070     
00071     theta = (likelihood(fmin) < likelihood(fmax)) ? fmin : fmax;
00072     return theta;
00073   }
00074 
00075   /*! 
00076     \brief
00077     Compute latent variable estimate for an examinee using 
00078     maximum likelihood, create a ThetaLogLikelihood object 
00079     from two item iterators and an interator to the examinee 
00080     responses, and return the latent trait estimate for the examinee.
00081       
00082     \section template_args Template Parameters
00083    
00084     \param  II Iterator type over pointers to item objects.
00085     \param  IR Iterator type over examinee responses to items.
00086 
00087     \section function_args Function Parameters
00088 
00089     \param[in] minTheta Minimum value of theta estimate
00090     \param[in]  maxTheta  Maximum value of theta estimate 
00091     \param[in]  precision Length of interval in which MLE is determined to lie.
00092             This should be greater than, roughly, 3.0e-8.
00093     \param[in] items_begin  Iterator pointing to first item object pointer.
00094     \param[in]  items_end Iterator pointing to one past the last item object pointer.
00095     \param[in]  responses_begin Iterator pointing to examinee's response to first item.
00096  
00097 
00098 
00099    */
00100   template<class II, class IR> Real ExamineeThetaMLE(Real minTheta, Real maxTheta, Real precision,
00101       II items_begin, II items_end, IR responses_begin)
00102   {
00103     // Last argument being true indicates the function object
00104     // should return the negative of the likelihood since
00105     // the function will be minimized, not maximized.
00106     ThetaLogLikelihood<II,IR> likelihood(items_begin, items_end, responses_begin, true);
00107 
00108     return ExamineeThetaMLE(minTheta, maxTheta, precision, likelihood);
00109 
00110   }
00111 
00112 } // namespace etirm
00113 
00114 #endif // ETIRM_EXAMINEETHETAMLE_H_

Generated on Sat Mar 1 21:40:15 2008 for ETIRM by  doxygen 1.5.4