[R] panel multinomial logit
Rose
hh132 at le.ac.uk
Wed Sep 4 13:55:27 CEST 2013
Hi there,
I am trying to apply multinomial Logit for a panel data set. I have 5016
observations for 22 countries (id). Each country has 228 observations over
time domain.
Following table shows the part of my dataset including 10 variables.
id t X1 X2 X3 X4 X5 X6 X7 X8
X9 X10
500 3 44 NA NA NA NA NA 150.9211 NA NA NA
0.005684
501 3 45 NA NA NA NA NA 153.6307 0.409641 NA NA
0.006196
502 3 46 NA NA NA NA NA 156.1034 0.422223 NA NA
0.006666
503 3 47 NA NA NA NA NA 157.7336 0.541157 NA NA
0.007110
504 3 48 NA NA NA NA NA 163.7610 0.717920 NA NA
0.007533
505 3 49 NA NA NA NA NA 151.5358 0.727861 NA NA
0.007580
506 3 50 NA NA NA NA NA 151.9387 0.842376 NA NA
0.008198
I have generated a dependent variable with 3 states which are 0, 1, 2.
id t y
500 3 44 1
501 3 45 2
502 3 46 0
503 3 47 0
504 3 48 0
505 3 49 0
506 3 50 1
In order to reshape data from wide to long format I used the command below;
mdat <- mlogit.data (dat, id="id", choice="y", shape = "long", alt.levels =
c("0", "1","2"))
> mdat[500:510,]
id t X1 X2 X3 X4 X5 X6 X7
X8 X9
167.1 3 44 NA NA NA NA NA 150.9211 NA NA NA
167.2 3 45 NA NA NA NA NA 153.6307 0.409641 NA NA
168.0 3 46 NA NA NA NA NA 156.1034 0.422223 NA NA
168.1 3 47 NA NA NA NA NA 157.7336 0.541157 NA NA
168.2 3 48 NA NA NA NA NA 163.7610 0.717920 NA NA
169.0 3 49 NA NA NA NA NA 151.5358 0.727861 NA NA
169.1 3 50 NA NA NA NA NA 151.9387 0.842376 NA NA
X10 y
167.1 0.005684 TRUE
167.2 0.006196 TRUE
168.0 0.006666 FALSE
168.1 0.007110 FALSE
168.2 0.007533 FALSE
169.0 0.007580 FALSE
169.1 0.008198 TRUE
This code has not given /chid/ or /alt/ columns in the result. These two
columns usually appear when you run the command for reshape the data format.
The problem in here is when I check y it shows True and False. I think it
ignores the other state that I defined for y it just shows 2 states! I am
confused. I don’t know whether the code which I have used for reshaping is
correct?
The main struggle is when I run the mlogit command. I have tried two
commands:
First;
> mlogit.model <- mlogit(y~ X1 + X2 +X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10,
> data = mdat, reflevel = "0")
I got following error;
Error in if (abs(x - oldx) < ftol) { :
missing value where TRUE/FALSE needed
Second;
mlogit.model <- mlogit(y~ X1 + X2 +X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10,
data = mdat, reflevel = "0", R=50, halton=NA, print.level=0, panel=TRUE)
Error in mlogit(y ~ X1 + X2 +X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10 + :
panel is only relevant for mixed logit models.
Now, I would like to know if the mlogit.dat is correct or not? Secondly, how
could I make correct the mlogit command.
Any help would be appreciated in advance.
Best,
Rose
--
View this message in context: http://r.789695.n4.nabble.com/panel-multinomial-logit-tp4675348.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list