etirm::ICRF_PCM Class Reference

Class for Masters' PCM item response function. More...

#include <ICRF_PCM.h>

List of all members.

Public Member Functions

 ICRF_PCM (int ncat, Response firstResp, Real a=1.0)
Real ICRF (Response r, const RealVector &param, Real theta) const
 Computes probability of a response in response category 'r' for latent variable value theta.
Real OpenICRF (Response r, const RealVector &param, Real theta) const
 Returns value of ICRF in open interval (0,1).
void ICRFDeriv1 (Response r, const RealVector &param, Real theta, RealVector &deriv)
 Computes value of first derivative of ICRF (gradient).
bool GradientDefined () const
 Function indicating that gradient (ICCDeriv1) is defined.
bool HessianDefined () const
 Function indicating that Hessian is not defined.
void Scale (Real slope, Real intercept, RealVector &param)
 Compute linear transformation of item parameters onto a new IRT scale.
int NumParameters () const
 Returns number of estimated parameters.
int NumAllParameters () const
 Returns number of fixed (a) and estimated (b1, b2, ...) parameters.
int NumRespCat () const
 Returns number of response categories.
std::string Name () const
 Return name of model.
IRTModel Model () const
 Return model type from enum defined in etirmtypes.h.
void GetAllParameters (const RealVector &estParam, RealVector &allParam) const
 Takes estimate parameters (b1, b2, ...) as input, outputs allParam, the vector made up of fixed parameter a, and the estimated parameters b1, b2, ...
template<class I>
void SetAllParameters (I begin_param, I end_param, RealVector &estParam)
 Set a, b1, b2, ... parameters.

Private Member Functions

void ExpZ (const RealVector &param, Real theta)
 Computes mDenom, mDenom2, and elements of mExpz.

Private Attributes

int mNumCat
 number of response categories
int mNumParameters
 number of estimated parameters in model
Real mA
 slope parameter
Response mFirstResponse
 Response associated with first response category.
RealVector mExpz
Real mDenom
 denominator of ICRF
Real mDenom2
 Square of mDenom.


Detailed Description

Class for Masters' PCM item response function.

Definition at line 34 of file ICRF_PCM.h.


Constructor & Destructor Documentation

etirm::ICRF_PCM::ICRF_PCM ( int  ncat,
Response  firstResp,
Real  a = 1.0 
) [inline]

Class Constructor

Definition at line 40 of file ICRF_PCM.h.

00040                                                          :
00041       mNumCat(ncat), mNumParameters(ncat-1), mFirstResponse(firstResp), mExpz(ncat), mA(a)
00042     {
00043     }


Member Function Documentation

Real etirm::ICRF_PCM::ICRF ( Response  r,
const RealVector param,
Real  theta 
) const

Computes probability of a response in response category 'r' for latent variable value theta.

Returns value of item characteristic response function (ICRF) for response r, parameters in vector param (b1, b2, ...), and theta value.

ICRF_PCM::ICRF

Parameters:
[in] r Response category, where a response in the first response category is mFirstResponse, the response in the second response category is mFirstResponse+1, etc.
[in] param Vector containing item parameters.
[in] theta Latent variable value for which probability is calculated.

Definition at line 58 of file ICRF_PCM.cpp.

References mA, mFirstResponse, and mNumCat.

Referenced by OpenICRF().

00059 {
00060   
00061   Real z = 0.0;
00062   Real num = (r == mFirstResponse) ? 1.0 : -1.0;
00063   Real sum = 1.0;
00064   Real a = mA;
00065   Response ir = mFirstResponse+1;
00066   RealVector::const_iterator ip = param.begin();
00067   for (int i = mNumCat-1; i--; ++ir, ++ip)
00068   {
00069     z += a * (theta - *ip);
00070     Real ez = std::exp(z);
00071     if (ir == r) num = ez;
00072     
00073     sum += ez;
00074   }
00075   
00076   return num/sum;
00077 
00078 }

Here is the caller graph for this function:

Real etirm::ICRF_PCM::OpenICRF ( Response  r,
const RealVector param,
Real  theta 
) const

Returns value of ICRF in open interval (0,1).

Computes probability of a correct response for latent variable value theta, where probability must be in the open interval (0, 1). This function can be used when the logarithm of the probability or logit of the probability needs to be taken.

OpenICRF

Definition at line 90 of file ICRF_PCM.cpp.

References ICRF().

00091 {
00092   
00093   double prob = ICRF(r, param, theta);
00094   
00095   /* Make sure probability is between 0 and 1 */
00096   if (prob <= 0.0)
00097   {
00098     prob = std::numeric_limits<Real>::min();
00099   }
00100   else if (prob >= 1.0)
00101   {
00102     prob = 1.0 - std::numeric_limits<Real>::epsilon();
00103   }
00104 
00105   return prob;
00106 }

Here is the call graph for this function:

void etirm::ICRF_PCM::ICRFDeriv1 ( Response  r,
const RealVector param,
Real  theta,
RealVector deriv 
)

Computes value of first derivative of ICRF (gradient).

Computes first derivatives of ICRF with respect to all parameters.

ICRFDeriv1

Returns derivative with respect to item parameters in vector deriv.

The derivative is obtained by computing the derivative of the numerator and denominator of the ICRF probability separately, and using the formula for the derivative of a quotient of functions.

Definition at line 149 of file ICRF_PCM.cpp.

References ExpZ(), mA, mDenom, mDenom2, mExpz, mFirstResponse, and mNumCat.

00150 {
00151   ExpZ(param, theta);
00152   
00153   Real probnum = mExpz[r - mFirstResponse]; // numerator of ICRF for this response
00154   Real a = mA;
00155   
00156   
00157   /* Derivatives with respect to b's. Compute derivative of parameter associated with
00158      the last response category first and work backward. */
00159   RealVector::const_iterator ie = mExpz.begin()+mNumCat-1;
00160   RealVector::iterator id = deriv.begin() + mNumCat-2;
00161   Real dderiv = 0.0;
00162   Real nderiv = -a * probnum;
00163   Response ir = mFirstResponse + mNumCat - 1;
00164   for (int i = mNumCat-1; i--; --ir, --ie, --id)
00165   {
00166     dderiv += -a * *ie;
00167     
00168     if (ir <= r) *id = nderiv * mDenom;
00169     else *id = 0.0;
00170     *id -= probnum * dderiv;
00171     *id /= mDenom2;
00172   }
00173   
00174 }

Here is the call graph for this function:

bool etirm::ICRF_PCM::GradientDefined (  )  const [inline]

Function indicating that gradient (ICCDeriv1) is defined.

Definition at line 57 of file ICRF_PCM.h.

bool etirm::ICRF_PCM::HessianDefined (  )  const [inline]

Function indicating that Hessian is not defined.

Definition at line 63 of file ICRF_PCM.h.

void etirm::ICRF_PCM::Scale ( Real  slope,
Real  intercept,
RealVector param 
)

Compute linear transformation of item parameters onto a new IRT scale.

Transforms item parameters to new IRT scale.

Definition at line 180 of file ICRF_PCM.cpp.

References mNumParameters.

00181 {
00182 
00183   /* Transform intercept parameters */
00184   RealVector::iterator ip = param.begin();
00185   for (int i = mNumParameters-1; i--; ++ip)
00186   {
00187     *ip *= slope;
00188     *ip += intercept;
00189   }
00190 }

int etirm::ICRF_PCM::NumParameters (  )  const [inline]

Returns number of estimated parameters.

Definition at line 72 of file ICRF_PCM.h.

References mNumParameters.

int etirm::ICRF_PCM::NumAllParameters (  )  const [inline]

Returns number of fixed (a) and estimated (b1, b2, ...) parameters.

Definition at line 78 of file ICRF_PCM.h.

References mNumParameters.

int etirm::ICRF_PCM::NumRespCat (  )  const [inline]

Returns number of response categories.

Definition at line 84 of file ICRF_PCM.h.

References mNumCat.

std::string etirm::ICRF_PCM::Name (  )  const [inline]

Return name of model.

Definition at line 90 of file ICRF_PCM.h.

IRTModel etirm::ICRF_PCM::Model (  )  const [inline]

Return model type from enum defined in etirmtypes.h.

Definition at line 96 of file ICRF_PCM.h.

References etirm::PCM.

void etirm::ICRF_PCM::GetAllParameters ( const RealVector estParam,
RealVector allParam 
) const

Takes estimate parameters (b1, b2, ...) as input, outputs allParam, the vector made up of fixed parameter a, and the estimated parameters b1, b2, ...

Copy fixed a parameter and estimated b parameters from estParam into allParam. Set a, b1, b2, ... parameters, where a is fixed, and b1, b2, ... are estimated.

GetAllParameters

Definition at line 198 of file ICRF_PCM.cpp.

References mA, and mNumParameters.

00199 {
00200   if (estParam.size() != mNumParameters || allParam.size() != mNumParameters+1)
00201   {
00202     throw InvalidArgument("Invalid number of parameters", "ICRF_PCM::GetAllParameters");
00203   }
00204   
00205   allParam[0] = mA;
00206   RealVector::iterator ia = allParam.begin() + 1;
00207   RealVector::const_iterator ie = estParam.begin();
00208   for (int i = mNumParameters; i--; ++ia, ++ie)
00209   {
00210     *ia = *ie;
00211   }
00212 }

template<class I>
void etirm::ICRF_PCM::SetAllParameters ( begin_param,
end_param,
RealVector estParam 
) [inline]

Set a, b1, b2, ... parameters.

Definition at line 109 of file ICRF_PCM.h.

References mA, and mNumParameters.

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     }

void etirm::ICRF_PCM::ExpZ ( const RealVector param,
Real  theta 
) [private]

Computes mDenom, mDenom2, and elements of mExpz.

Computes the terms exp(sum_{k=1}^i z_k), i = 1, mNumCat-1, where z_k = a * (theta - b_k), a = mA, b_k = param[k-1]. These terms are stored in the data member mExpz. Also store values in data members mDenom and mDenom2.

ExpZ

Definition at line 115 of file ICRF_PCM.cpp.

References mA, mDenom, mDenom2, mExpz, and mNumCat.

Referenced by ICRFDeriv1().

00116 {
00117   Real a = mA;
00118   
00119   
00120   mExpz[0] = 1.0;
00121   mDenom = 1.0;
00122   RealVector::iterator ie = mExpz.begin()+1;
00123   RealVector::const_iterator ip = param.begin();
00124   Real num = 0.0;
00125   for (int i = mNumCat-1; i--; ++ip, ++ie)
00126   {
00127     num += a * (theta - *ip);
00128     *ie = std::exp(num);
00129     mDenom += *ie;
00130   }
00131   
00132   mDenom2 = mDenom * mDenom;
00133 }

Here is the caller graph for this function:


Member Data Documentation

int etirm::ICRF_PCM::mNumCat [private]

number of response categories

Definition at line 127 of file ICRF_PCM.h.

Referenced by ExpZ(), ICRF(), ICRFDeriv1(), and NumRespCat().

int etirm::ICRF_PCM::mNumParameters [private]

number of estimated parameters in model

Definition at line 129 of file ICRF_PCM.h.

Referenced by GetAllParameters(), NumAllParameters(), NumParameters(), Scale(), and SetAllParameters().

Real etirm::ICRF_PCM::mA [private]

slope parameter

Definition at line 132 of file ICRF_PCM.h.

Referenced by ExpZ(), GetAllParameters(), ICRF(), ICRFDeriv1(), and SetAllParameters().

Response etirm::ICRF_PCM::mFirstResponse [private]

Response associated with first response category.

Definition at line 135 of file ICRF_PCM.h.

Referenced by ICRF(), and ICRFDeriv1().

RealVector etirm::ICRF_PCM::mExpz [private]

Holds the terms exp(sum_{k=1}^i z_k), i = 1, mNumCat-1, where z_k = a * (theta - b_k), a = param[0], b_k = param[k]. Used in computing the derivative of the ICRF.

Definition at line 138 of file ICRF_PCM.h.

Referenced by ExpZ(), and ICRFDeriv1().

Real etirm::ICRF_PCM::mDenom [private]

denominator of ICRF

Definition at line 143 of file ICRF_PCM.h.

Referenced by ExpZ(), and ICRFDeriv1().

Real etirm::ICRF_PCM::mDenom2 [private]

Square of mDenom.

Definition at line 145 of file ICRF_PCM.h.

Referenced by ExpZ(), and ICRFDeriv1().


The documentation for this class was generated from the following files:
Generated on Sat Mar 1 21:41:32 2008 for ETIRM by  doxygen 1.5.4