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

Go to the documentation of this file.
00001 /*! \file ICRF_PCM.h
00002  
00003   \brief
00004   Class for computing item category response function (ICRF) 
00005   and its derivative for the partial credit model.
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-2002, Bradley A. Hanson
00017  */
00018 
00019 #ifndef ETIRM_ICRF_PCM_H_
00020 #define ETIRM_ICRF_PCM_H_
00021 
00022 #ifdef ETIRM_NO_DIR_PREFIX
00023 #include "etirmtypes.h"
00024 #else
00025 #include "etirm/etirmtypes.h"
00026 #endif
00027 
00028 #include <string>
00029 
00030 namespace etirm
00031 {
00032   /*! \brief Class for Masters' PCM item response function.
00033    */
00034   class ICRF_PCM
00035   {
00036 
00037 public:
00038 
00039     /*! Class Constructor */
00040     ICRF_PCM(int ncat, Response firstResp, Real a = 1.0) :
00041       mNumCat(ncat), mNumParameters(ncat-1), mFirstResponse(firstResp), mExpz(ncat), mA(a)
00042     {
00043     }
00044 
00045     Real ICRF(Response r, const RealVector &param, Real theta) const;
00046     /*!< Returns value of item characteristic response function (ICRF)
00047          for response r, parameters in vector param (b1, b2, ...),
00048          and theta value.
00049      */
00050 
00051     Real OpenICRF(Response r, const RealVector &param, Real theta) const;
00052     //!< Returns value of ICRF in open interval (0,1)
00053 
00054     void ICRFDeriv1(Response r, const RealVector &param, Real theta, RealVector &deriv);
00055     //!< Computes value of first derivative of ICRF (gradient)
00056 
00057     bool GradientDefined() const
00058     {
00059       return true;
00060     }
00061     //!< Function indicating that gradient (ICCDeriv1) is defined.
00062 
00063     bool HessianDefined() const
00064     {
00065       return false;
00066     }
00067     //!< Function indicating that Hessian is not defined.
00068 
00069     void Scale(Real slope, Real intercept, RealVector &param);
00070     //!< Compute linear transformation of item parameters onto a new IRT scale
00071 
00072     int NumParameters() const
00073     {
00074       return mNumParameters;
00075     }
00076     //!< Returns number of estimated parameters
00077 
00078     int NumAllParameters() const
00079     {
00080       return mNumParameters+1;
00081     }
00082     //!< Returns number of fixed (a) and estimated (b1, b2, ...) parameters.
00083 
00084     int NumRespCat() const
00085     {
00086       return mNumCat;
00087     }
00088     //!< Returns number of response categories
00089 
00090     std::string Name() const
00091     {
00092       return std::string("PCM");
00093     }
00094     //!< Return name of model
00095 
00096     IRTModel Model() const
00097     {
00098       return PCM;
00099     }
00100     //!< Return model type from enum defined in etirmtypes.h
00101 
00102     void GetAllParameters(const RealVector &estParam, RealVector &allParam) const;
00103     /*!< Copy fixed a parameter and estimated b parameters from estParam into allParam.
00104          Set a, b1, b2, ... parameters, where a is fixed, and
00105          b1, b2, ... are estimated.
00106       */
00107     
00108     //! Set a, b1, b2, ... parameters
00109     template <class I> void SetAllParameters(I begin_param, I end_param, RealVector &estParam)
00110     {
00111 
00112       if ((end_param - begin_param) != (mNumParameters+1) || estParam.size() != mNumParameters)
00113         throw InvalidArgument("Wrong number of parameters", "ICRF_PCM::SetAllParameters");
00114 
00115       mA = *begin_param++;
00116       RealVector::iterator ie = estParam.begin();
00117       while (begin_param != end_param)
00118       {
00119         *ie = *begin_param;
00120         ++ie;
00121         ++begin_param;
00122       }
00123     }
00124 
00125 private:
00126 
00127     int mNumCat; //!< number of response categories
00128 
00129     int mNumParameters; //!< number of estimated parameters in model
00130 
00131     Real mA;
00132     //!< slope parameter
00133 
00134     Response mFirstResponse;
00135     //!< Response associated with first response category
00136 
00137     RealVector mExpz;
00138     /*!< Holds the terms exp(sum_{k=1}^i z_k), i = 1, mNumCat-1, where
00139          z_k = a * (theta - b_k), a = param[0], b_k = param[k]. Used
00140          in computing the derivative of the ICRF.
00141      */
00142 
00143     Real mDenom; //!< denominator of ICRF
00144 
00145     Real mDenom2; //!< Square of mDenom
00146 
00147     void ExpZ(const RealVector &param, Real theta);
00148     //!< Computes mDenom, mDenom2, and elements of mExpz.
00149 
00150   };
00151 
00152 } // namespace etirm
00153 
00154 #endif // ETIRM_ICRF_GPCM_H_

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