C:/programs/etirm/src/MStepIRT.cpp

Go to the documentation of this file.
00001 /*! \file MStepIRT.cpp
00002  
00003   \brief
00004   Functions useful in implementing the M-step for IRT models. 
00005 
00006   Estimation Toolkit for Item Response Models (ETIRM)
00007   http://www.smallwaters.com/software/cpp/etirm.html
00008 
00009   Author(s): 
00010   Werner Wothke, maintenance (http://www.smallwaters.com)
00011   Brad Hanson (http://www.b-a-h.com/)
00012   See the file LICENSE for information on usage and redistribution.
00013 
00014   Copyright (C) 2008, Werner Wothke
00015   Copyright (c) 2000-2001, Bradley A. Hanson
00016 */
00017 
00018 #ifdef ETIRM_NO_DIR_PREFIX
00019 #include "MStepIRT.h"
00020 #else
00021 #include "etirm/MStepIRT.h"
00022 #endif
00023 
00024 namespace etirm
00025 {
00026 
00027 /*
00028   Returns the maximum relative difference between an old and new set of item parameters.
00029   
00030   \param[in] &oldParam  Address of vector containing base parameter values.
00031   \param[in] &newParam  Address of vector containing comparison (new) parameter values.
00032   \param[in] typicalValue Minimum denominator for relative comparison.
00033 */
00034 double MaxRelParamDiff(RealVector &oldParam, RealVector &newParam, Real typicalValue)
00035 {
00036   double reldiff = 0.0;
00037   
00038   RealVector::iterator iold = oldParam.begin();
00039   RealVector::iterator inew = newParam.begin();
00040   
00041   for (int n = oldParam.size(); n--; ++iold, ++inew)
00042   {
00043     Real d = *iold - *inew;
00044     Real denom = *inew;
00045     denom = (denom < 0.0) ? -denom : denom; // fabs(denom)
00046     denom = (denom < typicalValue) ? typicalValue : denom;
00047     if (denom != 0.0) d /= denom;
00048     d = (d < 0.0) ? -d : d; // fabs(d)
00049     if (reldiff < d) reldiff = d;
00050   }
00051   
00052   return reldiff;
00053 }
00054 
00055 } // namespace etirm

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