How to Use TAXFIT and CPTFIT
by Michael H. Birnbaum, Copyright 1998, all rights reserved.
TAXFIT and CPTFIT are FORTRAN programs that can be used to fit a choice experiment in which each subject chooses between gambles with up to four positive outcomes in each gamble.  The data consist of choices and (optionally) strengths of preference.  The data are coded as follows:

	D(R,L) = Data value for gambles R (Right) and L (Left)
	D(R, L) < 0 indicates that judge prefers L over R
	D(R, L) > 0 indicates that judge prefers R over L
	D(R, L) = 0 indicates that there is no preference

D(R, L) may be include a judgment of how much the judge would pay to receive gamble R rather than L.  Or use D(R, L) = 1 or –1 for forced choice data.

The program fits a compromise loss function in which the parameters will be estimated to fit the choices and strengths of preference with the same parameters.  A special case is to require the model to only fit choices, ignoring judgments of strength of preference.

TAXFIT will fit a configural weight model in which weight is transferred among outcomes of the gamble.  The program can handle a special case in which the weight transfers are a constant proportion of the weight of the stimulus that is losing weight.  CPTFIT will fit the CPT model using a two-parameter W(P) function.

CPT Model:

								(C1)

							(C2)

										(C3)

							(C4)

								(C5)
where P(R, L) is the probability of choosing R over L;  is the logistic function; a, b, c, g, and b are parameters; Gamble G consists of n outcomes ranked x1 > x2 > ...xn; Pi is the decumulative probability that xi ≥ x given gamble G, which may be R or L.

TAX Model

								(T1)

							(T2)

										(T3)

				(T4)

			 if d ≤ 0				(T5a)

			 if d > 0				(T5b)

										(T6)

Note that Equations T1, T2, and T3 are the same as C1, C2, and C3.  This model also uses the logistic for F(x), and it also has 5 parameters: a, b, d, g and b.  The parameter d in the TAX model is analogous to the parameter c in the CPT model.  The configural weight, d, will be greater than or less than 0 as c is greater than or less than 1, respectively.

Index of Fit
			
where B is the index of Badness of Fit, SS is the sum of squared discrepancies between the data and the model, and L is the negative log likelihood of the observed choices given the model.  The compromise loss function has weights of h and 1 – h.  SS is defined as follows:
			
where  is the observed judgment of strength of preference for choice k, and  is the predicted strength of preference from Equations C1 or T1.  Note that if you use forced choice, without strength of preference, or if you want to ignore the strength of preference judgments, you should fix the value of a  (a = 1 is a convenient value) and set h to zero.  The negative log likelihood, L, is defined as follows:
			
where  is the predicted probability of the observed choice, Ck, which is either P(R, L) or 1 – P(R, L), if the judge chose R or L on choice k, respectively.
	To fit the judgments of strength of preference to a least-squares criterion only (the program will try fit the D(R,L), which includes both the sign and strength of preference), fix b (b = 1 is convenient), and set h to 1.
	People with different philosophical notions may prefer to use h =1 or h = 0.  Those who will prefer h = 1 will be those who want to predict the judgments of strength of preference, which will include the sign as well as the magnitude.  Such a person might argue that preference probabilities are not measures of difference in utility (i.e., the person disagrees with Equation C2 and T2), but they are confounded with measures of discriminability.  Thus, Rome plus $.01 is always judged better than Rome (i.e., choice probability is 1), but the difference in utility is minuscule.  
	On the other hand, those who will prefer h = 0 will believe that only the choices should count, and (as all Economists know), there is no such thing as psychophysics.  Thus, people are able to state what they prefer, but they are NOT able to say that the difference between trip to Rome and a trip to Rome plus $.01 is a smaller preference than their preference for a sure $1000 over a 50-50 gamble to win $25 or nothing (this is an oversimplification of philosophy, but the sort of oversimplification that you will read in blind reviews).  In other words, these people disagree with Equations C1 and T1.
	Another consideration is that for gambles with outcomes in the range, 0 < x < $150, the average error predicting a strength of preference might be $12, so the index of sum of squared errors for 100 such choices might be SS = 14,400.  If the model can predict the subject's choice 80% of the time (i.e., suppose the model predicts .8, and in 100 trials 80 are correct and 20 in error), then the index of fit would be L = 50.  In other words, to give "equal" weight to these criteria in this situation, one might set h = .0035.  However, if the outcomes are in the range of $10000, instead of $100, then SS might increase from 14,400 to 1440,000, so h should be adjusted to take this into account.
	In practice, I have observed that the programs tend to converge faster and work better with intermediate values of h.  This observation is consistent with the notion that the same parameters are underlying both aspects the data.  Also: I have observed that intermediate values of h occasionally lead to a better minimum for L, which suggests that the information from strength of preference "helps" the solution avoid local minima.  This is also consistent with the theory that the strength of preference information is useful to the program.  From experience with the programs, for gambles with positive outcomes under $100, I suggest you start in the neighborhood of h = .01 to .001.  After getting these solutions, you can use this compromise solution to provide starting values, and let the program work with h = 1 or h = 0, depending on your philosophy.

Files Needed

In order to use TAXFIT and CPTFIT, you need three files (in addition to the programs).

1. SUBJECTS.DAT   The first file is a text-only file called SUBJECTS.DAT.  This file contains the raw data for each subject.  All of the data for Subject 1 must precede all of the data for Subject 2, etc.  The responses for the m choices must be entered in the same order, in a fixed format.

2. TAXFIT.DAT  This text-only file contains the specifications to make TAXFIT work.  (The file will be VIRTUALLY IDENTICAL to CPTFIT.DAT, except for one or two numbers.  Thus, I advise you to make TAXFIT.DAT  first, proof it, then copy it and edit the one number, saving the copy as CPTFIT.DAT.  It may seem like a waste of disk drive space, but from experience, I can tell you that your time is more valuable than another 50K of space on the disk, and you will likely trick yourself if you don't keep these in separate files.)
The first 14 lines look like this:

 29  1 .999                         No. cells, Model ID,WWLIK BSFIT.DAT
110 gm  beta  a    b   delta        No. OF SUBJECTS
 0.70 1.00 0.50  .10 -0.8           initial estimates (gamma, beta, a, b, delta)
    0    1    0    0    0           masks (0=free;1=fixed)
 .050 .050 .001 .001-1.66           xmin
9.000 9999 9999 9999 1.66           xmax (xmin=xmax=0 for unconstrained)
(F7.2)
(///2(12F4.0/)/,5F4.0/40X,2X,I3)
(2(10F7.2/),9F7.2,2X,I3)
  3  3                            First Choice No. left, No. on right
  .60  .20  .20  .60  .20  .20      Probabilities (Left, Right)
    3   48   52    3   10   98      Outcomes (lowest to left)
  -1.86 60.9                        Mean judgment, Percent choosing left
  2  2                            Second Choice
  .60  .40  .80  .20
   10   52   10   98
   -.44 53.6
  3  3                            Third Choice
  .60  .20  .20  .60  .20  .20
    2   45   49    2   11   97
   -.81 60.0
  2  2                            Fourth Choice
  .60  .40  .80  .20
   11   49   11   97
   1.55 43.6                      etc. etc.

Line 1. The comments to the right are not read by the computer.  The first number (29, in this example) is the number of choices that the subjects made, to be fit by the models.  The second number is the model ID, which should be set to 1 (it is not active in these versions of the program). The third number is 1 – h.  In this example, it is set to .999, so h is .001.  The format for the first line is 2I3,F5.0.  That means the first two numbers are integers, right-justified in 3 columns each, and the third number is real, and you will have to enter the decimal.

Line 2. The second line shows the number of subjects, in I3 format (i.e., 3 columns, right justified).  The other comments are not read by the computer and are placed there to remind the user what goes on the next line.

Line 3. These are initial estimates of the parameters for the configural weight, TAX model.  Format is 5 columns, and you should enter the decimal.  Parameters are g, b, a, b, and d, in that order.  The values here are reasonable based on previous research (Note: a and b are reversed in Birnbaum and Chavez (1997), and delta is called omega in that paper).

Line 4 . This line has variables called "Masks."  These are set to zero, the corresponding parameter is free.  When Mask is set to 1, then the variable is fixed to its initial value.  In this example, the parameter beta is fixed to 1.00 by the Mask that is right-justified in the second field of 5 columns.  In this example, the other Masks are zero, so there are 4 active parameters to be estimated from the data.

Line 5. The next line has variables called XMIN, which are the minimal values you want to allow the program to use.  This line constrains the solutions to be in reasonable bounds for this theory.  You will want to restrict the first four parameters to be positive and also keep them from going off the board.  The parameter delta should be allowed to go negative (and it will).  You may want to place bounds on delta to prevent negative weights.  The example setup will prevent negative weights with n = 3 outcome gambles.

Line 6. This line has XMAX for the parameters, which are the maximal values allowed.  Place reasonable bounds. Setting bounds too narrow may prevent the solution from reaching a global minimum near a boundary.  In your first fits, you can relax these bounds, then use solutions to set better initial values.

Lines, 7, 8, and 9 are FORTRAN formats.  These must appear in parentheses, and they will be composed of the following elements: 
	nFw.d = there are n fields of real numbers of width w columns each, right-justified and a decimal shall be placed d columns in from the right.  If a decimal is actually placed in the field, it will override this format. 
	X is skip a space, mX = skip m columns.
	/ means go to the next line.  No / is needed for the last line, and if one is placed there,
		the program will skip the next line.
	() can be used to repeat an expression.

Line 7 is the format for reading the mean judgments, which will be placed in the file as shown below.  In this case, it is in the first 7 columns on its own line.

Line 8 is the format for reading the raw data from the data file.

(///2(12F4.0/)/,5F4.0/40X,2X,I3) means the following:
	3 lines are skipped
	2 lines are read with 12 numbers on a line, each one 4 columns wide.
	1 line is skipped
	next line has 5 numbers, each four columns wide,
		42 columns are skipped, then an integer number is read in 3 cols.
		(the integer number is the subject's id number, which must be
		read from the last line of the subject's data or after,
		on its own line, as in this example)

Line 9 is the format for putting the predictions and residuals into new files that will be created by the program.  These files will be named, TAXFIT.PRE, TAXFIT.RES, CPTFIT.PRE, and CPTFIT.RES, where PRE indicates predictions, and RES indicates Residuals (Data minus Predictions).

(2(10F7.2/),9F7.2,2X,I3)
	In this example, there are 29 cells, so this format specifies:

	2 lines have 10 numbers, each 7 columns wide, with 2 decimal places.
	the next line has 9 numbers, each 7 columns wide, with 2 decimal, and
		then 2 spaces, followed by a 3-digit integer, which is the 
		subject number.  
Lines 10-13 show one choice (the first choice), which will be repeated in format for later gambles. Line 10 is the first line of the first choice.

  3  3                            First Choice No. left, No. on right
  .60  .20  .20  .60  .20  .20      Probabilities (Left, Right)
    3   48   52    3   10   98      Outcomes (lowest to left)
  -1.86 60.9                        Mean judgment, Percent choosing left
  2  2                            Second Choice

The first line of each choice shows the number of outcomes on the left, and the number of outcomes on the right. Format is in 3 columns, right-justified.   
  3  3 
Represents a comparison between two 3-outcome gambles.
  3  2 for choice btn gamble with 3 outcomes (left) and 2 outcomes (right) 

The second line of each choice shows the probabilities of the outcomes.

The third line of each choice shows the values of the outcomes.  Lower items absolutely MUST be to the left of higher-valued items.  If not, the program may give wrong results without any warning. Also, the probabilities must be in the same order as their corresponding outcomes.
Also: check the probabilities and outcomes very very carefully.

The fourth line of each choice shows the mean judgment (7 columns) and percentage who chose the gamble on the left (5 columns). 

The example shows a comparison of two three-outcome gambles. 
	The gamble on the LEFT has .6 probability to win $3, .20 probability to win $48, .20 probability to win $52.  
	The gamble on the RIGHT has a .6 probability to win $3, .2 to win $10, and .2 to win $98.
	The mean judgment is $1.86 indicating that on the average, judges offered to pay $1.86 to receive the gamble on the LEFT, rather than the gamble on the RIGHT.  60.1% of subjects chose the gamble on the left.

3. CPTFIT.DAT
	This file is exactly the same as TAXFIT.DAT, except for the first few lines.  Here are the first 5 lines of CPTFIT.DAT for this example:

 29  1 .999                          No. cells, Model ID,WWLIK BSFIT.DAT
110 gm beta   a    b   c             NO. OF SUBS
 0.61 0.88 0.50  .10 .724            initial estimates (gamma, beta, a, b, c)
    0    0    0    0    0            masks (0=free;1=fxd)
 .050 .050 .001 .001 .001            xmin
9.000 9999 9999 9999 9999            xmax (xmin=xmax=0=>unconstd)
(F7.2)
(///2(12F4.0/)/,5F4.0/40X,2X,I3)
(2(10F7.2/),9F7.2,2X,I3)

The first two lines are the same.  The third line will use different starting values.  Tversky and Kahneman (1992) estimated gamma = .61, beta = .88.  An estimate of c that is consistent with their data is c = .724.  Note that all parameters are free in this run (all MASKS are 0).  Note that minima and maxima are different.  The parameter c is constrained to be positive and in the interval between .001 and 99.9.  The parameter, c,  is the biggest difference from TAXFIT.

Output

TAXFIT and CPTFIT will create 4 output files each:

TAXFIT.OUT and CPTFIT.OUT contain the printouts from STEPIT to trace the minimization process.  They also contain summaries of indices of fit.  The most important output is at the end of the file.  This contains the fit to the means (medians, or % left can also be selected as the average for the data).  This printout also prints out the gambles in order, and shows the mean judgment, the predicted value, and the residual for each choice problem.  When you run these programs, check this printout carefully, to make sure that you and the program are communicating properly.  This file contains a final word, "Normal End" which shows that the program finished without error.

TAXFIT.PAR and CPTFIT.PAR contain the parameters estimated for each subject, in the order of the subjects in the file.  The last "subject" is the means.  In addition to the parameters, the indices of fit for each subject are printed, and the weights of four equally likely outcomes are printed on the second line for each subject.  These files can be imported into a statistics package, such as SPSS, to do analyses on the parameters and fits.  For example, one can compute the difference in fit between the models for each subject.

TAXFIT.PRE and CPTFIT.PRE are the predictions for each subject.  One could compute the means of the predictions, and ask if these resemble the means of the judgments. 

TAXFIT.RES and CPTFIT.RES are the residuals for each subject.  Data - Predictions.
One could perform ANOVA to ask if there are systematic deviations in the residuals.

Modify the Programs

If you program in FORTRAN, it should be easy to modify these programs to implement other utility functions, weighting functions, or different models.  If you make a useful modification, please send me a note and a copy of the file.  If you find a bug or error in the programs, let me know.  They were written initially to be used in our lab, and they were not prepared originally to be user-proof.

Have fun!

References: These papers have used variants of these programs.

Birnbaum, M. H., & Chavez, A. (1997). Tests of Theories of Decision Making: Violations of Branch Independence and Distribution Independence. Organizational Behavior and Human Decision Processes, 71(2), 161-194.
Birnbaum, M. H., & Navarrete, J. (submitted). Testing rank- and sign-dependent utility theories: Violations of stochastic dominance and cumulative independence. Submitted for publication, 00, 000-000.
Birnbaum, M. H., Patton, J. N., & Lott, M. K. (submitted). Evidence against Rank-Dependent Utility Theories: Violations of Cumulative Independence, Interval Independence, Stochastic Dominance, and Transitivity. Submitted for publication, 00, 000-000.