etirm Namespace Reference


Classes

class  DiscreteLatentDist
 Class approximating the latent ability distribution by numeric quadrature. More...
class  NMatrixVec
 Helper class template used by EStepDiscrete for managing a vector containing pointers to RealMatrix objects. More...
class  EStepDiscrete
 Class template to perform E-step calculation and store results for IRT model with a discrete latent variable distribution. More...
class  Examinee
 Class to store a response pattern, its frequency, the posterior distribution of the ability parameter and the marginal likelihood of the pattern. More...
class  ExamineeGrpCov
 This class is a descendant of Examinee which also contains information about the group the examinee belongs to (a group covariate). More...
class  ICC3PLFunc
 Common functions and data members used for specializations of ICCLogistic. More...
class  ICCLogistic
 Class declaration of logistic item response model; specializations supplied for NPAR = 1, 2, 3. More...
class  ICCLogistic< 3 >
 Three-parameter logistic item response model. More...
class  ICCLogistic< 2 >
 Two-parameter logistic item response model. More...
class  ICCLogistic< 1 >
 One-parameter logistic item response model. More...
class  ICRF_GPCM
 Class for the GPCM item response function. More...
class  ICRF_PCM
 Class for Masters' PCM item response function. More...
class  Item
 Class (template) containing information about an item. More...
class  ItemDichotomous
 Class representing a dichotomously scored item derived from ItemNR. More...
class  ItemNR
 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...
class  ItemParamPrior
 Class representing a prior distribution used for item parameters in Bayes modal estimation. More...
class  ItemParamPriorBeta4
 Class representing a four-parameter beta prior distribution of item parameters in Bayes modal estimation. More...
class  ItemParamPriorLogNormal
 Class derived from ItemParamPrior representing a lognormal prior distribution of item parameters for use in Bayes modal estimation. More...
class  ItemParamPriorNormal
 Class derived from ItemParamPrior representing a normal prior distribution of item parameters for use in Bayes modal estimation. More...
class  ItemPolytomous
 Class representing a polytomously scored item derived from ItemNR class. More...
class  ItemRespCounts
 Class to hold counts of number of examinees who responded in each response category of an item. More...
class  SwigEtirmRun
 Class holding information used for one modeling problem. More...
class  estep
 SWIG wrapper for EStepDiscrete object. More...
class  ThetaLogLikelihood
 Function object for computing loglikelihood for theta parameter of an IRT model. More...

Typedefs

typedef ETIRM_FLOAT_TYPE Real
 Data type for floating point numbers.
typedef ETIRM_RESPONSE_TYPE Response
 Data type to hold an examinee item response.
typedef SCPPNT::Vector< RealRealVector
 Vector type containing floating point numbers. Used in numeric calculations.
typedef SCPPNT::Matrix< RealRealMatrix
 Matrix type containing floating point numbers. Used in numeric calculations.
typedef SCPPNT::LogicError LogicError
 Using SCPPNT exception types for logical errors.
typedef SCPPNT::InvalidArgument InvalidArgument
 Using SCPPNT exception types for invalid arguments.
typedef SCPPNT::RuntimeError RuntimeError
 Using SCPPNT exception types for runtime errors.
typedef SCPPNT::Exception Exception
 Using SCPPNT exception types for exception violations.
typedef std::vector
< ItemParamPrior * > 
PriorVector
 Data type to represent a vector of pointers to prior distributions.
typedef RealVector double_vector
 Vector type for double precision values.
typedef SCPPNT::Vector< int > int_vector
 Vector type for integer values.
typedef std::vector< item_type * > ItemVector
 Vector type for item pointers.
typedef EStepDiscrete
< examinee_type, item_type,
ItemVector::iterator,
lvdist_type
estep_type
 Class used in E-step calculation.
typedef std::vector< Uncmin
< RealVector, RealMatrix,
item_type > * > 
UncminVector
 Container to hold Uncmin optimization objects.
typedef std::vector
< examinee_type * > 
ExamineeVector
 Container holding examinee object pointers.
typedef std::vector
< ItemRespCounts * > 
ItemStatsVector
 Container holding pointers to objects containing item statistics for each item.

Enumerations

enum  IRTModel {
  OnePL, TwoPL, ThreePL, PCM,
  GPCM
}
 Enumeration for type of IRT model. More...

Functions

template<class URNG, class EI>
void BootstrapSample (EI examinees_begin, EI examinees_end, URNG &rand)
 Generate a bootstrap sample for a group of examinees.
template<class PI, class WI>
void DiscreteNormalDist (int nQuad, double minPoint, double maxPoint, PI ipoints, WI iweights, double mean=0.0, double sd=1.0)
 Compute points and weights for a discrete distribution that approximates a normal distribution.
template<class L>
Real ExamineeThetaMLE (Real minTheta, Real maxTheta, Real precision, L &likelihood)
 Compute latent variable estimate for an examinee using maximum likelihood. Returns the latent trait estimate for the examinee.
template<class II, class IR>
Real ExamineeThetaMLE (Real minTheta, Real maxTheta, Real precision, II items_begin, II items_end, IR responses_begin)
 Compute latent variable estimate for an examinee using maximum likelihood, create a ThetaLogLikelihood object from two item iterators and an interator to the examinee responses, and return the latent trait estimate for the examinee.
double MaxRelParamDiff (RealVector &oldParam, RealVector &newParam, Real typicalValue=1.0)
 Returns the maximum relative difference between an old and new set of item parameters.
template<class MI, class II>
int MStepItems (MI min_routines, II item_begin, II item_end, double &maxreldiff, bool ignoreMaxIter=false)
 Executes M-step for each item.
template<class II, class T, class R, class RI>
void SimulateResponses (II item_begin, II item_end, T &theta, R &rand, RI iresp, bool resp_indices=false)
 Simulate responses to a set of items for a specific latent variable value.
template<class RI, class II>
void PersonMoments (RI iresp, II iitem, RealVector &itemdiff, Response notPresentedResponse, Real *mean, Real *variance)
 Compute mean and standard deviation of logit item difficulty over items responded to by an examinee.
template<class IE, class RI>
void ItemMoments (int num_examinees, IE begin_examinee, int item, RealVector &abilities, Response notPresentedResponse, double *mean, double *variance)
 Compute mean and standard deviation of person ability over examinees who reponded to an item.
template<class EI, class RI, class II>
void PROX (int numItems, bool useAll, EI begin_examinee, EI end_examinee, II begin_item, Response notPresentedResponse, RealVector &itemdiff, RealVector &abilities)
 Compute Rasch item difficulties and examinee abilities using the Normal Approximation Estimation Algorithm (PROX).
template<class I>
void AssignItemNR (int n, RealVector::iterator itemTheta, RealVector::iterator nVec, RealVector::iterator rVec, I *item)
 Assigns individual examinee thetas into discrete latent variable categories and updates expected counts n and r for item M-step.
template<class RI, class MI, class EI, class I, class II>
int StartingValues3PL (MI begin_min, EI begin_examinee, EI end_examinee, II begin_item, II end_item, Response notPresentedResponse, bool useAll=false, int baseGroup=1, std::set< I * > *calc_items=0)
 Computes starting values for a sequence of items modeled with the three-parameter logistic model.
void CheckItemParam (item_type *item, int index, const char *funcname)
 Tests whether item parameter index is valid for the item.
ItemParamPriorCreatePrior (const std::string &pstr, const double_vector &priorparam, const char *funcname)
 Create a prior distribution object and return a pointer to it.
char Resp2Char (Response r, const item_type *item)
 Converts a response for an item into a character, where '0' represents the first response, '1' represents the second response, etc.
void set_missing_resp (char nr)
 Assigns missing response code to identify examinees who did not respond to an item.
int num_items ()
 Returns the number of items.
int num_latent_dist_points ()
 Returns number of categories of the discrete theta distribution.
int num_groups ()
 Returns number of examinee groups.
int num_examinees ()
 Returns number of examinees.
const char * item_get_model (int itemno)
 Returns the name of model used for an item.
void item_set_param (int paramno, int itemno, double paramvalue)
 Assigns a value to one item parameter of an item.
void item_set_params (int itemno, double_vector *params)
 Assigns values to all item parameters of an item.
void item_set_all_params (int itemno, double_vector *params)
 Assigns values to all fixed and estimated item parameters of an item.
double item_get_param (int paramno, int itemno)
 Returns value of one item parameter of an item.
double_vectoritem_get_params (int itemno)
 Returns vector of all estimated item parameters values of an item.
double_vectoritem_get_all_params (int itemno)
 Returns vector of all fixed and estimated item parameters values of an item.
int item_num_params (int itemno)
 Returns the number of parameters of an item.
int item_num_resp_cat (int itemno)
 Returns the number of response categories of an item.
void item_set_prior (int paramno, int itemno, char *priortype, double_vector *dlist)
 Assigns prior distribution parameters for one item parameter.
const char * item_get_prior_type (int paramno, int itemno)
 Returns type of prior distribution ("normal", "lognormal", "beta", "none") for one item parameter.
double_vectoritem_get_prior_param (int paramno, int itemno)
 Returns vector of prior distribution parameters for one item parameter.
double_vectoritem_cat_counts (int itemno, int group)
 Returns vector of response counts in each response category of an item.
double item_resp_count (int itemno, int group)
 Returns the number of examinees responding to an item.
int item_scale_params (int itemno, double slope, double intercept, bool ignorePriorError)
 Transforms the parameter estimates of an item to a different latent variable scale.
double item_prob_resp (int itemno, int response, double theta)
 Returns the probability that an examinee with a particular theta value will give a particular response to a particular item.
double_vectortest_characteristic_curve (double_vector *thetas, int_vector *ilist2)
 Returns a vector of values of the test characteristic curve, given a vector of theta values and a selection of items.
void dist_set_points (double_vector *dlist, int group)
 Assigns quadrature point values to each discrete category of the discrete latent variable distribution.
void dist_set_point (int index, double p, int group)
 Assigns a quadrature point value to one discrete category of the discrete latent variable distribution.
double_vectordist_get_points (int group)
 Returns vector of quadrature point values of the discrete latent variable distribution.
double dist_get_point (int index, int group)
 Returns the quadrature point value of one discrete category of the discrete latent variable distribution.
void dist_set_probs (double_vector *dlist, int group)
 Assigns quadrature weights to the quadrature points of the latent variable distribution.
void dist_set_prob (int index, double w, int group)
 Assigns the quadrature weight to one discrete category of the discrete latent variable distribution.
double_vectordist_get_probs (int group)
 Returns vector of quadrature weights of the latent variable distribution for one group of examinees.
double dist_get_prob (int index, int group)
 Returns the quadrature weight of one discrete category of the latent variable distribution for one group of examinees.
void dist_transform (double slope, double intercept)
 Transforms the quadrature points of latent variable distribution to a new scale.
double_vectordist_scale (double mean, double sd, int group)
 Scales to the quadrature points of latent variable distribution to yield a specfic mean and standard deviation in one group.
double_vectordist_mean_sd (int group)
 Returns a vector with the mean and standard deviation of the latent variable distribution for a selected group of examinees.
int dist_unique_points ()
 Returns 1 if unique sets of quadrature points are used for two or more groups of examinees, or returns 0 otherwise.
double_vectornormal_dist_prob (int npoints, double minPoint, double maxPoint, double mean, double sd)
 Returns a vector of probabilities for a discrete distribution to approximate a normal distribution over a set of equally spaced points.
double_vectornormal_dist_points (int npoints, double minPoint, double maxPoint, double mean, double sd)
 Returns a vector of quadrature points for a discrete distribution over a set of equally-spaced points.
int mstep_items (bool ignore_max_iter, int_vector *itemno)
 CalculateS M-step for a set of items.
int mstep_message (int itemno)
 Returns message from M-step minimization for one item.
void mstep_max_iter (int itemno, int maxiter)
 Assigns the maximum number of iterations permitted with optimization procedure in mstep_items for one item.
double mstep_max_diff ()
 Returns the maximum relative difference between parameter estimates in two successive EM iterations, as computed in last call to mstep_items.
double mstep_dist (estep *e, int group)
 Executes M-step for the latent distribution in one group.
int add_examinee (int_vector *responses, int group, double count)
 Add an examinee objec to the end of the examinee vector.
int_vectorexaminee_responses (int examineeno)
 Returns pointer to an integer vector of examinee item responses to all items.
const char * examinee_response_str (int examineeno)
 Returns string containing (character) examinee responses to all items.
int examinee_get_group (int examineeno)
 Return the number of the group the examinee belongs to.
void examinee_set_group (int examineeno, int group)
 Assigns which group the examinee belongs to.
void examinee_set_count (int examineeno, double count)
 Assigns the count (or weight) of the examinee.
double examinee_get_count (int examineeno)
 Returns the count (or weight) of the examinee.
void examinee_set_posterior (int examineeno, double_vector *posterior)
 Assigns posterior distribution of an examinee.
double_vectorexaminee_get_posterior (int examineeno)
 Returns pointer to vector of the posterior distribution of an examinee.
double examinee_posterior_mean (int examineeno)
 Returns means of an examinee's posterior distribution.
double examinee_theta_MLE (int examineeno, double minTheta, double maxTheta, double precision, int_vector *itemno5)
 Returns an examinee's maximum likelihood estimate of theta.
double examinees_count (int group)
 Returns total examinee count in an examinee group (1, 2, ...), or across all groups.
void bootstrap_seed (unsigned long seed)
 Assigns seed of random number generator used for bootstrap samples.
void bootstrap_sample ()
 Generate bootstrap sample of examinees.
void simulate_seed (unsigned long seed)
 Assigns seed of random number generator used for simulating item responses.
int_vectorsimulate_responses (double theta, int_vector *itemno2)
 Simulates item responses (integers) for a specific value of the latent variable.
const char * simulate_response_str (double theta, int_vector *itemno2)
 Simulates item responses (characters) for a specific value of the latent variable.
int_vectorget_responses (char *line, int_vector *offset, int_vector *len)
 Reads item responses from an input record.
int_vectorget_responses_missing (char *line, int_vector *offset, int_vector *len, int_vector *items)
 Read item responses from a string where responses to only some items are present. The responses to the remaining items are assumed to be missing.
void CheckRunInit ()
 Check that new_etirm has been called.
template<class V>
ItemSubset (int_vector *itemnums, V &all, const char *funcname)
 Creates a container holding the elements corresponding to a subset of items.

Variables

const double logZero = -1021.0
 Value used to represent the log of zero probabilities.
const Real invalidLogit = 10000.0
 value to indicate invalid logit (e.g., logit(1))
SwigEtirmRungEtirmRun = 0
 Global variable holding information about a run.


Typedef Documentation

typedef RealVector etirm::double_vector

Vector type for double precision values.

Definition at line 52 of file swig_etirm.h.

typedef EStepDiscrete<examinee_type, item_type, ItemVector::iterator, lvdist_type> etirm::estep_type

Class used in E-step calculation.

Definition at line 61 of file swig_etirm.h.

typedef std::vector<examinee_type *> etirm::ExamineeVector

Container holding examinee object pointers.

Definition at line 67 of file swig_etirm.h.

typedef SCPPNT::Exception etirm::Exception

Using SCPPNT exception types for exception violations.

Definition at line 112 of file etirmtypes.h.

typedef SCPPNT::Vector<int> etirm::int_vector

Vector type for integer values.

Definition at line 55 of file swig_etirm.h.

typedef SCPPNT::InvalidArgument etirm::InvalidArgument

Using SCPPNT exception types for invalid arguments.

Definition at line 106 of file etirmtypes.h.

typedef std::vector<ItemRespCounts *> etirm::ItemStatsVector

Container holding pointers to objects containing item statistics for each item.

Definition at line 155 of file swig_etirm.h.

typedef std::vector<item_type *> etirm::ItemVector

Vector type for item pointers.

Definition at line 58 of file swig_etirm.h.

typedef SCPPNT::LogicError etirm::LogicError

Using SCPPNT exception types for logical errors.

Definition at line 103 of file etirmtypes.h.

typedef std::vector<ItemParamPrior *> etirm::PriorVector

Data type to represent a vector of pointers to prior distributions.

Definition at line 126 of file ItemParamPrior.h.

typedef ETIRM_FLOAT_TYPE etirm::Real

Data type for floating point numbers.

This type is defined globally rather than being a template parameter in individual classes because it seemed unlikely that one would want different floating point types used for different ETIRM classes.

Definition at line 84 of file etirmtypes.h.

typedef SCPPNT::Matrix<Real> etirm::RealMatrix

Matrix type containing floating point numbers. Used in numeric calculations.

Definition at line 100 of file etirmtypes.h.

typedef SCPPNT::Vector<Real> etirm::RealVector

Vector type containing floating point numbers. Used in numeric calculations.

Definition at line 93 of file etirmtypes.h.

typedef ETIRM_RESPONSE_TYPE etirm::Response

Data type to hold an examinee item response.

Definition at line 87 of file etirmtypes.h.

typedef SCPPNT::RuntimeError etirm::RuntimeError

Using SCPPNT exception types for runtime errors.

Definition at line 109 of file etirmtypes.h.

typedef std::vector<Uncmin<RealVector, RealMatrix, item_type> *> etirm::UncminVector

Container to hold Uncmin optimization objects.

Definition at line 64 of file swig_etirm.h.


Enumeration Type Documentation

enum etirm::IRTModel

Enumeration for type of IRT model.

Enumerator:
OnePL  One-parameter logistic for dichotomous items.
TwoPL  Two-parameter logistic for dichotomous items.
ThreePL  Three-parameter logistic for dichotomous items.
PCM  Partial credit model for polytomous items.
GPCM  Generalized partial credit model for polytomous items.

Definition at line 115 of file etirmtypes.h.

00116   {
00117     //! One-parameter logistic for dichotomous items.
00118     OnePL,
00119     //! Two-parameter logistic for dichotomous items.
00120     TwoPL,
00121     //! Three-parameter logistic for dichotomous items.
00122     ThreePL,
00123     //! Partial credit model for polytomous items
00124     PCM,
00125     //! Generalized partial credit model for polytomous items
00126     GPCM
00127   };


Function Documentation

int etirm::add_examinee ( int_vector *  responses,
int  group,
double  count 
)

Add an examinee objec to the end of the examinee vector.

Returns the examinee number corresponding to this examinee.

Function Parameters

Parameters:
[in] *responses Pointer to vector of integer-formatted item responses. A negative integer indicates the examinee did not respond to the item. The integers representing responses are zero-offset (A response in the first response category is represented as zero).
[in] group Integer from 1 to maximum number of examinee groups giving the group the examinee belongs to.
[in] count Frequency given to response pattern (usually, count = 1).

Definition at line 1514 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), etirm::SwigEtirmRun::examineeCounts, etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::SwigEtirmRun::items, etirm::SwigEtirmRun::itemStats, etirm::SwigEtirmRun::numItems, etirm::Examinee< R, P >::SetCount(), and etirm::Examinee< R, P >::SetResponses().

01515   {
01516     const char *fname = "add_examinee";
01517     CheckRunInit();
01518     gEtirmRun->CheckGroup(group, fname);
01519 
01520     int len = responses->size();
01521 
01522     if (len != gEtirmRun->numItems)
01523     {
01524       throw RuntimeError("Invalid number of item responses", fname);
01525     }
01526 
01527     examinee_type *e = new examinee_type(len, group);
01528 
01529     ResponseVector r(len);
01530     ItemVector::iterator iitem = (gEtirmRun->items).begin();
01531     int_vector::iterator iir = responses->begin();
01532     ResponseVector::iterator ir = r.begin();
01533     ItemStatsVector::iterator is = (gEtirmRun->itemStats).begin();
01534     Response np = Item<Real>::NotPresentedResponse();
01535     for (; len--; ++iitem, ++iir, ++ir, ++is)
01536     {
01537       if (*iir < 0)
01538         *ir = np;
01539       else
01540       {
01541         *ir = (*iitem)->IndexResponse(*iir);
01542         if (!((*iitem)->ValidResponse(*ir)))
01543         {
01544           throw RuntimeError("Invalid item response", fname);
01545         }
01546         (*is)->AddResponse(*iir+1, count, group);
01547       }
01548     }
01549 
01550     e->SetResponses(r);
01551     e->SetCount(count);
01552 
01553     (gEtirmRun->examinees).push_back(e);
01554 
01555     (gEtirmRun->examineeCounts)[0] += count; // total count
01556     (gEtirmRun->examineeCounts)[group] += count; // group count
01557 
01558     return (gEtirmRun->examinees).size();
01559   }

Here is the call graph for this function:

template<class I>
void etirm::AssignItemNR ( int  n,
RealVector::iterator  itemTheta,
RealVector::iterator  nVec,
RealVector::iterator  rVec,
I *  item 
) [inline]

Assigns individual examinee thetas into discrete latent variable categories and updates expected counts n and r for item M-step.

Given category values of the discrete latent variable as c_1, c_2, ..., c_ncat, classifies individual thetas into categories using ncat-1 cutpoints (c_1+c_2)/2, (c_2+c_3)/2,..., where the examinee is classified into the first category if the theta value is less than (c_1+c_2)/2, into the second category if their theta value is greater than or equal to (c_1+c_2)/2 and less than (c_2+c_3)/2, etc.

Template Parameters

Parameters:
I Item type.

Function Parameters

Parameters:
[in,out] n Number of examinees who respond to the item on input, 0 on output.
[in] itemTheta Vector of thetas for examinees who reponded to an item.
[in,out] nVec Iterator to vector of expected item response counts for each theta value?
[in,out] rVec Iterator to vector of expected number correct counts for each theta value?.
[in,out] *item Pointer to item object.

Definition at line 376 of file Start3PL.h.

00378   {
00379     int i;
00380 
00381     int ncat = item->NumLatentVarCat();
00382 
00383     if (ncat == 0)
00384       throw RuntimeError("Values of discrete latent variable categories are missing for an item",
00385           "AssignItemNR");
00386 
00387     /* Compute cutpoints for categorizing individual latent variable values */
00388     RealVector cutpoints(ncat-1);
00389     RealVector::iterator ic = cutpoints.begin();
00390     typename I::point_iterator ip = item->GetLatentVarPoints(1); // use points for first group
00391     for (i=ncat-1; i--; ++ic, ++ip)
00392     {
00393       *ic = (ip[0] + ip[1]) / 2.0;
00394     }
00395 
00396     item->InitializeNR();
00397     typename I::n_iterator in = item->NVector();
00398     typename I::r_iterator ir = item->RVector(item->CorrectResponse());
00399     for (; n--; ++itemTheta, ++nVec, ++rVec)
00400     {
00401       /* find category for theta using inefficient linear search */
00402       ic = cutpoints.begin();
00403       for (i=0; i<ncat-1; ++i, ++ic)
00404       {
00405         if (*itemTheta < *ic)
00406           break;
00407       }
00408 
00409       in[i] += *nVec;
00410       ir[i] += *rVec;
00411     }
00412   }

void etirm::bootstrap_sample (  ) 

Generate bootstrap sample of examinees.

Definition at line 1944 of file swig_etirm.cpp.

References BootstrapSample(), etirm::SwigEtirmRun::CheckExaminees(), CheckRunInit(), etirm::SwigEtirmRun::examineeCounts, etirm::SwigEtirmRun::examinees, gEtirmRun, and etirm::SwigEtirmRun::rand_boot.

01945   {
01946     CheckRunInit();
01947     gEtirmRun->CheckExaminees("bootstrap_sample");
01948 
01949     if (!gEtirmRun->rand_boot)
01950       gEtirmRun->rand_boot = new random_type();
01951 
01952     boost::uniform_int<random_type> urand(*(gEtirmRun->rand_boot), 1, (gEtirmRun->examinees).size());
01953 
01954     BootstrapSample((gEtirmRun->examinees).begin(), (gEtirmRun->examinees).end(), urand);
01955 
01956     // Set vector of examinee counts
01957     gEtirmRun->examineeCounts = 0.0; // initialize to zero
01958     ExamineeVector::iterator ie = (gEtirmRun->examinees).begin();
01959     for (int i = (gEtirmRun->examinees).size(); i--; ++ie)
01960     {
01961       double count = (*ie)->Count();
01962       (gEtirmRun->examineeCounts)[0] += count; // total count
01963       int group = (*ie)->Group();
01964       (gEtirmRun->examineeCounts)[group] += count; // group count
01965     }
01966   }

Here is the call graph for this function:

void etirm::bootstrap_seed ( unsigned long  seed  ) 

Assigns seed of random number generator used for bootstrap samples.

Function Parameters

Parameters:
[in] seed Seed value, 0 <= seed <= 4,294,967,295.

Definition at line 1923 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::rand_boot.

01924   {
01925     CheckRunInit();
01926 
01927     // convert to type used for seed in boost random number library
01928     boost::uint32_t boost_seed = seed;
01929 
01930     if (gEtirmRun->rand_boot)
01931     {
01932       gEtirmRun->rand_boot->seed(boost_seed);
01933     }
01934     else
01935     {
01936       gEtirmRun->rand_boot = new random_type(boost_seed);
01937     }
01938   }

Here is the call graph for this function:

template<class URNG, class EI>
void etirm::BootstrapSample ( EI  examinees_begin,
EI  examinees_end,
URNG &  rand 
) [inline]

Generate a bootstrap sample for a group of examinees.

Template parameters

Parameters:
URNG Type of function object returning uniform random numbers over the integers 1 to the number of examines. An example of a type that meets the requirements for this function is the uniform_int class from the boost library (http://www.boost.org).
EI Type of iterator over pointers to examinee objects.
Arguments

Parameters:
examinees_begin Iterator to pointer to first examinee.
examinees_end - Iterator to one past pointer to last examinee.

Definition at line 48 of file BootstrapSample.h.

Referenced by bootstrap_sample().

00050   {
00051     // Number of examinees
00052     std::iterator_traits<EI>::difference_type n = std::distance(examinees_begin, examinees_end);
00053 
00054     if (rand.min() != 1 || rand.max() != n)
00055     {
00056       throw InvalidArgument("Invalid range for random number generator",
00057           "SCPPNT::BootstrapSample");
00058     }
00059 
00060     // Create vector to hold counts for each examinee from bootstrap sample - initially zero
00061     std::vector<int> counts(n, 0);
00062 
00063     // generate bootstrap counts
00064     for (int i=0; i<n; ++i)
00065     {
00066       ++counts[rand()-1];
00067     }
00068 
00069     // Assign counts to examinees
00070     for (std::vector<int>::iterator ic = counts.begin(); examinees_begin != examinees_end; ++ic,
00071         ++examinees_begin)
00072     {
00073       (*examinees_begin)->SetCount(*ic);
00074     }
00075   }

Here is the caller graph for this function:

void etirm::CheckItemParam ( item_type item,
int  index,
const char *  funcname 
)

Tests whether item parameter index is valid for the item.

Function Parameters

Parameters:
[in] *item Pointer to item object for which index is checked.
[in] index Zero-offset index of item parameter.
[in] *funcname pointer to name of calling function (used in error message).

Function Parameters

Parameters:
[in] *item Pointer to item object for which index is checked.
[in] index Zero-offset index of item parameter.
[in] *funcname pointer to name of calling function (used in error message).

Definition at line 284 of file swig_etirm.cpp.

References gEtirmRun, etirm::Item< L >::Index(), etirm::Item< L >::NumParameters(), and etirm::SwigEtirmRun::returnString.

Referenced by item_get_param(), item_get_prior_param(), item_get_prior_type(), item_set_param(), and item_set_prior().

00285   {
00286     if (item->NumParameters() <= index || index < 0)
00287     {
00288       char errstr[100];
00289       std::sprintf(errstr, "Invalid item parameter index for item %d: %d", item->Index()+1, index);
00290       gEtirmRun->returnString = errstr;
00291       throw RuntimeError((gEtirmRun->returnString).c_str(), funcname);
00292     }
00293   }

Here is the call graph for this function:

Here is the caller graph for this function:

void etirm::CheckRunInit (  ) 

Check that new_etirm has been called.

Note: This function is not defined in swig_etirm.cpp, it must be defined somewhere in the application.

Referenced by add_examinee(), bootstrap_sample(), bootstrap_seed(), etirm::estep::compute(), dist_get_point(), dist_get_points(), dist_get_prob(), dist_get_probs(), dist_mean_sd(), dist_scale(), dist_set_point(), dist_set_points(), dist_set_prob(), dist_set_probs(), dist_transform(), dist_unique_points(), etirm::estep::estep(), examinee_get_count(), examinee_get_group(), examinee_get_posterior(), examinee_posterior_mean(), examinee_response_str(), examinee_responses(), examinee_set_count(), examinee_set_group(), examinee_set_posterior(), examinee_theta_MLE(), examinees_count(), get_responses(), get_responses_missing(), item_cat_counts(), item_get_all_params(), item_get_model(), item_get_param(), item_get_params(), item_get_prior_param(), item_get_prior_type(), item_num_params(), item_num_resp_cat(), item_prob_resp(), item_resp_count(), item_scale_params(), item_set_all_params(), item_set_param(), item_set_params(), item_set_prior(), mstep_dist(), mstep_items(), mstep_max_diff(), mstep_max_iter(), mstep_message(), num_examinees(), num_groups(), num_items(), num_latent_dist_points(), simulate_response_str(), simulate_responses(), simulate_seed(), and test_characteristic_curve().

ItemParamPrior * etirm::CreatePrior ( const std::string &  pstr,
const double_vector &  priorparam,
const char *  funcname 
)

Create a prior distribution object and return a pointer to it.

Function Parameters

Parameters:
[in] pstr Type of prior distribution, valued as ("none", "normal", "lognormal", "beta").
[in] priorparam Parameters of prior distribution.
[in] funcname Name of calling function (used in error messages)

Definition at line 305 of file swig_etirm.cpp.

Referenced by item_set_prior().

00307   {
00308     const char *err_message = "Invalid number of prior parameters";
00309 
00310     if (pstr.compare("none") == 0)
00311     {
00312       return 0;
00313     }
00314     else if (pstr.compare("normal") == 0)
00315     {
00316       if (priorparam.size() != 2)
00317         throw RuntimeError(err_message, funcname);
00318       return new ItemParamPriorNormal(priorparam[0], priorparam[1]);
00319     }
00320     else if (pstr.compare("lognormal") == 0)
00321     {
00322       if (priorparam.size() != 2)
00323         throw RuntimeError(err_message, funcname);
00324       return new ItemParamPriorLogNormal(priorparam[0], priorparam[1]);
00325     }
00326     else if (pstr.compare("beta") == 0)
00327     {
00328       if (priorparam.size() != 4)
00329         throw RuntimeError(err_message, funcname);
00330       return new ItemParamPriorBeta4(priorparam[0], priorparam[1], priorparam[2], priorparam[3]);
00331     }
00332     else
00333     {
00334       throw RuntimeError("Invalid prior type", funcname);
00335     }
00336     return 0;
00337   }

Here is the caller graph for this function:

template<class PI, class WI>
void etirm::DiscreteNormalDist ( int  nQuad,
double  minPoint,
double  maxPoint,
PI  ipoints,
WI  iweights,
double  mean = 0.0,
double  sd = 1.0 
) [inline]

Compute points and weights for a discrete distribution that approximates a normal distribution.

DiscreteNormalDist

Arguments

nQuad Number of discrete points in distribution. minPoint Value of smallest point in distribution (must be smaller than the mean). maxPoint Value of largest point in distribution (must be larger than the mean). ipoints Iterator over nQuad points of distribution. iweights Iterator over nQuad probabilities corresponding to the points. mean Mean of normal distribution. sd Standard deviation of normal distribution.

Definition at line 56 of file DiscreteNormalDist.h.

Referenced by normal_dist_points(), normal_dist_prob(), and etirm::SwigEtirmRun::SwigEtirmRun().

00058 {
00059   int i;
00060   
00061   if ((maxPoint-minPoint) <= 0.0 || minPoint > mean || maxPoint < mean) 
00062     throw InvalidArgument("Invalid minimum and maximum points", "DiscreteNormalDist");
00063   
00064   double incr = (maxPoint-minPoint) / (nQuad-1.0);
00065   
00066   PI points = ipoints;
00067   WI weights = iweights;
00068   double theta = minPoint;
00069   double sum = 0.0;
00070   for (i=nQuad; i--; ++points, ++weights)
00071   {
00072     *points = (theta - mean) / sd;
00073     *weights = std::exp(-0.5 * theta * theta);
00074     sum += *weights;
00075     theta += incr;
00076   }
00077   
00078   /* Standardize weights */
00079   weights = iweights;
00080   for (i=nQuad; i--; ++weights)
00081   {
00082     *weights /= sum;
00083   }
00084   
00085 }

Here is the caller graph for this function:

double etirm::dist_get_point ( int  index,
int  group 
)

Returns the quadrature point value of one discrete category of the discrete latent variable distribution.

Function Parameters

Parameters:
[in] index Index of latent variable category (1, 2, ..., number of categories).
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1136 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01137   {
01138     CheckRunInit();
01139     gEtirmRun->CheckGroup(group, "dist_get_point");
01140 
01141     if (index < 1 || index> (gEtirmRun->latentDist).size())
01142     {
01143       throw RuntimeError("Invalid category of latent variable distribution","dist_get_point");
01144     }
01145 
01146     DiscreteLatentDist<Real>::point_iterator ip = (gEtirmRun->latentDist).begin_points(group);
01147 
01148     return ip[index-1];
01149   }

Here is the call graph for this function:

double_vector * etirm::dist_get_points ( int  group  ) 

Returns vector of quadrature point values of the discrete latent variable distribution.

Function Parameters

Parameters:
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1109 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01110   {
01111     CheckRunInit();
01112     gEtirmRun->CheckGroup(group, "dist_get_points");
01113 
01114     DiscreteLatentDist<Real>::point_iterator ip = (gEtirmRun->latentDist).begin_points(group);
01115 
01116     int n = (gEtirmRun->latentDist).size();
01117     double_vector *outv = new double_vector(n);
01118     double_vector::iterator id = outv->begin();
01119     for (; n--; ++ip, ++id)
01120     {
01121       *id = *ip;
01122     }
01123 
01124     return outv;
01125   }

Here is the call graph for this function:

double etirm::dist_get_prob ( int  index,
int  group 
)

Returns the quadrature weight of one discrete category of the latent variable distribution for one group of examinees.

Function Parameters

Parameters:
[in] index Index of latent variable category (1, 2, ..., number of categories).
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1253 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01254   {
01255     CheckRunInit();
01256     gEtirmRun->CheckGroup(group, "dist_get_prob");
01257 
01258     if (index < 1 || index> (gEtirmRun->latentDist).size())
01259     {
01260       throw RuntimeError("Invalid category of latent variable distribution","dist_get_prob");
01261     }
01262 
01263     DiscreteLatentDist<Real>::weight_iterator ip = (gEtirmRun->latentDist).begin_weights(group);
01264 
01265     return ip[index-1];
01266   }

Here is the call graph for this function:

double_vector * etirm::dist_get_probs ( int  group  ) 

Returns vector of quadrature weights of the latent variable distribution for one group of examinees.

Function Parameters

Parameters:
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1224 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01225   {
01226     CheckRunInit();
01227     gEtirmRun->CheckGroup(group, "dist_get_probs");
01228 
01229     DiscreteLatentDist<Real>::weight_iterator ip = (gEtirmRun->latentDist).begin_weights(group);
01230 
01231     int n = (gEtirmRun->latentDist).size();
01232     double_vector *outv = new double_vector(n);
01233     double_vector::iterator id = outv->begin();
01234     for (; n--; ++ip, ++id)
01235     {
01236       *id = *ip;
01237     }
01238 
01239     return outv;
01240 
01241   }

Here is the call graph for this function:

double_vector * etirm::dist_mean_sd ( int  group  ) 

Returns a vector with the mean and standard deviation of the latent variable distribution for a selected group of examinees.

Function Parameters

Parameters:
[in] group Group to use as reference group (1, 2, ..., number of groups).

Definition at line 1320 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01321   {
01322     CheckRunInit();
01323     gEtirmRun->CheckGroup(group, "dist_mean_sd");
01324 
01325     double mean, sd;
01326     (gEtirmRun->latentDist).MeanSD(group, mean, sd);
01327 
01328     double_vector *outv = new double_vector(2);
01329 
01330     (*outv)[0] = mean;
01331     (*outv)[1] = sd;
01332 
01333     return outv;
01334   }

Here is the call graph for this function:

double_vector * etirm::dist_scale ( double  mean,
double  sd,
int  group 
)

Scales to the quadrature points of latent variable distribution to yield a specfic mean and standard deviation in one group.

Function Parameters

Parameters:
[in] mean Mean of reference group after scaling the latent distribution.
[in] sd Standard deviation of reference group after scaling the latent distribution.
[in] group Group to use as reference group (1, 2, ..., number of groups).

Definition at line 1295 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01296   {
01297     CheckRunInit();
01298     gEtirmRun->CheckGroup(group, "dist_scale");
01299 
01300     double slope, intercept;
01301     (gEtirmRun->latentDist).Scale(mean, sd, group, slope, intercept);
01302 
01303     double_vector *outv = new double_vector(2);
01304 
01305     (*outv)[0] = slope;
01306     (*outv)[1] = intercept;
01307 
01308     return outv;
01309   }

Here is the call graph for this function:

void etirm::dist_set_point ( int  index,
double  p,
int  group 
)

Assigns a quadrature point value to one discrete category of the discrete latent variable distribution.

Function Parameters

Parameters:
[in] index Index of latent variable category (1, 2, ..., number of categories).
[in] p Value to assign to point.
[in] group Group to use (1, 2, ..., number of groups), default = 1.
Latent distribution functions

Definition at line 1086 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01087   {
01088     CheckRunInit();
01089     gEtirmRun->CheckGroup(group, "dist_set_point");
01090 
01091     if (index < 1 || index> (gEtirmRun->latentDist).size())
01092     {
01093       throw RuntimeError("Invalid category of latent variable distribution","dist_set_point");
01094     }
01095 
01096     DiscreteLatentDist<Real>::point_iterator ip = (gEtirmRun->latentDist).begin_points(group);
01097 
01098     ip[index-1] = p;
01099   }

Here is the call graph for this function:

void etirm::dist_set_points ( double_vector *  dlist,
int  group 
)

Assigns quadrature point values to each discrete category of the discrete latent variable distribution.

Function Parameters

Parameters:
[in] *dlist Pointer to vector of quadrature points of the latent variable distribution.
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1055 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01056   {
01057     CheckRunInit();
01058     gEtirmRun->CheckGroup(group, "dist_set_points");
01059 
01060     int n = dlist->size();
01061     if (n != (gEtirmRun->latentDist).size())
01062     {
01063       throw RuntimeError("Number of points does not match number of categories in latent distribution",
01064           "dist_set_points");
01065     }
01066 
01067     DiscreteLatentDist<Real>::point_iterator ip = (gEtirmRun->latentDist).begin_points(group);
01068 
01069     double_vector::iterator id = dlist->begin();
01070     for (; n--; ++ip, ++id)
01071     {
01072       *ip = *id;
01073     }
01074   }

Here is the call graph for this function:

void etirm::dist_set_prob ( int  index,
double  w,
int  group 
)

Assigns the quadrature weight to one discrete category of the discrete latent variable distribution.

Function Parameters

Parameters:
[in] index Index of latent variable category (1, 2, ..., number of categories).
[in] w Value to assign to weight.
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1200 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01201   {
01202     CheckRunInit();
01203     gEtirmRun->CheckGroup(group, "dist_set_prob");
01204 
01205     if (index < 1 || index> (gEtirmRun->latentDist).size())
01206     {
01207       throw RuntimeError("Invalid category of latent variable distribution","dist_set_prob");
01208     }
01209 
01210     DiscreteLatentDist<Real>::weight_iterator ip = (gEtirmRun->latentDist).begin_weights(group);
01211 
01212     ip[index-1] = w;
01213   }

Here is the call graph for this function:

void etirm::dist_set_probs ( double_vector *  dlist,
int  group 
)

Assigns quadrature weights to the quadrature points of the latent variable distribution.

Function Parameters

Parameters:
[in] *dlist Pointer to vector of quadrature weights of the latent variable distribution.
[in] group Group to use (1, 2, ..., number of groups), default = 1.

Definition at line 1160 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01161   {
01162     CheckRunInit();
01163     gEtirmRun->CheckGroup(group, "dist_set_probs");
01164 
01165     int n = dlist->size();
01166     if (n != (gEtirmRun->latentDist).size())
01167     {
01168       throw RuntimeError("Number of probabilities does not match number of categories in latent distribution",
01169           "dist_set_probs");
01170     }
01171 
01172     // assign probabilities
01173     DiscreteLatentDist<Real>::weight_iterator ip = (gEtirmRun->latentDist).begin_weights(group);
01174     double_vector::iterator id = dlist->begin();
01175     Real sum = 0.0;
01176     for (; n--; ++ip, ++id)
01177     {
01178       *ip = *id;
01179       sum += *ip;
01180     }
01181 
01182     // standardize probabilities to they sum to 1
01183     ip = (gEtirmRun->latentDist).begin_weights(group);
01184     for (n = dlist->size(); n--; ++ip)
01185     {
01186       *ip /= sum;
01187     }
01188   }

Here is the call graph for this function:

void etirm::dist_transform ( double  slope,
double  intercept 
)

Transforms the quadrature points of latent variable distribution to a new scale.

Function Parameters

Parameters:
[in] slope Slope parameter of linear scale transformation.
[in] intercept Intercept parameter of linear scale transformation.

Definition at line 1277 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01278   {
01279     CheckRunInit();
01280 
01281     (gEtirmRun->latentDist).Transform(slope, intercept);
01282   }

Here is the call graph for this function:

int etirm::dist_unique_points (  ) 

Returns 1 if unique sets of quadrature points are used for two or more groups of examinees, or returns 0 otherwise.

Definition at line 1341 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01342   {
01343     CheckRunInit();
01344 
01345     return ((gEtirmRun->latentDist).NumGroupsUnique() > 1 && (gEtirmRun->latentDist).NumGroups() > 1);
01346   }

Here is the call graph for this function:

double etirm::examinee_get_count ( int  examineeno  ) 

Returns the count (or weight) of the examinee.

Function Parameters

Parameters:
[in] examineeno Number of examinee whose count (or weight) is to be returned.

Definition at line 1719 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::Examinee< R, P >::Count(), etirm::SwigEtirmRun::examinees, and gEtirmRun.

01720   {
01721     CheckRunInit();
01722     gEtirmRun->CheckExamineeNumber(examineeno, "examinee_get_count");
01723 
01724     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01725 
01726     return examinee->Count();
01727   }

Here is the call graph for this function:

int etirm::examinee_get_group ( int  examineeno  ) 

Return the number of the group the examinee belongs to.

Function Parameters

Parameters:
[in] examineeno Number of examinee for whom group membership is to be returned.

Definition at line 1663 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, and etirm::ExamineeGrpCov< R, P >::Group().

01664   {
01665     CheckRunInit();
01666     gEtirmRun->CheckExamineeNumber(examineeno, "examinee_group");
01667 
01668     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01669 
01670     return examinee->Group();
01671   }

Here is the call graph for this function:

double_vector * etirm::examinee_get_posterior ( int  examineeno  ) 

Returns pointer to vector of the posterior distribution of an examinee.

Function Parameters

Parameters:
[in] examineeno Number of examinee whose posterior is to be returned.

Definition at line 1782 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::Examinee< R, P >::NumLatentVarCat(), etirm::Examinee< R, P >::posterior_begin(), and etirm::SwigEtirmRun::returnString.

01783   {
01784     char *fname = "examinee_get_posterior";
01785     CheckRunInit();
01786     gEtirmRun->CheckExamineeNumber(examineeno, fname);
01787 
01788     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01789     int n = examinee->NumLatentVarCat();
01790 
01791     if (n == 0)
01792     {
01793       char merr[100];
01794       std::sprintf(merr, "Posterior has not been computed for examinee %d", examineeno);
01795       gEtirmRun->returnString = merr;
01796       throw RuntimeError((gEtirmRun->returnString).c_str(), fname);
01797     }
01798 
01799     double_vector *post = new double_vector(n);
01800 
01801     examinee_type::posterior_vector::iterator ie = examinee->posterior_begin();
01802     double_vector::iterator ip = post->begin();
01803     for (; n--; ++ie, ++ip)
01804     {
01805       *ip = *ie;
01806     }
01807 
01808     return post;
01809   }

Here is the call graph for this function:

double etirm::examinee_posterior_mean ( int  examineeno  ) 

Returns means of an examinee's posterior distribution.

Posterior must have already been computed, for example, by estep_compute.

Function Parameters

Parameters:
[in] examineeno Number of examinee whose posterior mean is to be returned.

Definition at line 1821 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::SwigEtirmRun::latentDist, etirm::Examinee< R, P >::NumLatentVarCat(), etirm::Examinee< R, P >::posterior_begin(), and etirm::SwigEtirmRun::returnString.

01822   {
01823     char *fname = "examinee_posterior_mean";
01824     CheckRunInit();
01825     gEtirmRun->CheckExamineeNumber(examineeno, fname);
01826 
01827     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01828     int n = examinee->NumLatentVarCat();
01829 
01830     if (n == 0)
01831     {
01832       char merr[100];
01833       std::sprintf(merr, "Posterior distribution has not been computed for examinee %d", examineeno);
01834       gEtirmRun->returnString = merr;
01835       throw RuntimeError((gEtirmRun->returnString).c_str(), fname);
01836     }
01837 
01838     examinee_type::posterior_vector::iterator iw = examinee->posterior_begin();
01839     lvdist_type::point_iterator ip = (gEtirmRun->latentDist).begin_points();
01840     double mean = 0.0;
01841     for (; n--; ++iw, ++ip)
01842     {
01843       mean += *ip * *iw;
01844     }
01845 
01846     return mean;
01847   }

Here is the call graph for this function:

const char * etirm::examinee_response_str ( int  examineeno  ) 

Returns string containing (character) examinee responses to all items.

A response in the first response category is '0', a response in the second category is '1', etc. Because each response is represented by a single character care must be taken when some items have more than 10 response categories. For example, a response in the 11th response category would be represented by the ascii character ':', which is the 10th character greater than '0' in the ascii character sequence.

Function Parameters

Parameters:
[in] examineeno Number of examinee for whom item responses are returned.

Definition at line 1624 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::SwigEtirmRun::items, etirm::Examinee< R, P >::NumItems(), Resp2Char(), etirm::Examinee< R, P >::responses_begin(), etirm::Examinee< R, P >::responses_end(), and etirm::SwigEtirmRun::returnString.

01625   {
01626     const char *fname = "examinee_response_str";
01627     CheckRunInit();
01628     gEtirmRun->CheckExamineeNumber(examineeno, fname);
01629 
01630     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01631 
01632     if ((gEtirmRun->items).size() != examinee->NumItems())
01633     {
01634       throw RuntimeError("Number of examinee responses does not match number of items", fname);
01635     }
01636 
01637     // iterators to first and one past last response
01638     examinee_type::response_iterator first = examinee->responses_begin();
01639     examinee_type::response_iterator last = examinee->responses_end();
01640 
01641     std::string &responseStr = gEtirmRun->returnString;
01642     responseStr.clear();
01643     ItemVector::iterator ii = (gEtirmRun->items).begin();
01644     while (first != last)
01645     {
01646       responseStr.push_back(Resp2Char(*first, *ii));
01647       ++ii;
01648       ++first;
01649     }
01650 
01651     return responseStr.c_str();
01652   }

Here is the call graph for this function:

int_vector * etirm::examinee_responses ( int  examineeno  ) 

Returns pointer to an integer vector of examinee item responses to all items.

A non-negative integer indicates an examinee response in the category represented by the integer (0 = first response category, 1 = second response category, etc.). A negative integer indicates the examinee did not respond to the item.

Function Parameters

Parameters:
[in] examineeno Number of examinee for whom item responses are returned.

Definition at line 1574 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::SwigEtirmRun::items, etirm::Examinee< R, P >::NumItems(), etirm::Examinee< R, P >::responses_begin(), and etirm::Examinee< R, P >::responses_end().

01575   {
01576     const char *fname = "examinee_responses";
01577     CheckRunInit();
01578     gEtirmRun->CheckExamineeNumber(examineeno, fname);
01579 
01580     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01581 
01582     if ((gEtirmRun->items).size() != examinee->NumItems())
01583     {
01584       throw RuntimeError("Number of examinee responses does not match number of items", fname);
01585     }
01586 
01587     // iterators to first and one past last response
01588     examinee_type::response_iterator first = examinee->responses_begin();
01589     examinee_type::response_iterator last = examinee->responses_end();
01590 
01591     int_vector *responses = new int_vector(examinee->NumItems());
01592     int_vector::iterator ir = responses->begin();
01593     ItemVector::iterator ii = (gEtirmRun->items).begin();
01594     Response np = Item<Real>::NotPresentedResponse();
01595     while (first != last)
01596     {
01597       if (*first == np)
01598         *ir = -1;
01599       else
01600         *ir = (*ii)->ResponseIndex(*first);
01601       ++ir;
01602       ++ii;
01603       ++first;
01604     }
01605 
01606     return responses;
01607   }

Here is the call graph for this function:

void etirm::examinee_set_count ( int  examineeno,
double  count 
)

Assigns the count (or weight) of the examinee.

Function Parameters

Parameters:
[in] examineeno Number of examinee whose count (or weight) is to be assigned.
[in] count Count to be assigned to examinee.

Definition at line 1701 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, and etirm::Examinee< R, P >::SetCount().

01702   {
01703     CheckRunInit();
01704     gEtirmRun->CheckExamineeNumber(examineeno, "examinee_set_count");
01705 
01706     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01707 
01708     examinee->SetCount(count);
01709   }

Here is the call graph for this function:

void etirm::examinee_set_group ( int  examineeno,
int  group 
)

Assigns which group the examinee belongs to.

Function Parameters

Parameters:
[in] examineeno Number of examinee for whom group membership is to be assigned.
[in] group Group number to be assigned to examinee.

Definition at line 1682 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, and etirm::ExamineeGrpCov< R, P >::SetGroup().

01683   {
01684     CheckRunInit();
01685     gEtirmRun->CheckExamineeNumber(examineeno, "examinee_set_group");
01686 
01687     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01688 
01689     return examinee->SetGroup(group);
01690   }

Here is the call graph for this function:

void etirm::examinee_set_posterior ( int  examineeno,
double_vector *  posterior 
)

Assigns posterior distribution of an examinee.

Function Parameters

Parameters:
[in] examineeno Number of examinee whose posterior is to be assigned.
[in] *posterior Pointer to vector of posterior probabilities of the examinee.

Definition at line 1738 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::SwigEtirmRun::latentDist, etirm::SwigEtirmRun::numLatentCat, and etirm::Examinee< R, P >::SetPosterior().

01739   {
01740     CheckRunInit();
01741     gEtirmRun->CheckExamineeNumber(examineeno, "examinee_set_posterior");
01742 
01743     if (posterior->size() != (gEtirmRun->latentDist).size())
01744     {
01745       throw RuntimeError("Invalid number of posterior probabilities",
01746           "examinee_set_posterior");
01747     }
01748 
01749     examinee_type *examinee = (gEtirmRun->examinees)[examineeno-1];
01750 
01751     examinee_type::posterior_vector epost(gEtirmRun->numLatentCat);
01752     examinee_type::posterior_vector::iterator iep = epost.begin();
01753     double_vector::iterator ip = posterior->begin();
01754 
01755     // assign probabilities
01756     int i;
01757     Real sum = 0.0;
01758     for (i = gEtirmRun->numLatentCat; i--; ++iep, ++ip)
01759     {
01760       *iep = *ip;
01761       sum += *iep;
01762     }
01763 
01764     // standardize probabilities to sum to 1.0
01765     iep = epost.begin();
01766     for (i = gEtirmRun->numLatentCat; i--; ++iep)
01767     {
01768       *iep /= sum;
01769     }
01770 
01771     examinee->SetPosterior(epost);
01772   }

Here is the call graph for this function:

double etirm::examinee_theta_MLE ( int  examineeno,
double  minTheta,
double  maxTheta,
double  precision,
int_vector *  itemno5 
)

Returns an examinee's maximum likelihood estimate of theta.

Posterior must have already been computed, for example, by estep_compute.

Function Parameters

Parameters:
[in] examineeno Number of examinee whose theta MLE is to be returned (1 = first examinee).
[in] minTheta Minimum value of theta estimate.
[in] maxTheta Maximum value of theta estimate.
[in] precision Length of interval in which MLE is determined to lie. This should be greater than, roughly, 3.0e-8.
[in] *itemno5 Pointer to a list of item numbers of the items to use in computing examinee MLE. If itemno5 = NULL, then all items will be used.

Definition at line 1865 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::base_rand_simulate, etirm::SwigEtirmRun::CheckExamineeNumber(), CheckRunInit(), etirm::SwigEtirmRun::examinees, gEtirmRun, etirm::SwigEtirmRun::items, ItemSubset(), and etirm::SwigEtirmRun::rand_simulate.

01867   {
01868     CheckRunInit();
01869     gEtirmRun->CheckExamineeNumber(examineeno, "examinee_theta_MLE");
01870 
01871     if (!gEtirmRun->base_rand_simulate)
01872     {
01873       gEtirmRun->base_rand_simulate = new random_type();
01874       gEtirmRun->rand_simulate = new boost::uniform_01<random_type>(*(gEtirmRun->base_rand_simulate));
01875     }
01876 
01877     ItemVector *sitems;
01878     if (itemno5)
01879     {
01880       sitems = new ItemVector(ItemSubset(itemno5, gEtirmRun->items, "examinee_theta_MLE"));
01881     }
01882     else
01883     {
01884       sitems = &(gEtirmRun->items);
01885     }
01886 
01887     double theta =
01888         ExamineeThetaMLE<ItemVector::iterator, examinee_type::response_vector::iterator>(minTheta,
01889             maxTheta, precision, sitems->begin(), sitems->end(), (gEtirmRun->examinees[examineeno-1])->responses_begin());
01890 
01891     if (itemno5)
01892       delete sitems;
01893 
01894     return theta;
01895   }

Here is the call graph for this function:

double etirm::examinees_count ( int  group  ) 

Returns total examinee count in an examinee group (1, 2, ...), or across all groups.

Function Parameters

Parameters:
[in] group Group to return count for (1-offset). Specify group = 0 to return counts across all groups.

Definition at line 1906 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), etirm::SwigEtirmRun::examineeCounts, and gEtirmRun.

01907   {
01908     CheckRunInit();
01909     if (group != 0)
01910       gEtirmRun->CheckGroup(group, "examinee_count");
01911 
01912     return (gEtirmRun->examineeCounts)[group];
01913   }

Here is the call graph for this function:

template<class II, class IR>
Real etirm::ExamineeThetaMLE ( Real  minTheta,
Real  maxTheta,
Real  precision,
II  items_begin,
II  items_end,
IR  responses_begin 
) [inline]

Compute latent variable estimate for an examinee using maximum likelihood, create a ThetaLogLikelihood object from two item iterators and an interator to the examinee responses, and return the latent trait estimate for the examinee.

Template Parameters

Parameters:
II Iterator type over pointers to item objects.
IR Iterator type over examinee responses to items.

Function Parameters

Parameters:
[in] minTheta Minimum value of theta estimate
[in] maxTheta Maximum value of theta estimate
[in] precision Length of interval in which MLE is determined to lie. This should be greater than, roughly, 3.0e-8.
[in] items_begin Iterator pointing to first item object pointer.
[in] items_end Iterator pointing to one past the last item object pointer.
[in] responses_begin Iterator pointing to examinee's response to first item.

Definition at line 100 of file ExamineeThetaMLE.h.

References ExamineeThetaMLE().

00102   {
00103     // Last argument being true indicates the function object
00104     // should return the negative of the likelihood since
00105     // the function will be minimized, not maximized.
00106     ThetaLogLikelihood<II,IR> likelihood(items_begin, items_end, responses_begin, true);
00107 
00108     return ExamineeThetaMLE(minTheta, maxTheta, precision, likelihood);
00109 
00110   }

Here is the call graph for this function:

template<class L>
Real etirm::ExamineeThetaMLE ( Real  minTheta,
Real  maxTheta,
Real  precision,
L &  likelihood 
) [inline]

Compute latent variable estimate for an examinee using maximum likelihood. Returns the latent trait estimate for the examinee.

Template Parameters

Parameters:
L Function type returning minus the loglihood. An object of this type is passed to minimization procedure.

Function Parameters

Parameters:
[in] minTheta Minimum value of theta estimate
[in] maxTheta Maximum value of theta estimate
[in] precision Length of interval in which MLE is determined to lie. This should be greater than, roughly, 3.0e-8.
[in] likelihood The function to minimize (minus the loglikelihood).

Definition at line 53 of file ExamineeThetaMLE.h.

Referenced by ExamineeThetaMLE().

00055   {
00056     Real midTheta = (minTheta + maxTheta) / 2.0;
00057 
00058     // See if middle value is bracketed
00059     Real fmin = likelihood(minTheta);
00060     Real fmid = likelihood(midTheta);
00061     Real fmax = likelihood(maxTheta);
00062 
00063     Real theta;
00064 
00065     // Compute minimum on two intervals and take the one corresponding to the largest
00066     // likelihood. This reduces the chances of a local minimum being identified by Fmin when the
00067     // function is multimodal and is not bracketed.
00068     fmin = Fmin(minTheta, midTheta, likelihood, precision);
00069     fmax = Fmin(midTheta, maxTheta, likelihood, precision);
00070     
00071     theta = (likelihood(fmin) < likelihood(fmax)) ? fmin : fmax;
00072     return theta;
00073   }

Here is the caller graph for this function:

int_vector * etirm::get_responses ( char *  line,
int_vector *  offset,
int_vector *  len 
)

Reads item responses from an input record.

The item responses are assumed to be integers from 0 to one minus the maximum number of response categories for the item. A response representing a missing response is assigned -1.

Returns poiner to an integer vector containing thew item responses.

Function Parameters

Parameters:
[in] *line Pointer to character string to read the item responses from.
[in] *offset Pointer to vector of zero-based offsets of each item response in 'line'.
[in] *len Pointer to vector of field widths for each item response.

Definition at line 2102 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::returnString.

Referenced by get_responses_missing().

02103   {
02104     const char *fname = "get_responses";
02105     CheckRunInit();
02106 
02107     int n = offset->size();
02108 
02109     if (n != len->size())
02110     {
02111       throw InvalidArgument("Lengths of offset and length vectors do not match", fname);
02112     }
02113 
02114     int_vector *resp = new int_vector(n);
02115 
02116     int_vector::iterator ir = resp->begin();
02117     int_vector::iterator ioff = offset->begin();
02118     int_vector::iterator ilen = len->begin();
02119     Response np = Item<Real>::NotPresentedResponse();
02120     for (; n--; ++ioff, ++ilen, ++ir)
02121     {
02122       // Convert response to integer
02123       char *pos = line + *ioff + *ilen - 1;
02124       *ir = 0;
02125       int power = 1;
02126       for (int i=*ilen; i--; power *= 10, --pos)
02127       {
02128         if (*pos == np) // check for missing item response
02129         {
02130           *ir = -1;
02131           break;
02132         }
02133         else if ( (*pos < '0') && (*pos > '9')) // check that item response is valid // Sytax edited, ww, 2-24-2008.
02134         {
02135           char errstr[50];
02136           std::sprintf(errstr, "Invalid item response: %1c", *pos);
02137           gEtirmRun->returnString = errstr;
02138           throw RuntimeError((gEtirmRun->returnString).c_str(), fname);
02139         }
02140         *ir += power * (*pos - '0');
02141       }
02142     }
02143 
02144     return resp;
02145   }

Here is the call graph for this function:

Here is the caller graph for this function:

int_vector * etirm::get_responses_missing ( char *  line,
int_vector *  offset,
int_vector *  len,
int_vector *  items 
)

Read item responses from a string where responses to only some items are present. The responses to the remaining items are assumed to be missing.

The item responses are assumed to be integers from 0 to one minus the maximum number of response categories for the item. A response representing a missing response is assigned -1.

Returns poiner to an integer vector containing thew item responses.

Function Parameters

Parameters:
[in] *line Pointer to character string to read the item responses from.
[in] *offset Pointer to vector of zero-based offsets of each item response in 'line'.
[in] *len Pointer to vector of field widths for each item response.
[in] *items Pointer to vector 1-offset indices of items for which responses are read.

Definition at line 2165 of file swig_etirm.cpp.

References CheckRunInit(), get_responses(), gEtirmRun, and etirm::SwigEtirmRun::numItems.

02167   {
02168     const char *fname = "get_responses_missing";
02169     CheckRunInit();
02170 
02171     int n = offset->size();
02172 
02173     if (n != len->size() || n != items->size())
02174     {
02175       throw InvalidArgument("Lengths of vector arguments do not match", fname);
02176     }
02177 
02178     int_vector *resp = get_responses(line, offset, len);
02179 
02180     // initially assign all missing responses
02181     int nall = gEtirmRun->numItems;
02182     int_vector *allresp = new int_vector(nall, -1);
02183 
02184     // Assign responses read
02185     int_vector::iterator ir = resp->begin();
02186     int_vector::iterator ii = items->begin();
02187     for (; n--; ++ii, ++ir)
02188     {
02189       if ( (*ii < 1) || (*ii > nall)) // Syntax edited, ww, 2-24-2008.
02190       {
02191         delete resp;
02192         throw InvalidArgument("Invalid item number", fname);
02193       }
02194       (*allresp)[*ii-1] = *ir;
02195     }
02196 
02197     delete resp;
02198 
02199     return allresp;
02200   }

Here is the call graph for this function:

double_vector * etirm::item_cat_counts ( int  itemno,
int  group 
)

Returns vector of response counts in each response category of an item.

Function Parameters

Parameters:
[in] itemno Number of item for which response counts are returned (1-offset).
[in] group Group to return counts for (1-offset). Specify group = 0 to return counts across all groups.

Definition at line 897 of file swig_etirm.cpp.

References etirm::ItemRespCounts::CategoryCounts(), etirm::SwigEtirmRun::CheckGroup(), etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::itemStats.

00898   {
00899     const char *fname = "item_cat_counts";
00900     CheckRunInit();
00901 
00902     gEtirmRun->CheckItemNumber(itemno, fname);
00903     if (group != 0)
00904       gEtirmRun->CheckGroup(group, "item_resp_count");
00905 
00906     ItemRespCounts *stats = (gEtirmRun->itemStats)[itemno-1];
00907 
00908     double_vector *v = new double_vector(stats->CategoryCounts(group));
00909 
00910     return v;
00911   }

Here is the call graph for this function:

double_vector * etirm::item_get_all_params ( int  itemno  ) 

Returns vector of all fixed and estimated item parameters values of an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).
Note: The order of the parameters in the params vector is: a (if there is an a parameter), one or more b's, and c (if there is a c parameter).

Definition at line 727 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), etirm::Item< L >::GetAllParameters(), gEtirmRun, and etirm::SwigEtirmRun::items.

00728   {
00729     CheckRunInit();
00730     gEtirmRun->CheckItemNumber(itemno, "item_get_all_params");
00731 
00732     item_type *item = (gEtirmRun->items)[itemno-1];
00733 
00734     RealVector allparam = item->GetAllParameters();
00735     int n = allparam.size();
00736     double_vector *params = new double_vector(n);
00737 
00738     RealVector::iterator pv = allparam.begin();
00739     double_vector::iterator iv = params->begin();
00740     for (; n--; ++pv, ++iv)
00741     {
00742       *iv = *pv;
00743     }
00744 
00745     return params;
00746   }

Here is the call graph for this function:

const char * etirm::item_get_model ( int  itemno  ) 

Returns the name of model used for an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).

Definition at line 522 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, etirm::Item< L >::ModelName(), and etirm::SwigEtirmRun::returnString.

00523   {
00524 
00525     CheckRunInit();
00526     std::string &modelName = gEtirmRun->returnString;
00527     gEtirmRun->CheckItemNumber(itemno, "item_get_model");
00528 
00529     item_type *item = (gEtirmRun->items)[itemno-1];
00530     modelName = item->ModelName();
00531 
00532     return modelName.c_str();
00533   }

Here is the call graph for this function:

double etirm::item_get_param ( int  paramno,
int  itemno 
)

Returns value of one item parameter of an item.

Function Parameters

Parameters:
[in] paramno 1-offset index of the parameter in the item's parameter vector.
[in] itemno Item number (1-offset).
Note: The order of the parameters in the params vector is: a (if there is an a parameter), one or more b's, and c (if there is a c parameter).

Definition at line 668 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckItemParam(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, and etirm::Item< L >::ParametersIterator().

00669   {
00670     const char *fname = "item_get_param";
00671     CheckRunInit();
00672     int index = paramno - 1;
00673 
00674     gEtirmRun->CheckItemNumber(itemno, fname);
00675     item_type *item = (gEtirmRun->items)[itemno-1];
00676     CheckItemParam(item, index, fname);
00677 
00678     item_type::param_iterator pv = item->ParametersIterator();
00679 
00680     return pv[index];
00681   }

Here is the call graph for this function:

double_vector * etirm::item_get_params ( int  itemno  ) 

Returns vector of all estimated item parameters values of an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).
Note: The order of the parameters in the params vector is: a (if there is an a parameter), one or more b's, and c (if there is a c parameter).

Definition at line 695 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, etirm::Item< L >::NumParameters(), and etirm::Item< L >::ParametersIterator().

00696   {
00697     CheckRunInit();
00698     gEtirmRun->CheckItemNumber(itemno, "item_get_params");
00699 
00700     item_type *item = (gEtirmRun->items)[itemno-1];
00701 
00702     int n = item->NumParameters();
00703     double_vector *params = new double_vector(n);
00704 
00705     item_type::param_iterator pv = item->ParametersIterator();
00706     double_vector::iterator iv = params->begin();
00707     for (; n--; ++pv, ++iv)
00708     {
00709       *iv = *pv;
00710     }
00711 
00712     return params;
00713   }

Here is the call graph for this function:

double_vector * etirm::item_get_prior_param ( int  paramno,
int  itemno 
)

Returns vector of prior distribution parameters for one item parameter.

Function Parameters

Parameters:
[in] paramno 1-offset index of parameter in parameter vector for item.
[in] itemno Number of item for which prior is returned (1-offset).

Definition at line 858 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckItemParam(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, and etirm::Item< L >::PriorsIterator().

00859   {
00860     const char *fname = "item_get_prior_param";
00861     CheckRunInit();
00862     int index = paramno - 1;
00863 
00864     gEtirmRun->CheckItemNumber(itemno, fname);
00865     item_type *item = (gEtirmRun->items)[itemno-1];
00866     CheckItemParam(item, index, fname);
00867 
00868     item_type::prior_iterator pv = item->PriorsIterator() + index;
00869 
00870     double_vector *v;
00871     if (*pv != 0)
00872     {
00873       int n = (*pv)->NumParameters();
00874 
00875       v = new double_vector(n);
00876 
00877       *v = (*pv)->GetParameters();
00878     }
00879     else
00880     {
00881       v = new double_vector();
00882     }
00883 
00884     return v;
00885   }

Here is the call graph for this function:

const char * etirm::item_get_prior_type ( int  paramno,
int  itemno 
)

Returns type of prior distribution ("normal", "lognormal", "beta", "none") for one item parameter.

Function Parameters

Parameters:
[in] paramno 1-offset index of parameter in parameter vector for item.
[in] itemno Number of item for which prior is returned (1-offset).

Definition at line 824 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckItemParam(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, etirm::Item< L >::PriorsIterator(), and etirm::SwigEtirmRun::returnString.

00825   {
00826     const char *fname = "item_get_prior_type";
00827     CheckRunInit();
00828     std::string &priorName = gEtirmRun->returnString;
00829     int index = paramno - 1;
00830 
00831     gEtirmRun->CheckItemNumber(itemno, fname);
00832     item_type *item = (gEtirmRun->items)[itemno-1];
00833     CheckItemParam(item, index, fname);
00834 
00835     item_type::prior_iterator pv = item->PriorsIterator() + index;
00836 
00837     if (*pv != 0)
00838     {
00839       priorName = (*pv)->DistributionName();
00840     }
00841     else
00842     {
00843       priorName = "none";
00844     }
00845 
00846     return priorName.c_str();
00847   }

Here is the call graph for this function:

int etirm::item_num_params ( int  itemno  ) 

Returns the number of parameters of an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).

Definition at line 756 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, and etirm::Item< L >::NumParameters().

00757   {
00758     CheckRunInit();
00759     gEtirmRun->CheckItemNumber(itemno, "item_num_params");
00760 
00761     item_type *item = (gEtirmRun->items)[itemno-1];
00762 
00763     return item->NumParameters();
00764   }

Here is the call graph for this function:

int etirm::item_num_resp_cat ( int  itemno  ) 

Returns the number of response categories of an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).

Definition at line 774 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, and etirm::Item< L >::NumRespCat().

00775   {
00776     CheckRunInit();
00777     gEtirmRun->CheckItemNumber(itemno, "item_num_resp_cat");
00778 
00779     item_type *item = (gEtirmRun->items)[itemno-1];
00780 
00781     return item->NumRespCat();
00782   }

Here is the call graph for this function:

double etirm::item_prob_resp ( int  itemno,
int  response,
double  theta 
)

Returns the probability that an examinee with a particular theta value will give a particular response to a particular item.

Function Parameters

Parameters:
[in] itemno Number (1-based) of item for which response probability is returned.
[in] response Integer representing response, where a response in the first response category is 0, a response in the second response category is 1, etc.
[in] theta Value of latent variable for which response probability is returned.

Definition at line 970 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::Item< L >::IndexResponse(), etirm::SwigEtirmRun::items, and etirm::Item< L >::ProbResp().

00971   {
00972     CheckRunInit();
00973     gEtirmRun->CheckItemNumber(itemno, "item_prob_resp");
00974 
00975     item_type *item = (gEtirmRun->items)[itemno-1];
00976 
00977     return item->ProbResp(item->IndexResponse(response), theta);
00978   }

Here is the call graph for this function:

double etirm::item_resp_count ( int  itemno,
int  group 
)

Returns the number of examinees responding to an item.

Function Parameters

Parameters:
[in] itemno Number of item for which response counts are returned (1-offset).
[in] group Group to return counts for (1-offset). Specify group = 0 to return count across all groups.

Definition at line 923 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::itemStats.

00924   {
00925     CheckRunInit();
00926 
00927     gEtirmRun->CheckItemNumber(itemno, "item_resp_count");
00928     if (group != 0)
00929       gEtirmRun->CheckGroup(group, "item_resp_count");
00930 
00931     return (gEtirmRun->itemStats)[itemno-1]->RespCount(group);
00932   }

Here is the call graph for this function:

int etirm::item_scale_params ( int  itemno,
double  slope,
double  intercept,
bool  ignorePriorError 
)

Transforms the parameter estimates of an item to a different latent variable scale.

Returns zero if parameters are successfully scaled, or returns nonzero if scaling would result in an invalid parameter value.

Function Parameters

Parameters:
[in] itemno Number of item for which to transform parameters (1-offset).
[in] slope Slope of scale transformation to apply to item parameters.
[in] intercept Intercept of scale transformation to apply to item parameters.
[in] ignorePriorError If true then do not report an error if transformed parameter has zero density in prior used for that parameter.

Definition at line 948 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, and etirm::Item< L >::ScaleParameters().

00949   { // Retyped ignorePriorErro from "int" to "bool", ww, 2-24-2008.
00950     CheckRunInit();
00951 
00952     gEtirmRun->CheckItemNumber(itemno, "item_scale_params");
00953     item_type *item = (gEtirmRun->items)[itemno-1];
00954 
00955     return item->ScaleParameters(slope, intercept, ignorePriorError);
00956   }

Here is the call graph for this function:

void etirm::item_set_all_params ( int  itemno,
double_vector *  params 
)

Assigns values to all fixed and estimated item parameters of an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).
[in] *params Pointer to params vector containing the values to set the parameters to.
Note: The order of the parameters in the params vector is: a (if there is an a parameter), one or more b's, and c (if there is a c parameter).

Definition at line 629 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, etirm::Item< L >::NumParameters(), etirm::Item< L >::ParametersIterator(), etirm::Item< L >::PriorsIterator(), etirm::SwigEtirmRun::returnString, and etirm::Item< L >::SetAllParameters().

00630   {
00631     const char *fname = "item_set_all_params";
00632     CheckRunInit();
00633     gEtirmRun->CheckItemNumber(itemno, fname);
00634 
00635     item_type *item = (gEtirmRun->items)[itemno-1];
00636 
00637     // Assign new fixed and estimated parameters
00638     item->SetAllParameters(*params);
00639 
00640     /* Check that values of estimated parameters all have nonzero prior density */
00641     item_type::param_iterator iv = item->ParametersIterator();
00642     item_type::prior_iterator pri = item->PriorsIterator();
00643     for (int n = item->NumParameters(); n--; ++pri, ++iv)
00644     {
00645       if (*pri && (*pri)->ZeroDensity(*iv))
00646       {
00647         char merr[100];
00648         std::sprintf(merr, "Parameter specified for item %d has zero prior density", itemno);
00649         gEtirmRun->returnString = merr;
00650         throw InvalidArgument((gEtirmRun->returnString).c_str(), fname);
00651       }
00652     }
00653   }

Here is the call graph for this function:

void etirm::item_set_param ( int  paramno,
int  itemno,
double  paramvalue 
)

Assigns a value to one item parameter of an item.

Function Parameters

Parameters:
[in] paramno 1-offset index of parameter in parameter vector for item.
[in] itemno Item number (1-offset).
[in] paramvalue Value parameter is set to.

Definition at line 545 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckItemParam(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, etirm::Item< L >::ParametersIterator(), etirm::Item< L >::PriorsIterator(), and etirm::SwigEtirmRun::returnString.

00546   {
00547     const char *fname = "item_set_param";
00548     CheckRunInit();
00549     int index = paramno - 1;
00550 
00551     gEtirmRun->CheckItemNumber(itemno, fname);
00552     item_type *item = (gEtirmRun->items)[itemno-1];
00553     CheckItemParam(item, index, fname);
00554 
00555     /* Check that value of parameter has nonzero prior density */
00556     item_type::prior_iterator pri = item->PriorsIterator() + index;
00557     if (*pri && (*pri)->ZeroDensity(paramvalue))
00558     {
00559       char merr[100];
00560       std::sprintf(merr, "Parameter specified for item %d has zero prior density", itemno);
00561       gEtirmRun->returnString = merr;
00562       throw RuntimeError((gEtirmRun->returnString).c_str(), fname);
00563     }
00564 
00565     item_type::param_iterator pv = item->ParametersIterator();
00566 
00567     pv[index] = paramvalue;
00568   }

Here is the call graph for this function:

void etirm::item_set_params ( int  itemno,
double_vector *  params 
)

Assigns values to all item parameters of an item.

Function Parameters

Parameters:
[in] itemno Item number (1-offset).
[in] *params Pointer to params vector containing the values to set the parameters to.
Note: The order of the parameters in the params vector is: a (if there is an a parameter), one or more b's, and c (if there is a c parameter).

Definition at line 584 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, etirm::Item< L >::NumParameters(), etirm::Item< L >::ParametersIterator(), and etirm::Item< L >::PriorsIterator().

00585   {
00586     const char *fname = "item_set_params";
00587     CheckRunInit();
00588     gEtirmRun->CheckItemNumber(itemno, fname);
00589 
00590     item_type *item = (gEtirmRun->items)[itemno-1];
00591 
00592     // Assign new parameters
00593     item_type::param_iterator pv = item->ParametersIterator();
00594     double_vector::iterator iv = params->begin();
00595     int n;
00596     for (n = item->NumParameters(); n--; ++pv, ++iv)
00597     {
00598       *pv = *iv;
00599     }
00600 
00601     /* Check that values of all parameters have nonzero prior density */
00602     iv = params->begin();
00603     item_type::prior_iterator pri = item->PriorsIterator();
00604     for (n = item->NumParameters(); n--; ++pri, ++iv)
00605     {
00606       if (*pri && (*pri)->ZeroDensity(*iv))
00607       {
00608         char merr[100];
00609         std::sprintf(merr, "Parameter specified for item %d has zero prior density", itemno);
00610         throw InvalidArgument(merr, fname);
00611       }
00612     }
00613   }

Here is the call graph for this function:

void etirm::item_set_prior ( int  paramno,
int  itemno,
char *  priortype,
double_vector *  dlist 
)

Assigns prior distribution parameters for one item parameter.

Function Parameters

Parameters:
[in] paramno 1-offset index of parameter in parameter vector for item.
[in] itemno Number of item for which prior is set (1-offset).
[in] *priortype Pointer to type of prior distribution ("normal", "lognormal", "beta", "none").
[in] *dlist Pointer to vector of prior distribution parameters.

Definition at line 795 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckItemParam(), CheckRunInit(), CreatePrior(), gEtirmRun, etirm::SwigEtirmRun::items, and etirm::Item< L >::PriorsIterator().

00796   {
00797     const char *funcname = "item_set_prior";
00798     CheckRunInit();
00799     int index = paramno - 1;
00800 
00801     gEtirmRun->CheckItemNumber(itemno, funcname);
00802     item_type *item = (gEtirmRun->items)[itemno-1];
00803     CheckItemParam(item, index, funcname);
00804 
00805     item_type::prior_iterator pv = item->PriorsIterator() + index;
00806 
00807     if (*pv)
00808       delete *pv;
00809 
00810     std::string pstr(priortype);
00811     *pv = CreatePrior(pstr, *dlist, funcname);
00812   }

Here is the call graph for this function:

template<class IE, class RI>
void etirm::ItemMoments ( int  num_examinees,
IE  begin_examinee,
int  item,
RealVector &  abilities,
Response  notPresentedResponse,
double *  mean,
double *  variance 
) [inline]

Compute mean and standard deviation of person ability over examinees who reponded to an item.

Template Parameters

Parameters:
EI Type of iterator over examinees (iterator over pointers to Examinee objects)
RI Type of iterator over examinee responses (iterator returned by responses_begin() for an Examinee object)

Function Parameters

Parameters:
[in] num_examinees Number of examinees.
[in] begin_examinee Iterator to pointer to first examinee.
[in] item Index of item in response string to compute moments for (0 offset).
[in] &abilities Address of ability vector for all persons.
[in] notPresentedResponse Response which indicates an item was not presented to an examinee. Assumed to be the same for all items.
[out] mean Mean of abilities for persons resonding to the item.
[out] variance Variance of abilities for persons resonding to the item.

Definition at line 111 of file Start3PL.h.

References invalidLogit.

00113   {
00114     /* Compute logit of examinee proportion correct scores */
00115     RealVector::iterator iabil = abilities.begin();
00116     IE ie = begin_examinee;
00117     Real total = 0;
00118     *mean = 0.0;
00119     *variance = 0.0;
00120     for (int i = num_examinees; i--; ++ie, ++iabil)
00121     {
00122       RI resp = (*ie)->responses_begin() + item;
00123       Real count = (*ie)->Count();
00124 
00125       if (*resp != notPresentedResponse && *iabil != invalidLogit)
00126       {
00127         *mean += *iabil * count;
00128         *variance += *iabil * *iabil * count;
00129         total += count;
00130       }
00131     }
00132 
00133     *mean /= total;
00134     *variance /= total;
00135     *variance -= *mean * *mean;
00136   }

template<class V>
V etirm::ItemSubset ( int_vector *  itemnums,
V &  all,
const char *  funcname 
) [inline]

Creates a container holding the elements corresponding to a subset of items.

ItemSubset is based on a container holding elements corresponding to all items. This container is typically used to create subsets of etirmrun->items (which is an ItemVector) and etirmrun->minProc (which is a UncminVector).

Template Parameters

Parameters:
V ItemVector type.

Function Parameters

Parameters:
[in] *itemnums Pointer to vector containing numbers of items to include in subset.
[in] &all Address of container containing all items.
[in] *funcname Pointer to name of calling function (used in error messages)

Definition at line 297 of file swig_etirm.h.

Referenced by etirm::estep::compute(), etirm::estep::estep(), examinee_theta_MLE(), mstep_items(), simulate_responses(), and test_characteristic_curve().

00298   {
00299     int i;
00300     int nsub = itemnums->size();
00301     int nall = all.size();
00302 
00303     if (nsub < 1 || nsub> nall)
00304     {
00305       throw RuntimeError("Invalid number of items", funcname);
00306     }
00307 
00308     V sub(nsub);
00309     int *flag = new int[nall]; // flags indicating which items are in subset
00310     for (i = 0; i < nall; ++i) flag[i] = 0;
00311 
00312     typename V::iterator iall = all.begin();
00313     typename V::iterator isub = sub.begin();
00314     int_vector::iterator ino = itemnums->begin();
00315     for(i = 0; i < nsub; ++i, ++isub, ++ino)
00316     {
00317       int index = *ino - 1; // elements of itemnums are 1-offset indices
00318       if (index < 0 || index >= nall)
00319       {
00320         delete [] flag;
00321         throw RuntimeError("Invalid item number", funcname);
00322       }
00323       if (flag[index] == 1)
00324       {
00325         delete [] flag;
00326         throw RuntimeError("Duplicate item number", funcname);
00327       }
00328       flag[index] = 1;
00329       *isub = iall[index];
00330     }
00331     delete [] flag;
00332 
00333     return sub;
00334   }

Here is the caller graph for this function:

double etirm::MaxRelParamDiff ( RealVector &  oldParam,
RealVector &  newParam,
Real  typicalValue = 1.0 
)

Returns the maximum relative difference between an old and new set of item parameters.

Parameters:
[in] &oldParam Address of vector containing base parameter values.
[in] &newParam Address of vector containing comparison (new) parameter values.
[in] typicalValue Minimum denominator for relative comparison.

Definition at line 34 of file MStepIRT.cpp.

Referenced by MStepItems().

00035 {
00036   double reldiff = 0.0;
00037   
00038   RealVector::iterator iold = oldParam.begin();
00039   RealVector::iterator inew = newParam.begin();
00040   
00041   for (int n = oldParam.size(); n--; ++iold, ++inew)
00042   {
00043     Real d = *iold - *inew;
00044     Real denom = *inew;
00045     denom = (denom < 0.0) ? -denom : denom; // fabs(denom)
00046     denom = (denom < typicalValue) ? typicalValue : denom;
00047     if (denom != 0.0) d /= denom;
00048     d = (d < 0.0) ? -d : d; // fabs(d)
00049     if (reldiff < d) reldiff = d;
00050   }
00051   
00052   return reldiff;
00053 }

Here is the caller graph for this function:

double etirm::mstep_dist ( estep *  e,
int  group 
)

Executes M-step for the latent distribution in one group.

Returns maximum relative difference between new and old probabilities.

Function Parameters

Parameters:
[in] *e Pointer to not sure what(?!). To-Do: Find out what *e relates to!
[in] group Number of examinee group (1, 2, ..., number of groups).

Definition at line 1487 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckGroup(), CheckRunInit(), etirm::estep::GetEStep(), gEtirmRun, and etirm::SwigEtirmRun::latentDist.

01488   {
01489     CheckRunInit();
01490     gEtirmRun->CheckGroup(group, "mstep_dist");
01491 
01492     estep_type::ngroup_iterator i = (e->GetEStep())->GetNGroup(group);
01493     RealVector::size_type n = (e->GetEStep())->size();
01494     RealVector prob(i, i+n);
01495     return (gEtirmRun->latentDist).MStep(prob, group);
01496   }

Here is the call graph for this function:

int etirm::mstep_items ( bool  ignore_max_iter,
int_vector *  itemno 
)

CalculateS M-step for a set of items.

Function Parameters

Parameters:
[in] ignore_max_iter Flag: If ignore_max_iter == TRUE, then exceeding the maximum number of iterations in optimization procedure is NOT a fatal error; if ignore_max_iter == FALSE, then the exceeding the max_iter is treated as a fatal error (default = FALSE).
[in] *itemno Pointer to vector of integers giving item numbers (1-offset) for which the M-step is calculated. If itemno is the null pointer, then all items are used (default = null).

Definition at line 1412 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, ItemSubset(), etirm::SwigEtirmRun::minProc, MStepItems(), and etirm::SwigEtirmRun::mstepMaxDiff.

01413   {  // Retyped ignore_max_iter from "int" to "bool", ww, 2-25-2008.
01414     CheckRunInit();
01415 
01416     if (itemno)
01417     {
01418       const char *fname = "mstep_items";
01419       ItemVector itemsub = ItemSubset(itemno, gEtirmRun->items, fname);
01420       UncminVector minsub = ItemSubset(itemno, gEtirmRun->minProc, fname);
01421       return MStepItems(minsub.begin(), itemsub.begin(), itemsub.end(), gEtirmRun->mstepMaxDiff,
01422           ignore_max_iter);
01423     }
01424     else
01425     {
01426       return MStepItems((gEtirmRun->minProc).begin(), (gEtirmRun->items).begin(), (gEtirmRun->items).end(), gEtirmRun->mstepMaxDiff, ignore_max_iter);
01427     }
01428   }

Here is the call graph for this function:

double etirm::mstep_max_diff (  ) 

Returns the maximum relative difference between parameter estimates in two successive EM iterations, as computed in last call to mstep_items.

Definition at line 1469 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::mstepMaxDiff.

01470   {
01471     CheckRunInit();
01472 
01473     return gEtirmRun->mstepMaxDiff;
01474   }

Here is the call graph for this function:

void etirm::mstep_max_iter ( int  itemno,
int  maxiter 
)

Assigns the maximum number of iterations permitted with optimization procedure in mstep_items for one item.

Function Parameters

Parameters:
[in] itemno Integer giving item number (1-offset).
[in] maxiter Maximum number of iterations for stepwise optimization.

Definition at line 1456 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::minProc.

01457   {
01458     CheckRunInit();
01459     gEtirmRun->CheckItemNumber(itemno, "mstep_max_iter");
01460 
01461     return ((gEtirmRun->minProc)[itemno-1])->SetMaxIter(maxiter);
01462   }

Here is the call graph for this function:

int etirm::mstep_message ( int  itemno  ) 

Returns message from M-step minimization for one item.

Function Parameters

Parameters:
[in] itemno Integer giving item number (1-offset).

Definition at line 1438 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::CheckItemNumber(), CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::minProc.

01439   {
01440     CheckRunInit();
01441     gEtirmRun->CheckItemNumber(itemno, "mstep_message");
01442 
01443     return ((gEtirmRun->minProc)[itemno-1])->GetMessage();
01444   }

Here is the call graph for this function:

template<class MI, class II>
int etirm::MStepItems ( MI  min_routines,
II  item_begin,
II  item_end,
double &  maxreldiff,
bool  ignoreMaxIter = false 
) [inline]

Executes M-step for each item.

This function is used when the M-step can be carried out separately for each item.

Returns 0 if successful.

If ignoreMaxIter is true, and the only error that occurs is that the maximum number of M-step iterations is exceeded, then returns negative of number of items for which maximum number iterations were exceeded.

If ignoreMaxIter is false and an error occurs, or an error other than exceeding the maximum number of M-step iterations occurs, then returns the item number (1-offset) for which error occurred and processing is stopped at the point of the error.

Template Parameters

Parameters:
II Iterator to Item object pointer.
MI Iterator to pointers to minimization routines (interface is for Uncmin, but any minimization routine with the same interface as Uncmin could be used).

Function Parameters

Parameters:
[in] min_routines Object holding minimization routine (any minimization parameters set will be used for each item).
[in] item_begin Iterator pointing to first item (*item_begin is a pointer to the first item)
[in] item_end Iterator pointing to one past last item (*(item_end-1) is a pointer to the last item)
[out] &maxreldiff Address of maximum relative difference between an old and new parameter estimate across all items.
[in] ignoreMaxIter If true and maximum number of M-step iterations are exceeded then parameters are used anyway. If false and maximum number of M-step iterations are exceeded the function returns immediately with item number at which error occurred.

Definition at line 77 of file MStepIRT.h.

References MaxRelParamDiff().

Referenced by mstep_items().

00079   {
00080     int nMaxIter = 0;
00081     maxreldiff = 0.0;
00082 
00083     for (II iitem = item_begin; iitem != item_end; ++iitem, ++min_routines)
00084     {
00085       (*min_routines)->SetFunction(*iitem);
00086 
00087       int dim = (*iitem)->dim();
00088       RealVector start = (*iitem)->GetParameters();
00089       RealVector xpls(dim), gpls(dim);
00090       double fpls;
00091 
00092       int result = (*min_routines)->Minimize(start, xpls, fpls, gpls);
00093 
00094       if (result != 0)
00095       {
00096         int message = (*min_routines)->GetMessage();
00097         if (ignoreMaxIter && message == 4)
00098           nMaxIter--; // assumes message==4 means maximum number of iterations exceeded
00099         else
00100           return iitem-item_begin+1; // return number of item where minimization failed
00101       }
00102       (*iitem)->SetParameters(xpls);
00103 
00104       double d = MaxRelParamDiff(start, xpls);
00105       if (maxreldiff < d)
00106         maxreldiff = d;
00107     }
00108     return nMaxIter;
00109   }

Here is the call graph for this function:

Here is the caller graph for this function:

double_vector * etirm::normal_dist_points ( int  npoints,
double  minPoint,
double  maxPoint,
double  mean,
double  sd 
)

Returns a vector of quadrature points for a discrete distribution over a set of equally-spaced points.

Function Parameters

Parameters:
[in] npoints Number of discrete points in the latent distribution.
[in] minPoint Minimum point of the discrete distribution (must be smaller than the mean).
[in] maxPoint Maximum point of the discrete distribution (must be larger than the mean).
[in] mean Mean of the normal distribution.
[in] sd Standard deviation of the normal distribution.

Definition at line 1387 of file swig_etirm.cpp.

References DiscreteNormalDist().

01389   {
01390     RealVector prob(npoints);
01391     RealVector *points = new RealVector(npoints);
01392 
01393     // Probabilities do not matter so make up mean and sd
01394     DiscreteNormalDist(npoints, minPoint, maxPoint, points->begin(), prob.begin(), mean, sd);
01395 
01396     return points;
01397   }

Here is the call graph for this function:

double_vector * etirm::normal_dist_prob ( int  npoints,
double  minPoint,
double  maxPoint,
double  mean,
double  sd 
)

Returns a vector of probabilities for a discrete distribution to approximate a normal distribution over a set of equally spaced points.

Note: The mean and s.d. parameters only effect the quadrature points themselves, so it does not matter which values are passed for the mean and s.d.

Function Parameters

Parameters:
[in] npoints Number of discrete points in the latent distribution.
[in] minPoint Minimum point of the discrete distribution (must be smaller than the mean).
[in] maxPoint Maximum point of the discrete distribution (must be larger than the mean).
[in] mean Mean of the normal distribution.
[in] sd Standard deviation of the normal distribution.

Definition at line 1364 of file swig_etirm.cpp.

References DiscreteNormalDist().

01366   {
01367     RealVector points(npoints);
01368     RealVector *prob = new RealVector(npoints);
01369 
01370     DiscreteNormalDist(npoints, minPoint, maxPoint, points.begin(), prob->begin(), mean, sd);
01371 
01372     return prob;
01373   }

Here is the call graph for this function:

int etirm::num_examinees (  ) 

Returns number of examinees.

Definition at line 507 of file swig_etirm.cpp.

References CheckRunInit(), etirm::SwigEtirmRun::examinees, and gEtirmRun.

Referenced by PROX().

00508   {
00509     CheckRunInit();
00510 
00511     return (gEtirmRun->examinees).size();
00512   }

Here is the call graph for this function:

Here is the caller graph for this function:

int etirm::num_groups (  ) 

Returns number of examinee groups.

Definition at line 496 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::numGroups.

00497   {
00498     CheckRunInit();
00499 
00500     return gEtirmRun->numGroups;
00501   }

Here is the call graph for this function:

int etirm::num_items (  ) 

Returns the number of items.

Definition at line 474 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::numItems.

00475   {
00476     CheckRunInit();
00477 
00478     return gEtirmRun->numItems;
00479   }

Here is the call graph for this function:

int etirm::num_latent_dist_points (  ) 

Returns number of categories of the discrete theta distribution.

Definition at line 485 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::numLatentCat.

00486   {
00487     CheckRunInit();
00488 
00489     return gEtirmRun->numLatentCat;
00490   }

Here is the call graph for this function:

template<class RI, class II>
void etirm::PersonMoments ( RI  iresp,
II  iitem,
RealVector &  itemdiff,
Response  notPresentedResponse,
Real *  mean,
Real *  variance 
) [inline]

Compute mean and standard deviation of logit item difficulty over items responded to by an examinee.

Template Parameters

Parameters:
RI Type of iterator over examinee responses (iterator returned by responses_begin() for an Examinee object)
II Type of iterator over items (iterator over pointers to Item objects)

Function Parameters

Parameters:
[in] resp Iterator pointing to first response of examinee.
[in] iitem Iterator pointing to first item.
[in] itemdiff Item difficulties.
[in] notPresentedResponse Response which indicates an item was not presented to an examinee. Assumed to be the same for all items.
[out] mean Mean of abilities for persons responding to the item.
[out] variance Variance of abilities for persons responding to the item.

Definition at line 65 of file Start3PL.h.

References invalidLogit.

00067   {
00068 
00069     /* Compute logit of examinee proportion correct scores */
00070     RealVector::iterator idiff = itemdiff.begin();
00071     int total = 0;
00072     *mean = 0.0;
00073     *variance = 0.0;
00074     for (int i = itemdiff.size(); i--; ++iitem, ++idiff)
00075     {
00076       Response resp = iresp[(*iitem)->Index()];
00077       if (resp != notPresentedResponse && *idiff != invalidLogit)
00078       {
00079         *mean += *idiff;
00080         *variance += *idiff * *idiff;
00081         ++total;
00082       }
00083     }
00084 
00085     *mean /= total;
00086     *variance /= total;
00087     *variance -= *mean * *mean;
00088   }

template<class EI, class RI, class II>
void etirm::PROX ( int  numItems,
bool  useAll,
EI  begin_examinee,
EI  end_examinee,
II  begin_item,
Response  notPresentedResponse,
RealVector &  itemdiff,
RealVector &  abilities 
) [inline]

Compute Rasch item difficulties and examinee abilities using the Normal Approximation Estimation Algorithm (PROX).

The scale of the latent variable is set such that the sum of the item difficulties is zero.

For information on PROX see

Linacre, J. M. (1994). PROX with missing data. Rasch Measurement Transactions, 8(3), 378.

Cohen, L. (1979). Approximate expressions for parameter estimates in the Rasch model. British Journal of Mathematical and Statistical Psychology, 32(1), 113-120.

Template Parameters

Parameters:
EI Type of iterator over examinees (iterator over pointers to Examinee objects).
RI Type of iterator over examinee responses (iterator returned by responses_begin() for an Examinee object).
II Type of iterator over items (iterator over pointers to Item objects).

Function Parameters

Parameters:
[in] numItems Number of items.
[in] useAll If true calculate PROX estimates for all examinees and items, even examinees who get all items right or all items wrong, and even for items answered all correctly or all incorrectly.
[in] begin_examinee Iterator to pointer to first examinees.
[in] end_examinee Iterator to pointer to one past last examinees.
[in] begin_item Iterator to pointers to first item.
[in] notPresentedResponse Response which indicates an item was not presented to an examinee. Assumed to be the same for all items.
[out] itemdiff Item difficulties.
[out] abilities Examinee abilities.

Definition at line 176 of file Start3PL.h.

References invalidLogit, and num_examinees().

00179   {
00180     const int maxIter = 10; // maximum number of iterations for PROX algorithm
00181     const double convergenceCrit = 0.01; // if maximum difference in examinee abilities is less then this
00182     // over consecutive iterations then stop
00183     int i, iitem;
00184     int num_examinees = end_examinee - begin_examinee;
00185     RealVector logitDiff(numItems);
00186     RealVector logitAbility(num_examinees);
00187 
00188     /* Compute logit of item difficulties */
00189     RealVector::iterator ilogit = logitDiff.begin();
00190     for (i=0; i<numItems; ++i, ++ilogit)
00191     {
00192       Real total = 0.0;
00193       Real sum = 0.0;
00194       EI ie = begin_examinee;
00195       int nvalid = 0;
00196       iitem = begin_item[i]->Index();
00197       Response correct = begin_item[i]->CorrectResponse();
00198       while (ie != end_examinee)
00199       {
00200         RI ir = (*ie)->responses_begin() + iitem;
00201         if (*ir != notPresentedResponse)
00202         {
00203           if (*ir == correct)
00204             sum += (*ie)->Count();
00205           total += (*ie)->Count();
00206           ++nvalid;
00207         }
00208         ++ie;
00209       }
00210 
00211       if (total == 0.0)
00212         throw RuntimeError("No valid responses for an item", "PROX");
00213 
00214       if (sum == 0.0 || sum == total)
00215       {
00216         if (useAll)
00217         {
00218           Real halfCount = total / (2*nvalid); // 1/2 average count per examinee (usually 0.5)
00219           Real maxLogit = std::log(halfCount / (total-halfCount));
00220 
00221           /* Use sum = halfcount if sum == 0.0 and use sum = total - halfCount if sum == total */
00222           *ilogit = (sum == 0.0) ? maxLogit : (1.0 / maxLogit);
00223         }
00224         else
00225         {
00226           *ilogit = invalidLogit;
00227         }
00228       }
00229       else
00230       {
00231         *ilogit = std::log(sum / (total-sum));
00232       }
00233     }
00234 
00235     /* Compute logit of examinee proportion correct scores */
00236     ilogit = logitAbility.begin();
00237     for (EI ie = begin_examinee; ie != end_examinee; ++ie, ++ilogit)
00238     {
00239       Real total = 0.0;
00240       Real sum = 0.0;
00241       II item = begin_item;
00242       RI bresp = (*ie)->responses_begin();
00243       for (i=numItems; i--; ++item)
00244       {
00245         Response resp = bresp[(*item)->Index()];
00246         if (resp != notPresentedResponse)
00247         {
00248           if (resp == (*item)->CorrectResponse())
00249             ++sum;
00250           ++total;
00251         }
00252       }
00253 
00254       if (total == 0.0)
00255       {
00256         *ilogit = invalidLogit;
00257       }
00258       else if (sum == 0.0 || sum == total)
00259       {
00260         if (useAll)
00261         {
00262           /* Use sum = 0.5 if sum == 0.0 and use sum = total - 0.5 if sum == total */
00263           *ilogit = (sum == 0.0) ? (std::log(0.5 / (total-0.5))) : std::log((total - 0.5) / 0.5);
00264         }
00265         else
00266         {
00267           *ilogit = invalidLogit;
00268         }
00269       }
00270       else
00271       {
00272         *ilogit = std::log(sum / (total-sum));
00273       }
00274     }
00275 
00276     int iter;
00277     double mean = 0.0;
00278     double variance = 1.0;
00279     RealVector prevAbility(abilities); // ability estimates at previous iteration - used to check for convergence
00280     for (iter=0; iter<maxIter; ++iter)
00281     {
00282       /* Compute difficulties for each item */
00283       RealVector::iterator idiff = itemdiff.begin();
00284       ilogit = logitDiff.begin();
00285       Real sum = 0.0;
00286       int nvalid = 0;
00287       for (i=0; i<numItems; ++i, ++ilogit, ++idiff)
00288       {
00289         if (*ilogit != invalidLogit)
00290         {
00291           /* Compute mean and variance of abilities for persons responding to item i */
00292           if (iter > 0) // mean and variance of item difficulties set to 0 and 1 for first iteration
00293           {
00294             iitem = begin_item[i]->Index();
00295             ItemMoments<EI, RI>(num_examinees, begin_examinee, iitem, abilities,
00296                 notPresentedResponse, &mean, &variance);
00297           }
00298 
00299           /* Compute new item difficulty */
00300           *idiff = mean - std::sqrt(1 + variance/2.9) * *ilogit;
00301           sum += *idiff;
00302 
00303           ++nvalid;
00304         }
00305       }
00306 
00307       /* adjust item difficulties to sum to zero */
00308       sum /= nvalid;
00309       idiff = itemdiff.begin();
00310       for (i = numItems; i--; ++idiff)
00311       {
00312         if (*idiff != invalidLogit)
00313           *idiff -= sum;
00314       }
00315 
00316       /* Compute abilities for each examinee */
00317       RealVector::iterator iabil = abilities.begin();
00318       ilogit = logitAbility.begin();
00319       for (EI ie = begin_examinee; ie != end_examinee; ++ie, ++iabil, ++ilogit)
00320       {
00321         if (*ilogit != invalidLogit)
00322         {
00323           /* Compute mean and variance of item difficulties for items person responded to */
00324           PersonMoments<RI, II>((*ie)->responses_begin(), begin_item, itemdiff, notPresentedResponse, &mean, &variance);
00325 
00326           /* Compute new person ability */
00327           *iabil = mean + std::sqrt(1 + variance/2.9) * *ilogit;
00328         }
00329       }
00330 
00331       /* Check if abilities have converged */
00332       if (iter > 0)
00333       {
00334         Real maxdiff = 0.0;
00335         for (i=0; i<num_examinees; ++i)
00336         {
00337           if (abilities[i] != invalidLogit)
00338           {
00339             Real diff = std::fabs(abilities[i] - prevAbility[i]);
00340             if (diff > maxdiff)
00341               maxdiff = diff;
00342           }
00343         }
00344         if (maxdiff < convergenceCrit)
00345           break;
00346       }
00347       prevAbility = abilities;
00348     }
00349   }

Here is the call graph for this function:

char etirm::Resp2Char ( Response  r,
const item_type item 
)

Converts a response for an item into a character, where '0' represents the first response, '1' represents the second response, etc.

If the number of response categories for the item is greater than 10, then the characters returned will be ascii characters greater than '9'. For example, a ':' is return for a response in response category 11, since ':' is one greater than '9' in the ascii sequence.

Function Parameters

Parameters:
[in] r Item response to be converted.
[in] *item Pointer to item object.

Definition at line 354 of file swig_etirm.cpp.

References etirm::Item< L >::FirstResponse(), etirm::Item< D::latentvar_type >::NotPresentedResponse(), and etirm::Item< L >::ResponseIndex().

Referenced by examinee_response_str().

00355   {
00356     const char zero = '0';
00357     Response np = item_type::NotPresentedResponse();
00358     char cr;
00359     if (r == np)
00360       cr = np - item->FirstResponse() + zero;
00361     else
00362       cr = item->ResponseIndex(r) + zero;
00363 
00364     return cr;
00365   }

Here is the call graph for this function:

Here is the caller graph for this function:

void etirm::set_missing_resp ( char  nr  ) 

Assigns missing response code to identify examinees who did not respond to an item.

Definition at line 461 of file swig_etirm.cpp.

References gEtirmRun.

00462   {
00463     if (gEtirmRun)
00464     {
00465       throw RuntimeError("The not presented response can only be set before any items are initialized", 0);
00466     }
00467     Item<Real>::SetNotPresentedResponse(nr);
00468   }

const char * etirm::simulate_response_str ( double  theta,
int_vector *  itemno2 
)

Simulates item responses (characters) for a specific value of the latent variable.

Returns simulated responses in a string, where each character of the string gives a response to one item. The first response category of an item is represented by a '0', the second response category by a '1', etc.

Because each response is represented by a single character care must be taken when some items have more than 10 response categories. For example, a response in the 11th response category would be represented by the ascii character ':', which is the 10th character greater than '0' in the ascii character sequence.

Function Parameters

Parameters:
[in] theta Value of latent variable for which item responses are generated.
[in] itemno2 List of item numbers of the items for which responses will be simulated.

Definition at line 2055 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, etirm::Item< D::latentvar_type >::NotPresentedResponse(), etirm::SwigEtirmRun::returnString, and simulate_responses().

02056   {
02057     CheckRunInit();
02058 
02059     // Vector of integers representing simulated responses
02060     int_vector *iresp = simulate_responses(theta, itemno2);
02061 
02062     // Resize string to contain item responses
02063     std::string &responseStr = gEtirmRun->returnString;
02064     responseStr.resize(iresp->size());
02065 
02066     // Convert integers to characters
02067     int_vector::iterator ii = iresp->begin();
02068     std::string::iterator ic = responseStr.begin();
02069     for (int i = iresp->size(); i--; ++ii, ++ic)
02070     {
02071       if (*ii < 0)
02072       {
02073         *ic = item_type::NotPresentedResponse();
02074       }
02075       else
02076       {
02077         *ic = *ii + '0';
02078       }
02079     }
02080 
02081     delete iresp;
02082 
02083     return responseStr.c_str();
02084   }

Here is the call graph for this function:

int_vector * etirm::simulate_responses ( double  theta,
int_vector *  itemno2 
)

Simulates item responses (integers) for a specific value of the latent variable.

Returns pointer to integer vector containing item responses, where item responses are integers from 0 to one minus the maximum number of response categories for the item.

Function Parameters

Parameters:
[in] theta Value of latent variable for which item responses are generated.
[in] itemno2 List of item numbers of the items for which responses will be simulated.

Definition at line 2008 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::base_rand_simulate, CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, ItemSubset(), etirm::SwigEtirmRun::rand_simulate, and SimulateResponses().

Referenced by simulate_response_str().

02009   {
02010     CheckRunInit();
02011 
02012     if (!gEtirmRun->base_rand_simulate)
02013     {
02014       gEtirmRun->base_rand_simulate = new random_type();
02015       gEtirmRun->rand_simulate = new boost::uniform_01<random_type>(*(gEtirmRun->base_rand_simulate));
02016     }
02017 
02018     int_vector *resp;
02019     if (itemno2)
02020     {
02021       resp = new int_vector(itemno2->size());
02022       ItemVector sitems = ItemSubset(itemno2, gEtirmRun->items, "simulate_responses");
02023       resp->newsize(sitems.size());
02024       SimulateResponses(sitems.begin(), sitems.end(), theta, *(gEtirmRun->rand_simulate),
02025           resp->begin(), true);
02026     }
02027     else
02028     {
02029       resp = new int_vector((gEtirmRun->items).size());
02030       SimulateResponses((gEtirmRun->items).begin(), (gEtirmRun->items).end(), theta, *(gEtirmRun->rand_simulate), resp->begin(), true);
02031     }
02032 
02033     return resp;
02034   }

Here is the call graph for this function:

Here is the caller graph for this function:

void etirm::simulate_seed ( unsigned long  seed  ) 

Assigns seed of random number generator used for simulating item responses.

Function Parameters

Parameters:
[in] seed Seed value, 0 <= seed <= 4,294,967,295.

Definition at line 1976 of file swig_etirm.cpp.

References etirm::SwigEtirmRun::base_rand_simulate, CheckRunInit(), gEtirmRun, and etirm::SwigEtirmRun::rand_simulate.

01977   {
01978     CheckRunInit();
01979 
01980     // convert to type used for seed in boost random number library
01981     boost::uint32_t boost_seed = seed;
01982 
01983     if (gEtirmRun->base_rand_simulate)
01984     {
01985       gEtirmRun->base_rand_simulate->seed(boost_seed);
01986     }
01987     else
01988     {
01989       gEtirmRun->base_rand_simulate = new random_type(boost_seed);
01990       gEtirmRun->rand_simulate = new boost::uniform_01<random_type>(*(gEtirmRun->base_rand_simulate));
01991     }
01992   }

Here is the call graph for this function:

template<class II, class T, class R, class RI>
void etirm::SimulateResponses ( II  item_begin,
II  item_end,
T &  theta,
R &  rand,
RI  iresp,
bool  resp_indices = false 
) [inline]

Simulate responses to a set of items for a specific latent variable value.

Template Parameters

Parameters:
II Type of iterator over items (iterator over pointers to Item objects)
T Type of latent variable.
R Type of function object for generating random numbers in the interval (0,1).
RI Type of iterator over responses.

Function Parameters

Parameters:
[in] item_begin Iterator pointing to first item.
[in] item_end Iterator pointing to one past last item.
[in] &theta Value of latent variable for which response will be generated.
[in] &rand Uniform (0,1) random number generator.
[out] iresp Iterator pointing to first response to be generated.
[in] resp_indices - If true generate integer response indices, rather than responses of type Response, The integer index for the first response category is zero, the integer index for the second response category is is one, etc. If true then the type RI must be an interator over a container of integers, otherwise RI should be an interator over a container of type Response.

Definition at line 55 of file SimulateResponses.h.

Referenced by simulate_responses().

00057   {
00058     std::vector<Real> prob;
00059     for (; item_begin != item_end; ++item_begin, ++iresp)
00060     {
00061       int ncat = (*item_begin)->NumRespCat();
00062       prob.resize(ncat);
00063       (*item_begin)->ProbRespAll(theta, prob.begin());
00064 
00065       // compute cumulative probabilities
00066       std::vector<Real>::iterator ip = prob.begin()+1;
00067       int i = ncat - 2;
00068       while (i--)
00069       {
00070         *ip += ip[-1];
00071         ++ip;
00072       }
00073       *ip = 1.0; // last cumulative probability should be 1
00074 
00075       // Generate response by finding first cumulative probability
00076       // greater than a random number
00077       Real r = rand();
00078       i = 0;
00079       ip = prob.begin();
00080       while (*ip <= r)
00081       {
00082         ++ip;
00083         ++i;
00084       }
00085 
00086       *iresp = (resp_indices) ? i : (*item_begin)->IndexResponse(i);
00087     }
00088   }

Here is the caller graph for this function:

template<class RI, class MI, class EI, class I, class II>
int etirm::StartingValues3PL ( MI  begin_min,
EI  begin_examinee,
EI  end_examinee,
II  begin_item,
II  end_item,
Response  notPresentedResponse,
bool  useAll = false,
int  baseGroup = 1,
std::set< I * > *  calc_items = 0 
) [inline]

Computes starting values for a sequence of items modeled with the three-parameter logistic model.

Nonlinear regression is employed for each item, treating the theta estimate for each person as the independent variable and the item responses as the dependent variable. Theta estimates and initial b parameters for the nonlinear regression are calculated using the PROX procedure. Theta estimates for each person are categorized using latent variable categories defined for each item (using the interface of class ItemNR).

Returns the number of times minimization procedure failed while using nonlinear regression. Nonconvergence after the maximum number of iterations has been exceeded is not considered a failure.

Template Parameters

Parameters:
RI Type of iterator over examinee responses (iterator returned by responses_begin() for an Examinee object).
MI Type of iterator over minimization routines used for each item.
EI Type of iterator over examinees (iterator over pointers to Examinee objects).
I Item type.
II Type of iterator over items (iterator over pointers to Item objects).

Function Parameters

Parameters:
[in] begin_min Iterator to pointers to minimization routines used for items. These should correspond to the items given by begin_item and end_item that are in the set calc_items.
[in] begin_examinee Iterator to pointer to the first examinee.
[in] end_examinee Iterator to pointer to one past the last examinee.
[in,out] begin_item Iterator to pointer to the first item.
[in,out] end_item Iterator to pointer to one past the last item. All these items are used in computing PROX estimates of examinee abilities. Starting values are computed for any of these items that are also in the set calc_items. On output the item parameter estimates for each item also present in calc_items are set to the starting values calculated in this function.
[in] notPresentedResponse Response which indicates an item was not presented to an examinee. Assumed to be the same for all items.
[in] useAll If true calculate PROX estimates for all examinees and items, even examinees who get all items right or all items wrong, and even for items answered all correctly or all incorrectly.
[in] baseGroup Number of group to use as base group where mean and s.d. of latent variable distribution are zero and one.
[in] calc_items Set containing items for which starting values are computed. All items given by begin_item and end_item are used to compute PROX estimates of examinee ability, but starting values are only calculated for items in calc_items. If calc_items is null then starting values are computed for all items given by begin_item and end_item.

Definition at line 467 of file Start3PL.h.

References invalidLogit.

00471   {
00472 
00473     int numExaminees = end_examinee - begin_examinee;
00474     int numItems = end_item - begin_item;
00475 
00476     RealVector thetas(numExaminees, invalidLogit);
00477     RealVector itemDiff(numItems, invalidLogit);
00478 
00479     typedef std::vector<Response> cvector;
00480 
00481     /* Compute PROX estimates of examinee ability and item difficulty */
00482     PROX<EI, RI, II>(numItems, useAll, begin_examinee, end_examinee, begin_item,
00483         notPresentedResponse, itemDiff, thetas);
00484 
00485     /* Compute mean of PROX estimates of examinee ability in base group and assign case weights */
00486     int i;
00487     RealVector nVec(numExaminees); // store case weights to use in regression
00488     RealVector::iterator in = nVec.begin();
00489     RealVector::iterator itheta = thetas.begin();
00490     Real mean = 0.0;
00491     Real nwt = 0.0;
00492     EI ie = begin_examinee;
00493     for (i = numExaminees; i--; ++in, ++itheta, ++ie)
00494     {
00495       *in = (*ie)->Count();
00496       if ((*ie)->Group() == baseGroup && *itheta != invalidLogit)
00497       {
00498         mean += *itheta * *in;
00499         nwt += *in;
00500       }
00501     }
00502     if (nwt == 0)
00503       throw RuntimeError("No examinees with valid item responses in base group",
00504           "StartingValues3PL");
00505 
00506     mean /= nwt;
00507 
00508     /* Compute standard deviation of PROX estimates of examinee ability in base group */
00509     Real sd = 0.0;
00510     itheta = thetas.begin();
00511     in = nVec.begin();
00512     ie = begin_examinee;
00513     for (i = numExaminees; i--; ++in, ++itheta, ++ie)
00514     {
00515       if ((*ie)->Group() == baseGroup && *itheta != invalidLogit)
00516       {
00517         Real diff = *itheta - mean;
00518         sd += diff * diff * *in;
00519       }
00520     }
00521     sd /= nwt;
00522     sd = std::sqrt(sd);
00523 
00524     /* Put thetas on latent variable scale so mean and s.d. of thetas for examinees in base group are 0 and 1 */
00525     itheta = thetas.begin();
00526     for (i=numExaminees; i--; ++itheta)
00527     {
00528       if (*itheta != invalidLogit)
00529       {
00530         *itheta -= mean;
00531         *itheta /= sd;
00532       }
00533     }
00534 
00535     /* Put b parameters on latent variable scale so mean and s.d. of thetas for examinees in base group are 0 and 1 */
00536     RealVector::iterator idiff = itemDiff.begin();
00537     for (i = numItems; i--; ++idiff)
00538     {
00539       if (*idiff != invalidLogit)
00540       {
00541         *idiff -= mean;
00542         *idiff /= sd;
00543       }
00544     }
00545 
00546     RealVector itemTheta(numExaminees); // vector of thetas for examinees who reponded to an item
00547     RealVector rVec(numExaminees); // count of number of correct answers for each theta value 
00548     // (r vector in M-step computation)
00549     // nVec holds count for each theta value (n vector in M-step computation)
00550 
00551     /* Compute starting values for each item */
00552     int minError = 0; // Count of number of time minimization failed in computing regression
00553     for (int item = 0; item < numItems; ++item, ++begin_item)
00554     {
00555       if (calc_items)
00556       {
00557         if (calc_items->find(*begin_item) == calc_items->end())
00558           continue;
00559       }
00560 
00561       /* Create vectors of item responses and thetas for item */
00562       EI ie = begin_examinee;
00563       RealVector::iterator it = itemTheta.begin();
00564       in = nVec.begin();
00565       RealVector::iterator ir = rVec.begin();
00566       RealVector::iterator alltheta = thetas.begin();
00567       int n = 0; // number of examinees who respond to the item
00568       nwt = 0.0; // weighted number of examinees who respond to the item
00569       Real pvalue = 0.0;
00570       Response correct = (*begin_item)->CorrectResponse();
00571       while (ie != end_examinee)
00572       {
00573         RI iresp = (*ie)->responses_begin() + (*begin_item)->Index();
00574         if (*iresp != notPresentedResponse && *alltheta != invalidLogit)
00575         {
00576           *it = *alltheta;
00577           *in = (*ie)->Count();
00578           nwt += *in;
00579           if (*iresp == correct)
00580           {
00581             pvalue += *in;
00582             *ir = *in;
00583           }
00584           else
00585           {
00586             *ir = 0.0;
00587           }
00588           ++n;
00589           ++it;
00590           ++in;
00591           ++ir;
00592         }
00593         ++alltheta;
00594 
00595         ++ie;
00596       }
00597       pvalue /= nwt;
00598 
00599       /* Compute starting values for item */
00600       int numParameters = (*begin_item)->NumParameters();
00601       RealVector start(numParameters);
00602       Real startb = itemDiff[item]; // use b from PROX as starting value
00603 
00604       if (numParameters > 1)
00605       {
00606         // PROX estimate assumes D=1.0, so if D for item is different from
00607         // 1.0 adjust the a-parameter.
00608         start(1) = 1.0 / (*begin_item)->NormalizingConstant();
00609         start(2) = startb;
00610       }
00611       else
00612       {
00613         start(1) = startb;
00614       }
00615 
00616       /* Make starting c parameter slightly larger than zero since prior density of c
00617        is zero when c is equal to zero */
00618       if (numParameters > 2)
00619         start(3) = 0.05;
00620 
00621       if (pvalue == 1.0 || pvalue == 0.0)
00622       {
00623         if (!useAll)
00624         {
00625           /* If all responses to an item are correct or incorrect and useAll is false then PROX
00626            estimate of b will not exist, so use logit of number correct score 1/2 different from zero
00627            or perfect as b starting value. */
00628           Real maxlogit = std::log((numExaminees - 0.5) / 0.5);
00629           startb = (pvalue == 1.0) ? maxlogit : 1.0/maxlogit;
00630           if (numParameters > 1)
00631             start(2) = startb;
00632           else
00633             start(1) = startb;
00634         }
00635         (*begin_item)->NonZeroPriors(start);
00636         (*begin_item)->SetParameters(start);
00637       }
00638       else
00639       {
00640         /* Use nonlinear regression to find starting values */
00641 
00642         /* Assign expected counts n and r for item */
00643         AssignItemNR<I>(n, itemTheta.begin(), nVec.begin(), rVec.begin(), *begin_item);
00644 
00645         (*begin_min)->SetFunction(*begin_item);
00646 
00647         RealVector xpls(numParameters), gpls(numParameters);
00648         double fpls;
00649 
00650         /* Modify starting values which for which prior density is zero */
00651         (*begin_item)->NonZeroPriors(start);
00652 
00653         int result = (*begin_min)->Minimize(start, xpls, fpls, gpls);
00654 
00655         // assign values computed if minimization succeeded 
00656         // or failed because of the maximum number of iterations
00657         // being exceeded without convergence
00658         if (!result || (*begin_min)->GetMessage() == 4)
00659         {
00660           (*begin_item)->SetParameters(xpls);
00661         }
00662         else // if minimization failed use initial starting value for b
00663         {
00664           start(1) = 1.0;
00665           start(3) = 0.1;
00666           (*begin_item)->SetParameters(start);
00667           minError++;
00668         }
00669       }
00670       ++begin_min; // only increment for items for which starting values are computed
00671     }
00672     return minError;
00673   }

double_vector * etirm::test_characteristic_curve ( double_vector *  thetas,
int_vector *  ilist2 
)

Returns a vector of values of the test characteristic curve, given a vector of theta values and a selection of items.

It is assumed for each item that the lowest response category corresponds to a score of 0, the second response category corresponds to a score of 1, etc.

Function Parameters

Parameters:
[in] *thetas Pointer to vector of theta values.
[in] *ilist2 Pointer to vector of item sequence numbers (1-based).

Definition at line 993 of file swig_etirm.cpp.

References CheckRunInit(), gEtirmRun, etirm::SwigEtirmRun::items, and ItemSubset().

00994   {
00995     CheckRunInit();
00996 
00997     double_vector tcc(thetas->size(), 0.0);
00998 
00999     // Vector to hold response probabilities for an item.
01000     double_vector probs;
01001 
01002     ItemVector *sitems;
01003     if (ilist2)
01004     {
01005       sitems = new ItemVector(ItemSubset(ilist2, gEtirmRun->items, "test_characteristic_curve"));
01006     }
01007     else
01008     {
01009       sitems = &(gEtirmRun->items);
01010     }
01011 
01012     // loop over items
01013     ItemVector::iterator ii = sitems->begin();
01014     for (int i = sitems->size(); i--; ++ii)
01015     {
01016       int ncat = (*ii)->NumRespCat();
01017       probs.newsize(ncat);
01018 
01019       double_vector::iterator icc = tcc.begin();
01020       double_vector::iterator it = thetas->begin();
01021       for (int j = tcc.size(); j--; ++icc, ++it) // loop over thetas
01022       {
01023         (*ii)->ProbRespAll(*it, probs.begin());
01024 
01025         // first response category corresponds to 0, second response category
01026         // corresponds to 1, etc.
01027         double dresp = 1.0; // Start with response 1, 0 is skipped
01028         double sum = 0.0;
01029         double_vector::iterator ip = probs.begin()+1;
01030         for (int k = ncat-1; k--; ++ip, ++dresp)
01031         {
01032           sum += dresp * *ip;
01033         }
01034 
01035         // Add expected score for item to TCC
01036         *icc += sum;
01037       }
01038     }
01039 
01040     if (ilist2)
01041       delete sitems;
01042 
01043     return new double_vector(tcc);
01044   }

Here is the call graph for this function:


Variable Documentation

SwigEtirmRun* etirm::gEtirmRun = 0

Global variable holding information about a run.

Definition at line 108 of file swig_etirm.cpp.

Referenced by add_examinee(), bootstrap_sample(), bootstrap_seed(), etirm::SwigEtirmRun::CheckExamineeNumber(), etirm::SwigEtirmRun::CheckExaminees(), etirm::SwigEtirmRun::CheckGroup(), etirm::SwigEtirmRun::CheckItemNumber(), CheckItemParam(), etirm::estep::compute(), dist_get_point(), dist_get_points(), dist_get_prob(), dist_get_probs(), dist_mean_sd(), dist_scale(), dist_set_point(), dist_set_points(), dist_set_prob(), dist_set_probs(), dist_transform(), dist_unique_points(), etirm::estep::estep(), examinee_get_count(), examinee_get_group(), examinee_get_posterior(), examinee_posterior_mean(), examinee_response_str(), examinee_responses(), examinee_set_count(), examinee_set_group(), examinee_set_posterior(), examinee_theta_MLE(), examinees_count(), get_responses(), get_responses_missing(), item_cat_counts(), item_get_all_params(), item_get_model(), item_get_param(), item_get_params(), item_get_prior_param(), item_get_prior_type(), item_num_params(), item_num_resp_cat(), item_prob_resp(), item_resp_count(), item_scale_params(), item_set_all_params(), item_set_param(), item_set_params(), item_set_prior(), mstep_dist(), mstep_items(), mstep_max_diff(), mstep_max_iter(), mstep_message(), num_examinees(), num_groups(), num_items(), num_latent_dist_points(), set_missing_resp(), simulate_response_str(), simulate_responses(), simulate_seed(), and test_characteristic_curve().

const Real etirm::invalidLogit = 10000.0

value to indicate invalid logit (e.g., logit(1))

Definition at line 41 of file Start3PL.h.

Referenced by ItemMoments(), PersonMoments(), PROX(), and StartingValues3PL().

const double etirm::logZero = -1021.0

Value used to represent the log of zero probabilities.

Definition at line 56 of file EStepDiscrete.h.

Referenced by etirm::EStepDiscrete< E, I, II, D >::DoEStep(), etirm::EStepDiscrete< E, I, II, D >::EStepDiscrete(), and etirm::EStepDiscrete< E, I, II, D >::ExamineePosterior().


Generated on Sat Mar 1 21:41:10 2008 for ETIRM by  doxygen 1.5.4