#include <Item.h>
Public Types | |
typedef L | latentvar_type |
Type of latent variable. | |
typedef RealVector::iterator | param_iterator |
Iterator over parameters. | |
typedef PriorVector::iterator | prior_iterator |
Iterator over priors. | |
typedef RealVector | param_vector |
Parameter vector. | |
typedef PriorVector | prior_vector |
Vector of parameter priors. | |
Public Member Functions | |
Item (int nparam, int index, int nRespCat) | |
Item class constructor. | |
virtual | ~Item () |
Item class destructor. | |
RealVector | GetParameters () const |
Returns vector of estimated parameters for item. | |
virtual RealVector | GetAllParameters () const |
Returns all item parameters, including estimated and fixed parameters. | |
void | SetParameters (const RealVector ¶m) |
Assigns values of parameter estimates from vector. | |
template<class I> | |
void | SetParameters (I begin, I end) |
Assigns values of parameter estimates from iterator range. | |
virtual void | SetAllParameters (const RealVector &allParam) |
Sets all item parameters, including estimated and fixed parameters. | |
template<class I> | |
void | SetAllParameters (I begin, I end) |
Version of SetAllParameters that uses an iterator range to define the sequence of all parameters. | |
PriorVector::iterator | PriorsIterator () |
Returns iterator pointing to the first prior element of the first item parameter. | |
RealVector::iterator | ParametersIterator () |
Returns iterator to the estimate of the first parameter. | |
void | SetPriors (PriorVector &priors) |
Assigns prior distributions of item parameters. | |
PriorVector | GetPriors () |
Returns vector (mPriors) of parameter priors. | |
void | DeletePriors () |
Releases memory for all priors in mPriors. | |
virtual int | NonZeroPriors (RealVector &p) const |
Ensures that all priors have non-zero, positive densities. | |
int | NumParameters () const |
Returns the number of parameters of the item. | |
int | NumRespCat () const |
Returns the number of valid response categories for item. | |
bool | ValidResponse (Response r) const |
Returns true if response "r" is a valid response for this item, otherwise return false. | |
bool | CheckResponse (Response r) const |
Returns true if "r" is a valid response or is the constant indicating no response to the item. | |
virtual int | ScaleParameters (Real slope, Real intercept, bool ignorePriors=false)=0 |
Transforms item parameters to new latent variable scale. | |
virtual Real | ICRF (Response r, const RealVector ¶meters, const L &theta) const =0 |
Item category response function giving the probability of response r for the item parameters "parameters" and the latent variable "theta". | |
template<class I> | |
void | ICRFAll (const RealVector ¶meters, const L &theta, I iprob) const |
Computes the probabilities of all possible responses to the item for the latent variable "theta" and the item parameters "parameters". | |
Real | ProbResp (Response r, const L &theta) const |
Returns probability of response r for parameter estimates in "mParameterEstimates" and the latent variable "theta". | |
template<class I> | |
void | ProbRespAll (const L &theta, I iprob) const |
Computes the probabilities of all possible responses to the item for the the latent variable "theta". | |
virtual Real | NormalizingConstant () const |
Returns the normalizing constant used for some IRT models, such as D for the 3PL model. | |
int | ResponseIndex (const Response r) const |
Returns index associated with response, where ResponseIndex(firstResponse) == 0, ResponseIndex(firstResponse+1) == 1, ..., ResponseIndex(firstResponse+NumRespCat()-1) == NumRespCat()-1. | |
Response | IndexResponse (const int index) const |
Returns response in response category "index". | |
int | Index () const |
Returns zero-offset index of item (first item has index 0). | |
virtual std::string | ModelName () const =0 |
Returns string containing name of model used for item. | |
virtual IRTModel | Model () const =0 |
Returns type of model used for item. | |
virtual void | SetFirstResponse (Response r) |
Assigns response associated with first response category. | |
Response | FirstResponse () const |
Returns the response corresponding to first response category. | |
Response | LastResponse () const |
Returns the response corresponding to last response category. | |
virtual Response | CorrectResponse () |
Returns response that is considered correct for dichotomous items. | |
Static Public Member Functions | |
static Response | NotPresentedResponse () |
Returns the response which indicates an item was not presented, or that the examinee did not respond to the item. | |
static bool | IsNoResponse (Response r) |
Returns true if "r" is equal to the constant that represents no response to the item. | |
static Response | DefaultFirstResponse () |
Returns the response associated with the first response category if SetDefaultFirstResponse is not called. | |
static void | SetNotPresentedResponse (Response r) |
Assigns response indicating item was not presented. | |
static void | SetDefaultFirstResponse (Response r) |
Assigns response used for initial value of mFirstResponse in constructor. | |
Protected Attributes | |
int | mIndex |
A zero-based index of the item in the vector of responses to all items. | |
int | mNumParameters |
Number of item parameters. | |
int | mNRespCat |
Number of response categories. | |
RealVector | mParameterEstimates |
Vector of estimated item parameters. | |
PriorVector | mPriors |
Vector of prior distributions for item parameters. | |
Response | mFirstResponse |
Response associated with first response category. | |
Static Protected Attributes | |
static Response | notPresentedResponse |
Response indicating an item was not presented or the examinee did not respond to the item. | |
static Response | defaultFirstResponse |
Default value used for mFirstResponse if SetFirstResponse not called. |
L | Type of latent variable. |
Definition at line 43 of file Item.h.
typedef L etirm::Item< L >::latentvar_type |
typedef RealVector::iterator etirm::Item< L >::param_iterator |
typedef PriorVector::iterator etirm::Item< L >::prior_iterator |
typedef RealVector etirm::Item< L >::param_vector |
typedef PriorVector etirm::Item< L >::prior_vector |
etirm::Item< L >::Item | ( | int | nparam, | |
int | index, | |||
int | nRespCat | |||
) | [inline] |
Item class constructor.
[in] | nparam | Number of item parameters. |
[in] | index | zero-offset index of item in vector of all item responses. |
[in] | nRespCat | Number of response categories for the item. |
Definition at line 463 of file Item.h.
References etirm::Item< L >::notPresentedResponse, and etirm::Item< L >::ValidResponse().
00463 : 00464 mIndex(index), mNumParameters(nparam), mNRespCat(nRespCat), mParameterEstimates(nparam, 0.0), 00465 mPriors(nparam, (ItemParamPrior *) 0), mFirstResponse(defaultFirstResponse) 00466 { 00467 // Make sure response indicating that item was not taken 00468 // is not a valid response 00469 if (ValidResponse(notPresentedResponse)) 00470 throw RuntimeError("Not presented response is in range of valid responses", 00471 "Item::SetFirstResponse"); 00472 00473 }
etirm::Item< L >::~Item | ( | ) | [inline, virtual] |
RealVector etirm::Item< L >::GetParameters | ( | ) | const [inline] |
Returns vector of estimated parameters for item.
Definition at line 76 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::GetAllParameters().
00077 { 00078 return mParameterEstimates; 00079 }
virtual RealVector etirm::Item< L >::GetAllParameters | ( | ) | const [inline, virtual] |
Returns all item parameters, including estimated and fixed parameters.
For example, for a two-parameter logistic model only the a and b parameters are estimated, but a fixed c parameter could be specified. This function would return a vector containing the a, b, and c parameters, where only a and b would be returned by GetParameters().
Reimplemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.
Definition at line 91 of file Item.h.
Referenced by etirm::item_get_all_params().
00092 { 00093 return GetParameters(); 00094 }
void etirm::Item< L >::SetParameters | ( | const RealVector & | param | ) | [inline] |
Assigns values of parameter estimates from vector.
Definition at line 514 of file Item.h.
References etirm::Item< L >::mParameterEstimates, and etirm::Item< L >::NumParameters().
Referenced by etirm::Item< D::latentvar_type >::SetAllParameters().
00515 { 00516 if (param.size() != NumParameters()) 00517 throw InvalidArgument("Wrong number of parameters", "Item::SetParameters"); 00518 00519 mParameterEstimates = param; 00520 00521 }
void etirm::Item< L >::SetParameters | ( | I | begin, | |
I | end | |||
) | [inline] |
Assigns values of parameter estimates from iterator range.
Definition at line 525 of file Item.h.
References etirm::Item< L >::mParameterEstimates, and etirm::Item< L >::NumParameters().
00526 { 00527 typename std::iterator_traits<I>::difference_type n = end - begin; 00528 if (n != NumParameters()) 00529 throw InvalidArgument("Wrong number of parameters", "Item::SetParameters"); 00530 00531 param_iterator ip = mParameterEstimates.begin(); 00532 while (begin != end) 00533 { 00534 *ip = *begin; 00535 ++begin; 00536 ++ip; 00537 } 00538 00539 }
virtual void etirm::Item< L >::SetAllParameters | ( | const RealVector & | allParam | ) | [inline, virtual] |
Sets all item parameters, including estimated and fixed parameters.
For example, for a two-parameter logistic model only the a and b parameters are estimated, but a fixed c parameter could be specified. This function would set the a and b parameters the same as SetParameters, but would also set the fixed c parameter.
Reimplemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.
Definition at line 110 of file Item.h.
Referenced by etirm::item_set_all_params(), and etirm::Item< D::latentvar_type >::SetAllParameters().
00111 { 00112 SetParameters(allParam); 00113 }
void etirm::Item< L >::SetAllParameters | ( | I | begin, | |
I | end | |||
) | [inline] |
Version of SetAllParameters that uses an iterator range to define the sequence of all parameters.
Definition at line 120 of file Item.h.
00121 { 00122 RealVector allParam(begin, end); 00123 SetAllParameters(allParam); 00124 }
PriorVector::iterator etirm::Item< L >::PriorsIterator | ( | ) | [inline] |
Returns iterator pointing to the first prior element of the first item parameter.
Definition at line 126 of file Item.h.
Referenced by etirm::item_get_prior_param(), etirm::item_get_prior_type(), etirm::item_set_all_params(), etirm::item_set_param(), etirm::item_set_params(), and etirm::item_set_prior().
RealVector::iterator etirm::Item< L >::ParametersIterator | ( | ) | [inline] |
Returns iterator to the estimate of the first parameter.
Definition at line 132 of file Item.h.
Referenced by etirm::item_get_param(), etirm::item_get_params(), etirm::item_set_all_params(), etirm::item_set_param(), and etirm::item_set_params().
void etirm::Item< L >::SetPriors | ( | PriorVector & | priors | ) | [inline] |
Assigns prior distributions of item parameters.
Definition at line 542 of file Item.h.
References etirm::Item< L >::mPriors, and etirm::Item< L >::NumParameters().
00543 { 00544 if ( (int)priors.size() != NumParameters()) // Casting first argument to type "int", ww, 3-1-2008. 00545 throw InvalidArgument("Wrong number of priors", "Item::SetPriors"); 00546 00547 mPriors = priors; 00548 00549 }
PriorVector etirm::Item< L >::GetPriors | ( | ) | [inline] |
void etirm::Item< L >::DeletePriors | ( | ) | [inline] |
Releases memory for all priors in mPriors.
Definition at line 552 of file Item.h.
References etirm::Item< L >::mPriors.
00553 { 00554 00555 int n = mPriors.size(); 00556 PriorVector::iterator i = mPriors.begin(); 00557 00558 while (n--) 00559 { 00560 if (*i != 0) 00561 { 00562 delete *i; 00563 *i = 0; 00564 } 00565 ++i; 00566 } 00567 00568 }
int etirm::Item< L >::NonZeroPriors | ( | RealVector & | param | ) | const [inline, virtual] |
Ensures that all priors have non-zero, positive densities.
If a value of a parameter in param has zero probability in the prior distribution for the parameter then this functions changes the parameter prior to a strictly positive density.
Returns the number of parameters that were changed.
Definition at line 580 of file Item.h.
References etirm::Item< L >::mPriors, and etirm::Item< L >::NumParameters().
00581 { 00582 int n = 0; 00583 00584 // For each parameter assigns new value to parameter if 00585 // prior density of parameter value is zero. 00586 PriorVector::const_iterator iprior = mPriors.begin(); 00587 RealVector::iterator iparam = param.begin(); 00588 for (int i=NumParameters(); i--; ++iprior, ++iparam) 00589 { 00590 if (*iprior) 00591 { 00592 Real newparam = (*iprior)->NearestNonZero(*iparam); 00593 if (newparam != *iparam) 00594 { 00595 ++n; 00596 *iparam = newparam; 00597 } 00598 } 00599 } 00600 00601 return n; 00602 00603 }
int etirm::Item< L >::NumParameters | ( | ) | const [inline] |
Returns the number of parameters of the item.
Definition at line 152 of file Item.h.
Referenced by etirm::CheckItemParam(), etirm::item_get_params(), etirm::item_num_params(), etirm::item_set_all_params(), etirm::item_set_params(), etirm::Item< L >::NonZeroPriors(), etirm::Item< L >::SetParameters(), and etirm::Item< L >::SetPriors().
int etirm::Item< L >::NumRespCat | ( | ) | const [inline] |
Returns the number of valid response categories for item.
Definition at line 158 of file Item.h.
Referenced by etirm::Item< L >::ICRFAll(), etirm::item_num_resp_cat(), and etirm::Item< D::latentvar_type >::LastResponse().
bool etirm::Item< L >::ValidResponse | ( | Response | r | ) | const [inline] |
Returns true if response "r" is a valid response for this item, otherwise return false.
It is assumed that valid item responses are mFirstResponse, mFirstResponse+1, ..., mFirstResponse+NumRespCat()-1. mNotPresentedResponse is not a valid response.
Definition at line 173 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::CheckResponse(), etirm::Item< L >::Item(), and etirm::Item< D::latentvar_type >::SetFirstResponse().
00174 { 00175 return ((r >= mFirstResponse) && (r <= LastResponse())) ? true : false; 00176 }
bool etirm::Item< L >::CheckResponse | ( | Response | r | ) | const [inline] |
Returns true if "r" is a valid response or is the constant indicating no response to the item.
Definition at line 183 of file Item.h.
00184 { 00185 return (ValidResponse(r) || r == notPresentedResponse) ? true : false; 00186 }
virtual int etirm::Item< L >::ScaleParameters | ( | Real | slope, | |
Real | intercept, | |||
bool | ignorePriors = false | |||
) | [pure virtual] |
Transforms item parameters to new latent variable scale.
Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.
Referenced by etirm::item_scale_params().
virtual Real etirm::Item< L >::ICRF | ( | Response | r, | |
const RealVector & | parameters, | |||
const L & | theta | |||
) | const [pure virtual] |
Item category response function giving the probability of response r for the item parameters "parameters" and the latent variable "theta".
Referenced by etirm::Item< L >::ICRFAll(), and etirm::Item< D::latentvar_type >::ProbResp().
void etirm::Item< L >::ICRFAll | ( | const RealVector & | parameters, | |
const L & | theta, | |||
I | iprob | |||
) | const [inline] |
Computes the probabilities of all possible responses to the item for the latent variable "theta" and the item parameters "parameters".
Probabilities are stored using iterator iprob, which points to the location where the probability for the first response category should be stored.
Definition at line 491 of file Item.h.
References etirm::Item< L >::ICRF(), etirm::Item< L >::IndexResponse(), and etirm::Item< L >::NumRespCat().
00493 { 00494 Real sum = 0.0; 00495 int n = NumRespCat()-1; 00496 // Compute probabilities for all but last response category 00497 for (int r = 0; r < n; ++r, ++iprob) 00498 { 00499 *iprob = ICRF(IndexResponse(r), parameters, theta); 00500 sum += *iprob; 00501 } 00502 // Probability for last response category 00503 *iprob = 1.0 - sum; 00504 00505 }
Real etirm::Item< L >::ProbResp | ( | Response | r, | |
const L & | theta | |||
) | const [inline] |
Returns probability of response r for parameter estimates in "mParameterEstimates" and the latent variable "theta".
Definition at line 217 of file Item.h.
Referenced by etirm::item_prob_resp().
00218 { 00219 return ICRF(r, mParameterEstimates, theta); 00220 }
void etirm::Item< L >::ProbRespAll | ( | const L & | theta, | |
I | iprob | |||
) | const [inline] |
Computes the probabilities of all possible responses to the item for the the latent variable "theta".
Probabilities are stored using iterator iprob, which points to the location where the probability for the first response category should be stored.
Definition at line 231 of file Item.h.
00232 { 00233 ICRFAll<I>(mParameterEstimates, theta, iprob); 00234 }
virtual Real etirm::Item< L >::NormalizingConstant | ( | ) | const [inline, virtual] |
Returns the normalizing constant used for some IRT models, such as D for the 3PL model.
Reimplemented in etirm::ItemDichotomous< D, ICC >.
Definition at line 241 of file Item.h.
int etirm::Item< L >::ResponseIndex | ( | const Response | r | ) | const [inline] |
Returns index associated with response, where ResponseIndex(firstResponse) == 0, ResponseIndex(firstResponse+1) == 1, ..., ResponseIndex(firstResponse+NumRespCat()-1) == NumRespCat()-1.
Assumes r is a valid response not equal to notPresentedResponse.
Definition at line 254 of file Item.h.
Referenced by etirm::Resp2Char().
00255 { 00256 return r - mFirstResponse; 00257 }
Response etirm::Item< L >::IndexResponse | ( | const int | index | ) | const [inline] |
Returns response in response category "index".
Note: This is the inverse of the ResponseIndex function. It is assumed that index >= 0.
Definition at line 266 of file Item.h.
Referenced by etirm::Item< L >::ICRFAll(), and etirm::item_prob_resp().
00267 { 00268 return mFirstResponse + index; 00269 }
int etirm::Item< L >::Index | ( | ) | const [inline] |
Returns zero-offset index of item (first item has index 0).
Definition at line 272 of file Item.h.
Referenced by etirm::CheckItemParam().
virtual std::string etirm::Item< L >::ModelName | ( | ) | const [pure virtual] |
Returns string containing name of model used for item.
Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.
Referenced by etirm::item_get_model().
virtual IRTModel etirm::Item< L >::Model | ( | ) | const [pure virtual] |
Returns type of model used for item.
Implemented in etirm::ItemDichotomous< D, ICC >, and etirm::ItemPolytomous< LC, M >.
virtual void etirm::Item< L >::SetFirstResponse | ( | Response | r | ) | [inline, virtual] |
Assigns response associated with first response category.
Responses associated with other response categories are assumed to mFirstResponse+1, mFirstResponse+2, ...
Reimplemented in etirm::ItemDichotomous< D, ICC >.
Definition at line 292 of file Item.h.
00293 { 00294 mFirstResponse = r; 00295 // Make sure response indicating that item was not taken 00296 // is not a valid response 00297 if (ValidResponse(notPresentedResponse)) 00298 throw RuntimeError("Not presented response is in range of valid responses", 00299 "Item::SetFirstResponse"); 00300 }
Response etirm::Item< L >::FirstResponse | ( | ) | const [inline] |
Returns the response corresponding to first response category.
The response corresponding to the i-th response category would be FirstResponse() + (i-1).
Definition at line 309 of file Item.h.
Referenced by etirm::Resp2Char().
00310 { 00311 return mFirstResponse; 00312 }
Response etirm::Item< L >::LastResponse | ( | ) | const [inline] |
Returns the response corresponding to last response category.
Definition at line 314 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::ValidResponse().
virtual Response etirm::Item< L >::CorrectResponse | ( | ) | [inline, virtual] |
Returns response that is considered correct for dichotomous items.
Should be overriden for class representing dichotomous items.
Reimplemented in etirm::ItemDichotomous< D, ICC >.
Definition at line 326 of file Item.h.
00327 { 00328 // By default throw an exception indicating there no response considered correct 00329 throw RuntimeError("No correct response for item", "Item::CorrectResponse()"); 00330 return 0; 00331 }
static Response etirm::Item< L >::NotPresentedResponse | ( | ) | [inline, static] |
Returns the response which indicates an item was not presented, or that the examinee did not respond to the item.
Definition at line 338 of file Item.h.
00339 { 00340 return notPresentedResponse; 00341 }
static bool etirm::Item< L >::IsNoResponse | ( | Response | r | ) | [inline, static] |
Returns true if "r" is equal to the constant that represents no response to the item.
Definition at line 348 of file Item.h.
00349 { 00350 return r == notPresentedResponse; 00351 }
static Response etirm::Item< L >::DefaultFirstResponse | ( | ) | [inline, static] |
Returns the response associated with the first response category if SetDefaultFirstResponse is not called.
Definition at line 358 of file Item.h.
00359 { 00360 return defaultFirstResponse; 00361 }
static void etirm::Item< L >::SetNotPresentedResponse | ( | Response | r | ) | [inline, static] |
Assigns response indicating item was not presented.
This should only be called before any item objects have been created.
Definition at line 370 of file Item.h.
00371 { 00372 notPresentedResponse = r; 00373 }
static void etirm::Item< L >::SetDefaultFirstResponse | ( | Response | r | ) | [inline, static] |
int etirm::Item< L >::mIndex [protected] |
A zero-based index of the item in the vector of responses to all items.
Definition at line 384 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::Index().
int etirm::Item< L >::mNumParameters [protected] |
Number of item parameters.
Definition at line 387 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::NumParameters().
int etirm::Item< L >::mNRespCat [protected] |
Number of response categories.
Definition at line 390 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::NumRespCat().
RealVector etirm::Item< L >::mParameterEstimates [protected] |
Vector of estimated item parameters.
Definition at line 393 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::GetParameters(), etirm::Item< D::latentvar_type >::ParametersIterator(), etirm::Item< D::latentvar_type >::ProbResp(), etirm::Item< D::latentvar_type >::ProbRespAll(), and etirm::Item< L >::SetParameters().
PriorVector etirm::Item< L >::mPriors [protected] |
Vector of prior distributions for item parameters.
Definition at line 396 of file Item.h.
Referenced by etirm::Item< L >::DeletePriors(), etirm::Item< D::latentvar_type >::GetPriors(), etirm::Item< L >::NonZeroPriors(), etirm::Item< D::latentvar_type >::PriorsIterator(), and etirm::Item< L >::SetPriors().
Response etirm::Item< L >::mFirstResponse [protected] |
Response associated with first response category.
It is assumed that valid responses to the item are mFirstResponse, mFirstResponse+1, ..., mFirstResponse+NumRespCat()-1
Definition at line 405 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::FirstResponse(), etirm::Item< D::latentvar_type >::IndexResponse(), etirm::Item< D::latentvar_type >::LastResponse(), etirm::Item< D::latentvar_type >::ResponseIndex(), etirm::Item< D::latentvar_type >::SetFirstResponse(), and etirm::Item< D::latentvar_type >::ValidResponse().
Response etirm::Item< L >::notPresentedResponse [static, protected] |
Response indicating an item was not presented or the examinee did not respond to the item.
Definition at line 415 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::CheckResponse(), etirm::Item< D::latentvar_type >::IsNoResponse(), etirm::Item< L >::Item(), etirm::Item< D::latentvar_type >::NotPresentedResponse(), etirm::Item< D::latentvar_type >::SetFirstResponse(), and etirm::Item< D::latentvar_type >::SetNotPresentedResponse().
Response etirm::Item< L >::defaultFirstResponse [static, protected] |
Default value used for mFirstResponse if SetFirstResponse not called.
Definition at line 419 of file Item.h.
Referenced by etirm::Item< D::latentvar_type >::DefaultFirstResponse(), and etirm::Item< D::latentvar_type >::SetDefaultFirstResponse().