etirm::ItemNR< D > Class Template Reference

Class, derived from Item, to maintain information calculated for an Item object in the E-step so that it can be used in the M-step to estimate item parameters. More...

#include <ItemNR.h>

Inheritance diagram for etirm::ItemNR< D >:

Inheritance graph
[legend]
Collaboration diagram for etirm::ItemNR< D >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef RealMatrix::row_iterator r_iterator
 Type iterator over responses of an item.
typedef RealVector::iterator n_iterator
 Type iterator over number of examinees who responded to an item.
typedef D::point_iterator point_iterator
 Type iterator over quadrature points.

Public Member Functions

 ItemNR (int nparam, int index, int respCat, D *dist=0)
 Constructor.
virtual ~ItemNR ()
 Destructor.
r_iterator RVector (Response resp, int group=1)
 Returns iterator to first element of row of mR corresponding to response "resp" for examinee group "group" (where the first examinee group is group 1).
n_iterator NVector (int group=1)
 Returns iterator to first element of mN for examinee group "group" (where the first examinee group is group 1).
void SetLatentVarPoints (int n, point_iterator points)
 Assigns values associated with discrete latent variable categories.
point_iterator GetLatentVarPoints (int group=1)
 Returns iterator over quadrature points.
int NumLatentVarCat ()
 Returns number of discrete latent variable categories.
void InitializeNR ()
 Initializes elements of mR and mN to zero.
virtual double f_to_minimize (RealVector &p)=0
 Function to maximize in M-step.
virtual void gradient (RealVector &p, RealVector &g)=0
 Computes gradient of function to maximize in M-step.
virtual void hessian (RealVector &x, RealMatrix &h)=0
 Computes hessian of function to maximize in M-step.
virtual int HasAnalyticGradient () const =0
 Function to indicate that the algebraic gradient of the item (ICCDeriv1) is defined.
virtual int HasAnalyticHessian () const =0
 Function to indicate that the algebraic hessian of the item (ICCDeriv2) is defined.
virtual int ValidParameters (const RealVector &p, bool ignorePriors=false) const
 Returns 1 if all parameters have a non-zero prior density, or 0 otherwise.
int dim () const
 Number of item parameters.

Protected Attributes

D * mLatentDist
 Latent variable distribution used to determine discrete categories on the latent variable.
RealMatrixmR
 Expected number of respondents in each latent variable category who took this item and gave the i-th response.
RealVectormN
 Expected number of examinees who took this item in each latent variable category.
int mNumLatentVarCat
 Number of latent variable categories.


Detailed Description

template<class D>
class etirm::ItemNR< D >

Class, derived from Item, to maintain information calculated for an Item object in the E-step so that it can be used in the M-step to estimate item parameters.

Information stored from the E-step includes the expected number of examinees in each category of the discrete latent variable of those that took the item (these usually are denoted by the letter "n"), and for each item response the expected number of examinees in each category of the discrete latent variable who gave that item response of those examinees who took the item (these usually are denoted by the letter "r").

Template Parameters

Parameters:
D Class for discrete latent variable distribution.

Definition at line 57 of file ItemNR.h.


Member Typedef Documentation

template<class D>
typedef RealMatrix::row_iterator etirm::ItemNR< D >::r_iterator

Type iterator over responses of an item.

Definition at line 63 of file ItemNR.h.

template<class D>
typedef RealVector::iterator etirm::ItemNR< D >::n_iterator

Type iterator over number of examinees who responded to an item.

Definition at line 66 of file ItemNR.h.

template<class D>
typedef D::point_iterator etirm::ItemNR< D >::point_iterator

Type iterator over quadrature points.

Definition at line 69 of file ItemNR.h.


Constructor & Destructor Documentation

template<class D>
etirm::ItemNR< D >::ItemNR ( int  nparam,
int  index,
int  respCat,
D *  dist = 0 
) [inline]

Constructor.

Template Parameters

Parameters:
D Class for discrete latent variable distribution.

Function Parameters

Parameters:
[in] nparam Number of item parameters.
[in] index Zero-offset index of item in vector of all item responses.
[in] respCat Number of response categories.
[in] dist Latent variable distribution.

Definition at line 290 of file ItemNR.h.

References etirm::ItemNR< D >::mLatentDist, etirm::ItemNR< D >::mN, etirm::ItemNR< D >::mNumLatentVarCat, and etirm::ItemNR< D >::mR.

00290                                                                :
00291     Item<typename D::latentvar_type>(nparam, index, respCat),
00292 #else
00293         ItemNR<D>::ItemNR(int nparam, int index, int respCat, D *dist) : Item<D::latentvar_type>(nparam, index, respCat),
00294 #endif
00295         mLatentDist(dist), mR(0), mN(0), mNumLatentVarCat(0)
00296   {
00297     if (dist)
00298     {
00299       mNumLatentVarCat = dist->size();
00300       // Compute total number of latent distribution points over all groups for
00301       // which the points are unique
00302       int totpoints = mLatentDist->NumGroupsUnique() * mNumLatentVarCat;
00303 
00304       mR = new RealMatrix(respCat, totpoints);
00305       mN = new RealVector(totpoints);
00306     }
  }

template<class D>
etirm::ItemNR< D >::~ItemNR (  )  [inline, virtual]

Destructor.

Definition at line 312 of file ItemNR.h.

References etirm::ItemNR< D >::mN, and etirm::ItemNR< D >::mR.

00314   {
00315     if (mN)
00316       delete mN;
00317     if (mR)
00318       delete mR;


Member Function Documentation

template<class D>
ItemNR< D >::r_iterator etirm::ItemNR< D >::RVector ( Response  resp,
int  group = 1 
) [inline]

Returns iterator to first element of row of mR corresponding to response "resp" for examinee group "group" (where the first examinee group is group 1).

Function Parameters

Parameters:
[in] resp Response vector.
[in] group Examinee group (default =1).

Definition at line 342 of file ItemNR.h.

References etirm::ItemNR< D >::mLatentDist, etirm::ItemNR< D >::mNumLatentVarCat, and etirm::ItemNR< D >::mR.

00344   {
00345     int ngroups = mLatentDist->NumGroups();
00346     if (group > ngroups || group < 1)
00347       throw InvalidArgument("Invalid group", "ItemNR::RVector");
00348 
00349     r_iterator rvec = mR->begin_row(Item<typename D::latentvar_type>::ResponseIndex(resp)+1); // Added "Item<typename D::latentvar_type>::" to ResponseIndex method call. ww, 1/12/2008
00350 
00351     return (mLatentDist->NumGroupsUnique() == 1) ? rvec : (rvec + (group-1) * mNumLatentVarCat);

template<class D>
ItemNR< D >::n_iterator etirm::ItemNR< D >::NVector ( int  group = 1  )  [inline]

Returns iterator to first element of mN for examinee group "group" (where the first examinee group is group 1).

Function Parameters

Parameters:
[in] group Group index.

Definition at line 362 of file ItemNR.h.

References etirm::ItemNR< D >::mLatentDist, etirm::ItemNR< D >::mN, and etirm::ItemNR< D >::mNumLatentVarCat.

00364   {
00365     int ngroups = mLatentDist->NumGroups();
00366     if (group > ngroups || group < 1)
00367       throw InvalidArgument("Invalid group", "ItemNR::NVector");
00368 
00369     n_iterator nvec = mN->begin();
00370     return (mLatentDist->NumGroupsUnique() == 1) ? nvec : (nvec + (group-1) * mNumLatentVarCat);

template<class D>
void etirm::ItemNR< D >::SetLatentVarPoints ( int  n,
point_iterator  points 
)

Assigns values associated with discrete latent variable categories.

Note: I was not able to locate any SetLatentVarPoints function in the code base. It is questionable whether this function is operative at all (ww, 2-28-2008).

Function Parameters

Parameters:
[in] n Number of discrete categories of the latent ability distribution.
[in] points Iterator over quadrature points.

template<class D>
point_iterator etirm::ItemNR< D >::GetLatentVarPoints ( int  group = 1  )  [inline]

Returns iterator over quadrature points.

Function Parameters

Parameters:
[in] group \ Examinee group (1, 2, ..., "number of groups").

Definition at line 137 of file ItemNR.h.

00138     {
00139       return mLatentDist->begin_points(group);
00140     }

template<class D>
int etirm::ItemNR< D >::NumLatentVarCat (  )  [inline]

Returns number of discrete latent variable categories.

Definition at line 143 of file ItemNR.h.

00144     {
00145       return mNumLatentVarCat;
00146     }

template<class D>
void etirm::ItemNR< D >::InitializeNR (  )  [inline]

Initializes elements of mR and mN to zero.

Definition at line 324 of file ItemNR.h.

References etirm::ItemNR< D >::mN, and etirm::ItemNR< D >::mR.

00326   {
00327     if (mN)
00328       *mN = 0.0;
00329     if (mR)
00330       *mR = 0.0;

template<class D>
virtual double etirm::ItemNR< D >::f_to_minimize ( RealVector p  )  [pure virtual]

Function to maximize in M-step.

Function Parameters

Parameters:
[in] &p Address of item parameter vector.
Note: Technically, negative value of function is being minimized, so the negative function value is being returned.

Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.

template<class D>
virtual void etirm::ItemNR< D >::gradient ( RealVector p,
RealVector g 
) [pure virtual]

Computes gradient of function to maximize in M-step.

Function Parameters

Parameters:
[in] &p Address of item parameter vector.
[out] &g Address of gradient vector. Gradient values are returned in the vector elements.
Note: Technically, negative value of function is being minimized, so the negative gradient is being returned.

Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.

template<class D>
virtual void etirm::ItemNR< D >::hessian ( RealVector x,
RealMatrix h 
) [pure virtual]

Computes hessian of function to maximize in M-step.

Note: Technically, the negative value of the function is to be minimized by UNCMIN++, see inline comments in function code.

Note: The hessian is stored in the lower trangle of h.

Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.

template<class D>
virtual int etirm::ItemNR< D >::HasAnalyticGradient (  )  const [pure virtual]

Function to indicate that the algebraic gradient of the item (ICCDeriv1) is defined.

This function can be used by UNCMIN++.

Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.

template<class D>
virtual int etirm::ItemNR< D >::HasAnalyticHessian (  )  const [pure virtual]

Function to indicate that the algebraic hessian of the item (ICCDeriv2) is defined.

This function can be used by UNCMIN++.

Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.

template<class D>
int etirm::ItemNR< D >::ValidParameters ( const RealVector p,
bool  ignorePriors = false 
) const [inline, virtual]

Returns 1 if all parameters have a non-zero prior density, or 0 otherwise.

Function Parameters

Parameters:
[in] &p Address of parameter vector for this item.
[in] ignorePriors Boolan flag to bypass the test of prior densities.

Reimplemented in etirm::ItemDichotomous< D, ICC >.

Definition at line 381 of file ItemNR.h.

00383   {
00384     // For each parameter check that prior density at the value of the
00385     // parameter is not zero
00386     if (!ignorePriors)
00387     {
00388       PriorVector::const_iterator iprior = Item<typename D::latentvar_type>::mPriors.begin();
00389       RealVector::const_iterator iparam = param.begin();
00390       for (int i=Item<typename D::latentvar_type>::NumParameters(); i--; ++iprior, ++iparam) // Added "Item<typename D::latentvar_type>::" to NumParameters method call. ww, 1/12/2008
00391       {
00392         if (*iprior)
00393         {
00394           if ((*iprior)->ZeroDensity(*iparam))
00395           {
00396             return 0;
00397           }
00398         }
00399       }
00400     }
00401     return 1;

template<class D>
int etirm::ItemNR< D >::dim (  )  const [inline]

Number of item parameters.

Definition at line 226 of file ItemNR.h.

00227     {
00228       return Item<typename D::latentvar_type>::NumParameters();
00229     } // Added "Item<typename D::latentvar_type>::" to NumParameters method call. ww, 1/12/2008


Member Data Documentation

template<class D>
D* etirm::ItemNR< D >::mLatentDist [protected]

Latent variable distribution used to determine discrete categories on the latent variable.

Definition at line 234 of file ItemNR.h.

Referenced by etirm::ItemNR< LC >::GetLatentVarPoints(), etirm::ItemNR< D >::ItemNR(), etirm::ItemNR< D >::NVector(), and etirm::ItemNR< D >::RVector().

template<class D>
RealMatrix* etirm::ItemNR< D >::mR [protected]

Expected number of respondents in each latent variable category who took this item and gave the i-th response.

If there are different points for different examinee groups the expected number of examinees will differ for different groups, and will be stacked in each row.

The first mNumLatentVarCat values will be for the first group, the second mNumLatentVarCat values will be for the second group, etc. These expected counts are computed in the E-step.

Definition at line 249 of file ItemNR.h.

Referenced by etirm::ItemNR< D >::InitializeNR(), etirm::ItemNR< D >::ItemNR(), etirm::ItemNR< D >::RVector(), and etirm::ItemNR< D >::~ItemNR().

template<class D>
RealVector* etirm::ItemNR< D >::mN [protected]

Expected number of examinees who took this item in each latent variable category.

If there are different points for different examinee groups the expected number of examinees will differ for different groups, and will be stacked.

The first mNumLatentVarCat values will be for the first group, the second mNumLatentVarCat values will be for the second group, etc. These expected counts are computed in the E-step.

Definition at line 264 of file ItemNR.h.

Referenced by etirm::ItemNR< D >::InitializeNR(), etirm::ItemNR< D >::ItemNR(), etirm::ItemNR< D >::NVector(), and etirm::ItemNR< D >::~ItemNR().

template<class D>
int etirm::ItemNR< D >::mNumLatentVarCat [protected]

Number of latent variable categories.

Definition at line 268 of file ItemNR.h.

Referenced by etirm::ItemNR< D >::ItemNR(), etirm::ItemNR< LC >::NumLatentVarCat(), etirm::ItemNR< D >::NVector(), and etirm::ItemNR< D >::RVector().


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