etirm::ICRF_GPCM Class Reference

Class for the GPCM item response function. More...

#include <ICRF_GPCM.h>

List of all members.

Public Member Functions

 ICRF_GPCM (int ncat, Response firstResp)
Real ICRF (Response r, const RealVector &param, Real theta) const
Real OpenICRF (Response r, const RealVector &param, Real theta) const
 Return value of ICRF in open interval (0,1).
void ICRFDeriv1 (Response r, const RealVector &param, Real theta, RealVector &deriv)
 Compute value of first derivative of ICRF (gradient).
bool GradientDefined () const
 Function that computes gradient (ICCDeriv1) is defined.
bool HessianDefined () const
 Function that computes hessian is not defined.
void Scale (Real slope, Real intercept, RealVector &param)
 Linearly transform item parameters to new IRT scale.
int NumParameters () const
 Return number of estimated parameters.
int NumAllParameters () const
int NumRespCat () const
 Return 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
 Copy a, b1, b2, ... parameters from estParam into allParam.
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 parameters in model
Response mFirstResponse
 response corresponding to the first response category
RealVector mExpz
Real mDenom
 denominator of ICRF
Real mDenom2
 Square of mDenom.


Detailed Description

Class for the GPCM item response function.

Definition at line 35 of file ICRF_GPCM.h.


Constructor & Destructor Documentation

etirm::ICRF_GPCM::ICRF_GPCM ( int  ncat,
Response  firstResp 
) [inline]

Class Constructor

Definition at line 41 of file ICRF_GPCM.h.

00041                                             :
00042       mNumCat(ncat), mNumParameters(ncat), mFirstResponse(firstResp), mExpz(ncat)
00043     {
00044     }


Member Function Documentation

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

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

Definition at line 55 of file ICRF_GPCM.cpp.

References mFirstResponse, and mNumCat.

Referenced by OpenICRF().

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

Here is the caller graph for this function:

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

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

OpenICC, compute 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.

Definition at line 86 of file ICRF_GPCM.cpp.

References ICRF().

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

Here is the call graph for this function:

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

Compute value of first derivative of ICRF (gradient).

ICRFDeriv1, compute first derivatives of ICRF with respect to all parameters.

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 141 of file ICRF_GPCM.cpp.

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

00142   {
00143     ExpZ(param, theta);
00144 
00145     Real probnum = mExpz[r - mFirstResponse]; // numerator of ICRF for this response
00146     Real a = param[0];
00147 
00148     /* Derivative with respect to a */
00149     Real du = 0.0;
00150     Real nderiv = 0.0; // derivative of numerator of ICRF
00151     Real dderiv = 0.0; // derivative of denominator of ICRF
00152     RealVector::const_iterator ip = param.begin()+1;
00153     RealVector::const_iterator ie = mExpz.begin()+1;
00154     Response ir = mFirstResponse + 1;
00155     int i;
00156     for (i = mNumCat-1; i--; ++ip, ++ie, ++ir)
00157     {
00158       du += theta - *ip;
00159       dderiv += du * *ie;
00160       if (ir == r)
00161         nderiv = du * *ie;
00162     }
00163     deriv[0] = nderiv * mDenom;
00164     deriv[0] -= probnum * dderiv;
00165     deriv[0] /= mDenom2;
00166 
00167     /* Derivatives with respect to b's. Compute derivative of parameter associated with
00168      the last response category first and work backward. */
00169     ie = mExpz.begin()+mNumCat-1;
00170     RealVector::iterator id = deriv.begin() + mNumCat-1;
00171     dderiv = 0.0;
00172     nderiv = -a * probnum;
00173     ir = mFirstResponse + mNumCat - 1;
00174     for (i = mNumCat-1; i--; --ir, --ie, --id)
00175     {
00176       dderiv += -a * *ie;
00177 
00178       if (ir <= r)
00179         *id = nderiv * mDenom;
00180       else
00181         *id = 0.0;
00182       *id -= probnum * dderiv;
00183       *id /= mDenom2;
00184     }
00185 
00186   }

Here is the call graph for this function:

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

Function that computes gradient (ICCDeriv1) is defined.

Definition at line 58 of file ICRF_GPCM.h.

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

Function that computes hessian is not defined.

Definition at line 64 of file ICRF_GPCM.h.

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

Linearly transform item parameters to new IRT scale.

Scale, transform item parameters to new IRT scale.

Definition at line 191 of file ICRF_GPCM.cpp.

References mNumParameters.

00192   {
00193 
00194     /* Transform the slope parameter */
00195     param[0] /= slope;
00196 
00197     /* Transform intercept parameters */
00198     RealVector::iterator ip = param.begin() + 1;
00199     for (int i = mNumParameters-1; i--; ++ip)
00200     {
00201       *ip *= slope;
00202       *ip += intercept;
00203     }
00204   }

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

Return number of estimated parameters.

Definition at line 73 of file ICRF_GPCM.h.

References mNumParameters.

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

Return number of fixed and estimated parameters. In this case there are no fixed parameters.

Definition at line 79 of file ICRF_GPCM.h.

References mNumParameters.

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

Return number of response categories.

Definition at line 87 of file ICRF_GPCM.h.

References mNumCat.

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

Return name of model.

Definition at line 93 of file ICRF_GPCM.h.

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

Return model type from enum defined in etirmtypes.h.

Definition at line 99 of file ICRF_GPCM.h.

References etirm::GPCM.

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

Copy a, b1, b2, ... parameters from estParam into allParam.

GetAllParameters, copy parameters from estParam to allParam.

Definition at line 207 of file ICRF_GPCM.cpp.

References mNumParameters.

00208   {
00209     if (estParam.size() != mNumParameters || allParam.size() != mNumParameters)
00210     {
00211       throw InvalidArgument("Invalid number of parameters", "ICRF_GPCM::GetAllParameters");
00212     }
00213 
00214     RealVector::iterator ia = allParam.begin();
00215     RealVector::const_iterator ie = estParam.begin();
00216     for (int i = mNumParameters; i--; ++ia, ++ie)
00217     {
00218       *ia = *ie;
00219     }
00220   }

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

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

Definition at line 109 of file ICRF_GPCM.h.

References mNumParameters.

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     }

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

Computes mDenom, mDenom2, and elements of mExpz.

ExpZ, compute 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]. These terms are stored in the data member mExpz. Also store values in data members mDenom and mDenom2.

Definition at line 110 of file ICRF_GPCM.cpp.

References mDenom, mDenom2, mExpz, and mNumCat.

Referenced by ICRFDeriv1().

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

Here is the caller graph for this function:


Member Data Documentation

int etirm::ICRF_GPCM::mNumCat [private]

number of response categories

Definition at line 126 of file ICRF_GPCM.h.

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

int etirm::ICRF_GPCM::mNumParameters [private]

number of parameters in model

Definition at line 128 of file ICRF_GPCM.h.

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

Response etirm::ICRF_GPCM::mFirstResponse [private]

response corresponding to the first response category

Definition at line 130 of file ICRF_GPCM.h.

Referenced by ICRF(), and ICRFDeriv1().

RealVector etirm::ICRF_GPCM::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 133 of file ICRF_GPCM.h.

Referenced by ExpZ(), and ICRFDeriv1().

Real etirm::ICRF_GPCM::mDenom [private]

denominator of ICRF

Definition at line 138 of file ICRF_GPCM.h.

Referenced by ExpZ(), and ICRFDeriv1().

Real etirm::ICRF_GPCM::mDenom2 [private]

Square of mDenom.

Definition at line 140 of file ICRF_GPCM.h.

Referenced by ExpZ(), and ICRFDeriv1().


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