Saturday, 24 August 2013

how to shape the dataframe for mlogit in R

how to shape the dataframe for mlogit in R

I have a question concerning mlogit function.
In my experimental design I collect 80 trials for each participant . The
subjects are asked to provide an answer by choosing among 4 different
alternatives (not ordered). Now, I would like to model the choices of my
participants as a function of nine continuous predictors, however I can't
understand how the data frame must be re-shaped in order to be used with
mlogit.
Does anybody know what would be the proper way to arrange the dataset?
Here is an extract of the dataset:
# Subject Trial Choice X1 X2 X3 X4 X5 X6 X7
X8 X9
Subj1 1 2 0.00 0.62 0.04 -0.84 0.12 -0.06
0.58 -0.05 0.04
Subj1 2 2 0.00 0.62 0.04 -0.84 0.12 -0.06
0.58 -0.05 0.04
Subj1 3 4 0.02 -0.01 0.02 -0.23 0.01 0.30
0.12 -0.01 0.01
Subj1 4 3 0.01 -0.02 0.03 -0.24 0.03 0.37
0.12 -0.02 0.03
Subj1 5 3 0.01 -0.02 0.03 -0.24 0.03 0.37
0.12 -0.02 0.03
… … … … … … … … … …
… …
Subj1 80 3 0.01 -0.02 0.03 -0.24 0.03 0.37
0.12 -0.02 0.03
Subj2 1 3 0.01 -0.04 0.03 -0.22 0.03 0.33
0.10 -0.02 0.03
Subj2 2 2 0.02 0.01 0.02 -0.12 0.01 0.26
0.07 -0.01 0.01
Subj2 3 1 0.03 -0.01 0.02 -0.12 0.02 0.23
0.07 -0.02 0.02
Subj2 4 2 -0.02 0.00 0.00 -0.19 -0.01 0.35
0.06 -0.04 0.01
Subj2 5 2 0.01 -0.01 -0.01 -0.10 0.00 0.27
0.05 -0.01 0.00
… … … … … … … … … …
… …
Subj2 80 2 0.01 -0.01 -0.01 -0.10 0.00 0.27
0.05 -0.01 0.00
Subj3 1 4 0.02 0.31 0.01 -0.20 0.01 0.04
0.12 -0.01 0.01
… … … … … … … … … …
… …

No comments:

Post a Comment