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

Go to the documentation of this file.
00001 /*! \file ICRF_GPCM.h
00002  
00003   \brief
00004   Class for computing item category response function (ICRF) 
00005   and its derivative for the generalized 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_GPCM_H_
00020 #define ETIRM_ICRF_GPCM_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 
00033   /*! \brief Class for the GPCM item response function.
00034    */
00035   class ICRF_GPCM
00036   {
00037 
00038 public:
00039 
00040     /*! Class Constructor */
00041     ICRF_GPCM(int ncat, Response firstResp) :
00042       mNumCat(ncat), mNumParameters(ncat), mFirstResponse(firstResp), mExpz(ncat)
00043     {
00044     }
00045 
00046     Real ICRF(Response r, const RealVector &param, Real theta) const;
00047     /*!< Return value of item characteristic response function (ICRF)
00048          for response r, parameters in vector param (a, b1, b2, ...),
00049          and theta value.
00050      */
00051 
00052     Real OpenICRF(Response r, const RealVector &param, Real theta) const;
00053     //!< Return value of ICRF in open interval (0,1)
00054 
00055     void ICRFDeriv1(Response r, const RealVector &param, Real theta, RealVector &deriv);
00056     //!< Compute value of first derivative of ICRF (gradient)
00057 
00058     bool GradientDefined() const
00059     {
00060       return true;
00061     }
00062     //!< Function that computes gradient (ICCDeriv1) is defined.
00063 
00064     bool HessianDefined() const
00065     {
00066       return false;
00067     }
00068     //!< Function that computes hessian is not defined.
00069 
00070     void Scale(Real slope, Real intercept, RealVector &param);
00071     //!< Linearly transform item parameters to new IRT scale
00072 
00073     int NumParameters() const
00074     {
00075       return mNumParameters;
00076     }
00077     //!< Return number of estimated parameters.
00078 
00079     int NumAllParameters() const
00080     {
00081       return mNumParameters;
00082     }
00083     /*!< Return number of fixed and estimated parameters.
00084      In this case there are no fixed parameters.
00085      */
00086 
00087     int NumRespCat() const
00088     {
00089       return mNumCat;
00090     }
00091     //!< Return number of response categories
00092 
00093     std::string Name() const
00094     {
00095       return std::string("GPCM");
00096     }
00097     //!< Return name of model
00098 
00099     IRTModel Model() const
00100     {
00101       return GPCM;
00102     }
00103     //!< Return model type from enum defined in etirmtypes.h
00104 
00105     void GetAllParameters(const RealVector &estParam, RealVector &allParam) const;
00106     //!< Copy a, b1, b2, ... parameters from estParam into allParam.
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 || estParam.size() != mNumParameters)
00113         throw InvalidArgument("Wrong number of parameters", "ICRF_GPCM::SetAllParameters");
00114 
00115       RealVector::iterator ie = estParam.begin();
00116       while (begin_param != end_param)
00117       {
00118         *ie = *begin_param;
00119         ++ie;
00120         ++begin_param;
00121       }
00122     }
00123 
00124 private:
00125 
00126     int mNumCat; //!< number of response categories
00127 
00128     int mNumParameters; //!< number of parameters in model
00129 
00130     Response mFirstResponse; //!< response corresponding to the first response category
00131 
00132     RealVector mExpz;
00133     /*!< Holds the terms exp(sum_{k=1}^i z_k), i = 1, mNumCat-1, where
00134      z_k = a * (theta - b_k), a = param[0], b_k = param[k]. Used
00135      in computing the derivative of the ICRF.
00136      */
00137 
00138     Real mDenom; //!< denominator of ICRF
00139 
00140     Real mDenom2; //!< Square of mDenom
00141 
00142     void ExpZ(const RealVector &param, Real theta);
00143     //!< Computes mDenom, mDenom2, and elements of mExpz.
00144 
00145   };
00146 
00147 } // namespace etirm
00148 
00149 #endif // ETIRM_ICRF_GPCM_H_

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