* From Stata Press website * A Hybrid Unordered Multinomial logit problem with BOTH alternative-specific * and case specific explanatory variables. The choice variable is the car * type chosen = American, Japenese, or European =(car). The case-specific * explanatory variables are income in thousands of dollars (income), sex = * male (=1) or female (=0). The number of dealerships of each nationality * in the consumer's city (dealer) is the alternative-specific explanatory * variable. We do not consider the size of the car purchased in this analysis. * The variable "choice" is equal to one when the automobile's nationality is * chosen and zero otherwise. * Note: The data is already in "long" form as rquired of asclogit * models where there are both alternative specific variables (dealer) * and case-specific variables (sex and income). use http://www.stata-press.com/data/r14/choice.dta, clear gen index = _n gen time = mod(index,3) replace time = 3 if (time == 0) drop index asclogit choice dealer, case(id) alternative(car) casevars(sex income) test sex test income asclogit choice dealer, case(id) alternative(car) casevars(sex income) or predict p reshape wide car p choice dealer, i(id) j(time) list id choice1 choice2 choice3 p1 p2 p3 in 1/9, separator(3) gen actual = . replace actual = 1 if (choice1 == 1) replace actual = 2 if (choice2 == 1) replace actual = 3 if (choice3 == 1) summarize p1 p2 p3 summarize choice1 choice2 choice3 * Create Classification Table and get accuracy rate egen pred_max = rowmax(p1 p2 p3) generate pred_choice = . forv i=1/3 { replace pred_choice = `i' if (pred_max == p`i') } local choice_label: value label actual label values pred_choice `actual_label' tabulate pred_choice actual * This conditional logit model did not pick any zeroes * hence the 3x4 reported classification table * Accuracy rate = 195/295 = 0.65. This classifer only choose American cars! * In comparison, the accuracy rate that one would expect from naively classifying * using the majority class (choice = 1 = American) would be 65.0% accuracy on average. * See the previous summarize statement for choices. Thus, the current asclogit * classifier is providing a LIFT of 65/65 = 1.0. It provides no lift at all! * On the other hand, we have a better understanding now of the role of * income, aex, and number of local dealers in determining the choice of * automobiles by consumers. We can try to improve the accuracy rate by * simplifying the above model and have only one or two variables like dealer * and income. We will try that in Automobile_Choice2.do and Automobile_Choice3.do.