Please enable JavaScript.
Coggle requires JavaScript to display documents.
TAE Week4 - Coggle Diagram
TAE Week4
R
-
-
create data frame with choice, shape, alt.var parameters
create mlogit model (to remove the constant use -1, use the dataframe you created earlier)
goodness of fit - compute AIC by hand (-2 loglikehood) + 2 parameters (predictor variables + constant if there is)
use the predict function to see the probabilites of the 5 choices, then pick the one with the highest probability, then compare that with the actual (test result) if they match
-
when you do shape = wide, you need to be careful when you are fitting the model, to use the column names of the prepared dataframe
predicted share = doing a confusion matrix (where the diagonals are the actual correct predictions) of the actual choices vs the predicted choices... and then taking the correct predictions / sum of all the observations in the matrix ... each number in the matrix represents the number of observations allotted to each row/column
willingness to pay = -coefficient1/coefficient 2- represents how much one unit of increase in one attribute will affect the other attribute
the formula by default has a negative sign
mixed logit
use when there is this independence of irrelevant alternatives like the bus example (which takes all alternatives are equally probable)
alternative specific constants: what else can we specify to our model function such that the model uses K-1 alternatives where the Kth alternative would become a reference level. specify reflevel in our mlogit function
-
-
make predictions after you used mlogit, compare predictions to actual results
when you split your data into train and test sets, you need to remember to apply dfidx on each of them
might need to create a new column in dataframe if the idx is not there - so idx should be unique, sometimes if its not unique, you gotta create it, by including a new column that has the count of evverything, or you could merge into a list the id and the num of trials
compare with multinomial logit by computing model$loglik and AIC (-2 loglik + 2 num of parameters) and can also compare prediction accuracy
Homework
if you want to fit the intercept term only, just use 1
-
-
-
-
define a new variable (1,0) use as.integer or define something as the multiple of two existing columns
-
-