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

Go to the documentation of this file.
00001 /*! \file ICCLogistic.h
00002  
00003  \brief
00004  Class for computing item characteristic curve (ICC) of 
00005  1, 2, and 3-parameter logistic models, as well
00006  as first and second derivatives of ICC.
00007 
00008  Estimation Toolkit for Item Response Models (ETIRM)
00009  http://www.smallwaters.com/software/cpp/etirm.html
00010 
00011  Author(s): 
00012  Werner Wothke, maintenance (http://www.smallwaters.com)
00013  Brad Hanson (http://www.b-a-h.com/)
00014  See the file LICENSE for information on usage and redistribution.
00015 
00016  Copyright (C) 2008, Werner Wothke
00017  Copyright (c) 2000-2002, Bradley A. Hanson
00018  */
00019 
00020 #ifndef ETIRM_ICCLOGISTIC_H_
00021 #define ETIRM_ICCLOGISTIC_H_
00022 
00023 #ifdef ETIRM_NO_DIR_PREFIX
00024 #include "etirmtypes.h"
00025 #else
00026 #include "etirm/etirmtypes.h"
00027 #endif
00028 
00029 #include <string>
00030 
00031 namespace etirm
00032 {
00033 
00034   /*! 
00035    \brief 
00036    Common functions and data members used for specializations of ICCLogistic. 
00037    */
00038   class ICC3PLFunc
00039   {
00040 
00041 protected:
00042 
00043     /*!
00044       \brief
00045       Logistic response function class for dichotomous items.
00046       
00047       \section function_args Function Parameters
00048    
00049       \param[in]  nparam  Number of estimated item parameters (1, 2, or 3).
00050       \param[in]  D Scale constant defining the metric of the parameter estimates. 
00051           Typical choices are 1 (for the logistic metric) and 1.7 (for the normal-ogive metric).
00052      */
00053     ICC3PLFunc(int nparam, Real D) :
00054       mD(D), numParameters(nparam)
00055     {
00056     }
00057 
00058     /*!
00059       \brief
00060       Returns the probability of a correct response for the 3PL item with parameters 
00061       a, b, c, and ability value theta.
00062       
00063       \section function_args Function Parameters
00064    
00065       \param[in]  a Item slope parameter.
00066       \param[in]  b Item location parameter.
00067       \param[in]  c Item pseudo-guessing parameter.
00068       \param[in]  theta Examinee ability parameter.
00069      */
00070     Real ICC3PL(Real a, Real b, Real c, Real theta) const;
00071 
00072     /*!
00073       \brief
00074       Returns the probability in the open interval (0, 1) of a correct response for 
00075       the 3PL item with parameters a, b, c, and ability value theta.
00076       
00077       This function can be used when the logarithm of the probability or logit of 
00078       the probability needs to be taken.
00079 
00080       \section function_args Function Parameters
00081    
00082       \param[in]  a Item slope parameter.
00083       \param[in]  b Item location parameter.
00084       \param[in]  c Item pseudo-guessing parameter.
00085       \param[in]  theta Examinee ability parameter.
00086      */
00087     Real OpenICC3PL(Real a, Real b, Real c, Real theta) const;
00088 
00089     /*!
00090       \brief
00091       Computes (gradient) vector of first partial derivatives of the 3PL model with respect to item parameters.
00092       
00093       Returns results in deriv vector.
00094 
00095       \section function_args Function Parameters
00096 
00097       \param[in]  numParam Number of parameters (1, 2, or 3) of Logistic IRT model.   
00098       \param[in]  a Item slope parameter.
00099       \param[in]  b Item location parameter.
00100       \param[in]  c Item pseudo-guessing parameter.
00101       \param[in]  theta Examinee ability parameter.
00102       \param[out] &deriv  Address of gradient vector of length numParam. 
00103      */
00104     void ICC3PLDeriv1(int numParam, Real a, Real b, Real c, Real theta, RealVector &deriv) const;
00105 
00106     /*!
00107       \brief
00108       Computes (hessian) matrix of second partial derivatives of the 3PL model with respect to item parameters.
00109       
00110       Returns results in deriv matrix.
00111 
00112       \section function_args Function Parameters
00113 
00114       \param[in]  numParam Number of parameters (1, 2, or 3) of Logistic IRT model.   
00115       \param[in]  a Item slope parameter.
00116       \param[in]  b Item location parameter.
00117       \param[in]  c Item pseudo-guessing parameter.
00118       \param[in]  theta Examinee ability parameter.
00119       \param[out] &deriv  Address of hessian matrix of dimension numParam. Only the lower half and diagonal 
00120           of the matrix are populated, the upper off-diagonal entries remain undefined.
00121      */
00122     void ICC3PLDeriv2(int numParam, Real a, Real b, Real c, Real theta, RealMatrix &deriv) const;
00123 
00124     /*!
00125       \brief
00126       Transforms the parameters of a logistic item to a different latent variable scale.
00127    
00128       \section function_args Function Parameters
00129 
00130       \param[in]  slope Slope parameter of linear scale transformation.
00131       \param[in]  intercept Intercept parameter of linear scale transformation.
00132       \param[in,out]  a Item slope parameter.
00133       \param[in,out]  b Item location parameter.
00134      */
00135     void Scale(Real slope, Real intercept, Real &a, Real &b)
00136     {
00137       a /= slope;
00138       b *= slope;
00139       b += intercept;
00140     }
00141 
00142     //! D constant in ICC, use D=1.0 for logistic metric, D=1.7 for normal-ogive metric.
00143     Real mD;
00144 
00145     //! Number of parameters in the (logistic) item response model.
00146     int numParameters; 
00147 
00148   };
00149 
00150   /*!
00151     \brief
00152     Class declaration of logistic item response model; specializations supplied for NPAR = 1, 2, 3.
00153    
00154     \section template_args Template Parameters
00155    
00156     \param NPAR Number of parameter used for instantiation of the dichotomous 
00157         IRT model. Valid options are 1, 2, or 3.
00158    */
00159     template <int NPAR> class ICCLogistic
00160   {
00161 
00162 private:
00163 
00164     /*!
00165      \brief
00166      Private constructor prevents any objects of this type from being created with 
00167      NPAR not equal to one of the values for which a specilization is supplied.
00168      */
00169     ICCLogistic()
00170     {
00171     }
00172 
00173   };
00174 
00175   /*!
00176     \brief
00177     Three-parameter logistic item response model.
00178    */
00179   template <> class ICCLogistic<3> : private ICC3PLFunc
00180   {
00181 
00182 public:
00183 
00184     /*!
00185       \brief 
00186       Instantiation of logistic item response model, fixing scale constant.
00187       
00188       \section function_args Function Parameters
00189    
00190       \param[in]  D Scale constant defining the metric of the parameter estimates. 
00191           Typical choices are 1 (for the logistic metric) and 1.7 (for the 
00192           normal-ogive metric).
00193      */ 
00194     ICCLogistic(Real D); // Corrected typo (was "ICLogistics), ww, 2-23-2008
00195 
00196     /*! 
00197       \brief
00198       Returns value of the 3PL item characteristic curve (ICC) for a set of item parameters 
00199       and theta value.
00200       
00201       \section function_args Function Parameters
00202 
00203       \param[in]  &param Address of item parameter vector with entries = (a, b, c).
00204       \param[in]  theta Examinee ability parameter.
00205      */
00206     Real ICC(const RealVector &param, Real theta) const
00207     {
00208       return ICC3PL(param(1), param(2), ValidC(param(3)), theta);
00209     }
00210 
00211     /*! 
00212       \brief
00213       Returns value of the 3PL item characteristic curve (ICC) in open interval (0, 1); 
00214       for a set of item parameters and theta value.
00215       
00216       This function version can be used when the logarithm of the probability or 
00217       logit of the probability needs to be taken.
00218       
00219       \section function_args Function Parameters
00220 
00221       \param[in]  &param Address of item parameter vector with entries = (a, b, c).
00222       \param[in]  theta Examinee ability parameter.
00223      */
00224     Real OpenICC(const RealVector &param, Real theta) const
00225     {
00226       return OpenICC3PL(param(1), param(2), ValidC(param(3)), theta);
00227     }
00228 
00229     /*!
00230       \brief
00231       Computes (gradient) vector of first partial derivatives of the 3PL model with 
00232       respect to item parameters.
00233       
00234       Returns results in deriv vector.
00235 
00236       \section function_args Function Parameters
00237 
00238       \param[in]  &param Address of item parameter vector with entries (a, b, c).
00239       \param[in]  theta Examinee ability parameter.
00240       \param[out] &deriv  Address of gradient vector of length 3. 
00241      */
00242     void ICCDeriv1(const RealVector &param, Real theta, RealVector &deriv) const
00243     {
00244       ICC3PLDeriv1(3, param(1), param(2), ValidC(param(3)), theta, deriv);
00245     }
00246 
00247     /*!
00248       \brief
00249       Computes (hessian) matrix of second partial derivatives of the 3PL model 
00250       with respect to item parameters.
00251       
00252       Returns results in deriv matrix.
00253 
00254       \section function_args Function Parameters
00255 
00256       \param[in]  &param Address of item parameter vector with entries (a, b, c).
00257       \param[in]  theta Examinee ability parameter.
00258       \param[out] &deriv  Address of 3x3 hessian matrix. Only the lower half and diagonal 
00259           of the matrix are populated, the upper off-diagonal entries remain undefined.
00260      */
00261     void ICCDeriv2(const RealVector &param, Real theta, RealMatrix &deriv) const
00262     {
00263       ICC3PLDeriv2(3, param(1), param(2), ValidC(param(3)), theta, deriv);
00264     }
00265 
00266     /*!
00267       \brief
00268       Function to indicate that the algebraic gradient of the item (ICCDeriv1) is defined.
00269       
00270       This function can be used by UNCMIN++.
00271      */
00272     bool GradientDefined() const
00273     {
00274       return true;
00275     }
00276 
00277     /*!
00278       \brief
00279       Function to indicate that the algebraic hessian of the item (ICCDeriv2) is defined.
00280       
00281       This function can be used by UNCMIN++.
00282      */
00283     bool HessianDefined() const
00284     {
00285       return true;
00286     }
00287 
00288     /*!
00289       \brief
00290       Transforms the parameters of a logistic item to a different latent variable scale.
00291    
00292       \section function_args Function Parameters
00293 
00294       \param[in]  slope Slope parameter of linear scale transformation.
00295       \param[in]  intercept Intercept parameter of linear scale transformation.
00296       \param[in,out]  &param Address of item parameter vector to be transformed. Only the
00297           first two entries (slope and location) will be transformed.
00298      */
00299     void Scale(Real slope, Real intercept, RealVector &param)
00300     {
00301       ICC3PLFunc::Scale(slope, intercept, param(1), param(2));
00302     }
00303 
00304     //! Returns scaling constant D.
00305     Real GetD() const
00306     {
00307       return mD;
00308     }
00309 
00310     /*!
00311       \brief
00312       Copies a, b, and c parameters from estParam into allParam.
00313       
00314       \section function_args Function Parameters
00315 
00316       \param[in]  &estParam Address of vector of item parameter estimates.
00317       \param[out]  &allParam Address of copied item parameter vector.
00318      */
00319     void GetAllParameters(const RealVector &estParam, RealVector &allParam) const;
00320 
00321     //! Returns number of estimated parameters.
00322     int NumParameters() const
00323     {
00324       return numParameters;
00325     }
00326 
00327     //! Returns sum of number of fixed and estimated parameters.
00328     int NumAllParameters() const
00329     {
00330       return numParameters;
00331     }
00332 
00333     /*!
00334       \brief
00335       Returns true if vector param contains valid item parameters.
00336       
00337       \section function_args Function Parameters
00338 
00339       \param[in]  &param Address of item parameter vector.
00340      */      
00341     bool ValidParameters(const RealVector &param) const
00342     {
00343       return (param(3) >= 0.0 && param(3) <= 1.0);
00344     }
00345 
00346     //! Returns name of model.
00347     std::string Name() const
00348     {
00349       return std::string("3PL");
00350     }
00351     
00352     //! Returns model type from enum defined in etirmtypes.h
00353     IRTModel Model() const
00354     {
00355       return ThreePL;
00356     }
00357 
00358     /*! 
00359       \brief
00360       Assigns all item parameters (a, b, and c), fixed and estimated.
00361       
00362       \section template_args Template Parameters
00363    
00364       \param I  Type of iterator over item parameters. 
00365     
00366       \section function_args Function Parameters
00367    
00368       \param[in]  begin_param Iterator pointing to first item parameter for the item.
00369       \param[in]  end_param Iterator point to one after the last parameter for the item.
00370       \param[out] &estParam Address to vector "all" parameters for this item.
00371      */
00372     template <class I> void SetAllParameters(I begin_param, I end_param, RealVector &estParam)
00373     {
00374       if ((end_param - begin_param) != 3 || estParam.size() != 3)
00375         throw InvalidArgument("Wrong number of parameters", "ICCLogistic<3>::SetAllParameters");
00376 
00377       if (begin_param[2] < 0.0 || begin_param[2] > 1.0)
00378         throw InvalidArgument("Invalid c parameter","ICCLogistic<3>::SetAllParameters");
00379 
00380       RealVector::iterator ie = estParam.begin();
00381       for (int i = 3; i--; ++ie, ++begin_param)
00382       {
00383         *ie = *begin_param;
00384       }
00385     }
00386 
00387 private:
00388 
00389     /*!
00390       \brief
00391       Returns c parameter, if valid, or throws an exception otherwise.
00392       \section function_args Function Parameters
00393       
00394       \param[in]  c Pseudo-guessing parameter c for the item.
00395     */ 
00396     Real ValidC(Real c) const
00397     {
00398       if (c < 0.0 || c > 1.0)throw RuntimeError("Invalid c parameter","ICCLogistic<3>::ValidC"); 
00399     
00400       return c;
00401     }
00402   };
00403 
00404   /*!
00405     \brief
00406     Two-parameter logistic item response model.
00407    */
00408   template <>
00409   class ICCLogistic<2> : private ICC3PLFunc
00410   {
00411 
00412   public:
00413 
00414     /*!
00415       \brief 
00416       Instantiation of 2-parameter logistic item response model, fixing scale constant D and 
00417       pseudo-guessing parameter c.
00418       
00419       \section function_args Function Parameters
00420    
00421       \param[in]  D Scale constant defining the metric of the parameter estimates. 
00422           Typical choices are 1 (for the logistic metric) and 1.7 (for the 
00423           normal-ogive metric).
00424       \param[in]  c Pseudo-guessing parameter for the item.
00425      */ 
00426     ICCLogistic(Real D, Real c);
00427 
00428     /*! 
00429       \brief
00430       Returns value of item characteristic curve (ICC) of the 2PL model for a 
00431       set of item parameters and theta value.
00432       
00433       \section function_args Function Parameters
00434 
00435       \param[in]  &param Address of item parameter vector with entries = (a, b).
00436       \param[in]  theta Examinee ability parameter.
00437      */
00438     Real ICC(const RealVector &param, Real theta) const
00439     {
00440       return ICC3PL(param(1), param(2), fixedC, theta);
00441     }
00442 
00443     /*! 
00444       \brief
00445       Returns value of item characteristic curve (ICC) of the 2PL model in the 
00446       open interval (0, 1), for a set of item parameters and theta value.
00447       
00448       This function version can be used when the logarithm of the probability or 
00449       logit of the probability needs to be taken.
00450       
00451       \section function_args Function Parameters
00452 
00453       \param[in]  &param Address of item parameter vector with entries = (a, b).
00454       \param[in]  theta Examinee ability parameter.
00455      */
00456     Real OpenICC(const RealVector &param, Real theta) const
00457     {
00458       return OpenICC3PL(param(1), param(2), fixedC, theta);
00459     }
00460 
00461     /*!
00462       \brief
00463       Computes (gradient) vector of first partial derivatives of the 2PL model with 
00464       respect to item parameters.
00465       
00466       Returns results in deriv vector.
00467 
00468       \section function_args Function Parameters
00469 
00470       \param[in]  &param Address of item parameter vector with entries (a, b).
00471       \param[in]  theta Examinee ability parameter.
00472       \param[out] &deriv  Address of gradient vector of length 2. 
00473      */
00474     void ICCDeriv1(const RealVector &param, Real theta, RealVector &deriv) const
00475     {
00476       ICC3PLDeriv1(2, param(1), param(2), fixedC, theta, deriv);
00477     }
00478 
00479     /*!
00480       \brief
00481       Computes (hessian) matrix of second partial derivatives of the 2PL model 
00482       with respect to item parameters.
00483       
00484       Returns results in deriv matrix.
00485 
00486       \section function_args Function Parameters
00487 
00488       \param[in]  &param Address of item parameter vector with entries (a, b).
00489       \param[in]  theta Examinee ability parameter.
00490       \param[out] &deriv  Address of 2x2 hessian matrix. Only the lower half and diagonal 
00491           of the matrix are populated, the upper off-diagonal entries remain undefined.
00492      */
00493     void ICCDeriv2(const RealVector &param, Real theta, RealMatrix &deriv) const
00494     {
00495       ICC3PLDeriv2(2, param(1), param(2), fixedC, theta, deriv);
00496     }
00497 
00498     /*!
00499       \brief
00500       Function to indicate that the algebraic gradient of the item (ICCDeriv1) is defined.
00501       
00502       This function can be used by UNCMIN++.
00503      */
00504     bool GradientDefined() const
00505     { 
00506       return true;
00507     }
00508 
00509     /*!
00510       \brief
00511       Function to indicate that the algebraic hessian of the item (ICCDeriv2) is defined.
00512       
00513       This function can be used by UNCMIN++.
00514      */
00515     bool HessianDefined() const
00516     { 
00517       return true;
00518     }
00519 
00520     /*!
00521       \brief
00522       Transforms the parameters of a 2-parameter logistic item to a different latent 
00523       variable scale.
00524    
00525       \section function_args Function Parameters
00526 
00527       \param[in]  slope Slope parameter of linear scale transformation.
00528       \param[in]  intercept Intercept parameter of linear scale transformation.
00529       \param[in,out]  &param Address of item parameter vector (slope and intercept) to be 
00530           transformed.
00531      */
00532     void Scale(Real slope, Real intercept, RealVector &param)
00533     {
00534       ICC3PLFunc::Scale(slope, intercept, param(1), param(2));
00535     }
00536 
00537     //! Returns scaling constant D.
00538     Real GetD() const
00539     { 
00540       return mD;
00541     }
00542 
00543     /*!
00544       \brief
00545       Copies a, b, and c parameters from estParam into allParam.
00546       
00547       \section function_args Function Parameters
00548 
00549       \param[in]  &estParam Address of vector of item parameter estimates.
00550       \param[out]  &allParam Address of copied item parameter vector.
00551      */
00552     void GetAllParameters(const RealVector &estParam, RealVector &allParam) const;
00553 
00554     //! Returns number of estimated parameters.
00555     int NumParameters() const
00556     { 
00557       return numParameters;
00558     }
00559 
00560     //! Returns sum of number of fixed and estimated parameters.
00561     int NumAllParameters() const
00562     { 
00563       return numParameters+1;
00564     }
00565 
00566     /*!
00567       \brief
00568       Returns true if vector param contains valid item parameters.
00569       
00570       \section function_args Function Parameters
00571 
00572       \param[in]  & Address of item parameter vector (not used with this model).
00573      */ 
00574     bool ValidParameters(const RealVector &/* param */) const
00575     { 
00576       return true;
00577     }
00578 
00579     //! Returns name of model.
00580     std::string Name() const
00581     { 
00582       return std::string("2PL");
00583     }
00584 
00585     //! Returns model type from enum defined in etirmtypes.h
00586     IRTModel Model() const
00587     { 
00588       return TwoPL;
00589     }
00590 
00591     /*! 
00592       \brief
00593       Assigns all item parameters (a, b, and c), fixed and estimated.
00594       
00595       \section template_args Template Parameters
00596    
00597       \param I  Type of iterator over item parameters. 
00598     
00599       \section function_args Function Parameters
00600    
00601       \param[in]  begin_param Iterator pointing to first item parameter for the item.
00602       \param[in]  end_param Iterator point to one after the last parameter for the item.
00603       \param[out] &estParam Address to vector "all" parameters for this item.
00604      */
00605     template <class I>
00606     void SetAllParameters(I begin_param, I end_param, RealVector &estParam)
00607     {
00608 
00609       if ((end_param - begin_param) != 3 || estParam.size() != 2)
00610       throw InvalidArgument("Wrong number of parameters", "ICCLogistic<2>::SetAllParameters");
00611 
00612       if (begin_param[2] < 0.0 || begin_param[2]> 1.0) throw InvalidArgument("Invalid c parameter","ICCLogistic<2>::SetAllParameters");
00613 
00614       RealVector::iterator ie = estParam.begin();
00615       for (int i = 2; i--; ++ie, ++begin_param)
00616       {
00617         *ie = *begin_param;
00618       }
00619 
00620       fixedC = *begin_param;
00621     }
00622 
00623   private:
00624     
00625     //! fixed c parameter
00626     Real fixedC;
00627 
00628   };
00629 
00630   /*!
00631     \brief
00632     One-parameter logistic item response model.
00633    */
00634   template <>
00635   class ICCLogistic<1> : private ICC3PLFunc
00636   {
00637 
00638   public:
00639 
00640     /*!
00641       \brief 
00642       Instantiation of 1-parameter logistic item response model, fixing scale constant D,
00643       slope a and pseudo-guessing parameter c.
00644       
00645       \section function_args Function Parameters
00646    
00647       \param[in]  D Scale constant defining the metric of the parameter estimates. 
00648           Typical choices are 1 (for the logistic metric) and 1.7 (for the 
00649           normal-ogive metric).
00650       \param[in]  a Item slope parameter.
00651       \param[in]  c Pseudo-guessing parameter for the item.
00652      */ 
00653     ICCLogistic(Real D, Real a, Real c);
00654 
00655     /*! 
00656       \brief
00657       Returns value of item characteristic curve (ICC) of the 1PL model for a 
00658       set of item parameters and theta value.
00659       
00660       \section function_args Function Parameters
00661 
00662       \param[in]  &param Address of item parameter vector with entry = (b).
00663       \param[in]  theta Examinee ability parameter.
00664      */
00665     Real ICC(const RealVector &param, Real theta) const
00666     {
00667       return ICC3PL(fixedA, param(1), fixedC, theta);
00668     }
00669 
00670     /*! 
00671       \brief
00672       Returns value of item characteristic curve (ICC) of the 1PL model in the 
00673       open interval (0, 1), for a set of item parameters and theta value.
00674       
00675       This function version can be used when the logarithm of the probability or 
00676       logit of the probability needs to be taken.
00677       
00678       \section function_args Function Parameters
00679 
00680       \param[in]  &param Address of item parameter vector with entries = (b).
00681       \param[in]  theta Examinee ability parameter.
00682      */
00683     Real OpenICC(const RealVector &param, Real theta) const
00684     {
00685       return OpenICC3PL(fixedA, param(1), fixedC,theta);
00686     }
00687 
00688     /*!
00689       \brief
00690       Computes (gradient) vector of first partial derivatives of the 1PL model with 
00691       respect to item parameters.
00692       
00693       Returns results in deriv vector.
00694 
00695       \section function_args Function Parameters
00696 
00697       \param[in]  &param Address of item parameter vector with entries (b).
00698       \param[in]  theta Examinee ability parameter.
00699       \param[out] &deriv  Address of gradient vector of length 1. 
00700      */
00701     void ICCDeriv1(const RealVector &param, Real theta, RealVector &deriv) const
00702     {
00703       ICC3PLDeriv1(1, fixedA, param(1), fixedC, theta, deriv);
00704     }
00705 
00706     /*!
00707       \brief
00708       Computes (hessian) matrix of second partial derivatives of the 1PL model 
00709       with respect to item parameters.
00710       
00711       Returns results in deriv matrix.
00712 
00713       \section function_args Function Parameters
00714 
00715       \param[in]  &param Address of item parameter vector with entries (b).
00716       \param[in]  theta Examinee ability parameter.
00717       \param[out] &deriv  Address of 1x1 hessian matrix. Only the lower half and diagonal 
00718           of the matrix are populated, the upper off-diagonal entries remain undefined.
00719      */
00720     void ICCDeriv2(const RealVector &param, Real theta, RealMatrix &deriv) const
00721     {
00722       ICC3PLDeriv2(1, fixedA, param(1), fixedC, theta, deriv);
00723     }
00724 
00725     /*!
00726       \brief
00727       Function to indicate that the algebraic gradient of the item (ICCDeriv1) is defined.
00728       
00729       This function can be used by UNCMIN++.
00730      */
00731     bool GradientDefined() const
00732     { 
00733       return true;
00734     }
00735 
00736     /*!
00737       \brief
00738       Function to indicate that the algebraic hessian of the item (ICCDeriv2) is defined.
00739       
00740       This function can be used by UNCMIN++.
00741      */
00742     bool HessianDefined() const
00743     { 
00744       return true;
00745     }
00746 
00747     /*!
00748       \brief
00749       Transforms the parameters of a 1-parameter logistic item to a different latent 
00750       variable scale.
00751    
00752       \section function_args Function Parameters
00753 
00754       \param[in]  slope Slope parameter of linear scale transformation.
00755       \param[in]  intercept Intercept parameter of linear scale transformation.
00756       \param[in,out]  &param Address of item parameter vector (item location only) to be 
00757           transformed.
00758      */
00759     void Scale(Real slope, Real intercept, RealVector &param)
00760     {
00761       ICC3PLFunc::Scale(slope, intercept, fixedA, param(1));
00762     }
00763 
00764     //! Returns scaling constant D.
00765     Real GetD() const
00766     { 
00767       return mD;
00768     }
00769 
00770     /*!
00771       \brief
00772       Copies a, b, and c parameters from estParam into allParam.
00773       
00774       \section function_args Function Parameters
00775 
00776       \param[in]  &estParam Address of vector of item parameter estimates.
00777       \param[out]  &allParam Address of copied item parameter vector.
00778      */
00779     void GetAllParameters(const RealVector &estParam, RealVector &allParam) const;
00780 
00781     //! Returns number of estimated parameters.
00782     int NumParameters() const
00783     { 
00784       return numParameters;
00785     }
00786 
00787     //! Returns sum of number of fixed and estimated parameters.
00788     int NumAllParameters() const
00789     { 
00790       return numParameters+2;
00791     }
00792 
00793     /*!
00794       \brief
00795       Returns true if vector param contains valid item parameters.
00796       
00797       \section function_args Function Parameters
00798 
00799       \param[in]  & Address of item parameter vector (not used with this model).
00800      */ 
00801     bool ValidParameters(const RealVector & /* param */) const
00802     { 
00803       return true;
00804     }
00805 
00806     //! Returns name of model.
00807     std::string Name() const
00808     { 
00809       return std::string("1PL");
00810     }
00811 
00812     //! Returns model type from enum defined in etirmtypes.h
00813     IRTModel Model() const
00814     { 
00815       return OnePL;
00816     }
00817 
00818     /*! 
00819       \brief
00820       Assigns all item parameters (a, b, and c), fixed and estimated.
00821       
00822       \section template_args Template Parameters
00823    
00824       \param I  Type of iterator over item parameters. 
00825     
00826       \section function_args Function Parameters
00827    
00828       \param[in]  begin_param Iterator pointing to first item parameter for the item.
00829       \param[in]  end_param Iterator point to one after the last parameter for the item.
00830       \param[out] &estParam Address to vector "all" parameters for this item.
00831      */
00832     template <class I>
00833     void SetAllParameters(I begin_param, I end_param, RealVector &estParam)
00834     {
00835 
00836       if ((end_param - begin_param) != 3 || estParam.size() != 1)
00837       throw InvalidArgument("Wrong number of parameters", "ICCLogistic<1>::SetAllParameters");
00838 
00839       if (begin_param[2] < 0.0 || begin_param[2]> 1.0) throw InvalidArgument("Invalid c parameter","ICCLogistic<1>::SetAllParameters");
00840 
00841       fixedA = *begin_param++;
00842       estParam[0] = *begin_param++;
00843       fixedC = *begin_param;
00844     }
00845 
00846   private:
00847 
00848     Real fixedC; //!< fixed c parameter
00849     Real fixedA; //!< fixed a parameter
00850 
00851   };
00852 
00853 }
00854 
00855 #endif // ETIRM_ICCLOGISTIC_H_

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