[R] length of variable in mlogit

Lee van Cleef l.van.cleef at gmx.net
Fri Aug 3 18:49:24 CEST 2012


Hi Michael,

many thanks for your comment. 

Below the original data as imported from Stata format. I deleted some
columns with explaining variables because they were unnecessary and working;
the model has several explaining variables with generic regression
coefficients. 

pid	Choice	V7.Ch 1	V7.Ch 2	V7.Ch 3	V7.Ch 4	V7.Ch 5	V7.Ch 6	V4	VS
1	Choice 1	4	4	3	1	3	2	Choice 1	Choice 1
2	Choice 1	3	4	-3	-5	3	-5	Choice 1	Choice 1
3	n.a.	n.a.	n.a.	5	4	-5	-5	n.a.	0
4	Choice 2	-3	-4	1	2	-3	-2	Choice 2	Choice 2
5	Choice 1	3	3	2	-1	1	1	Choice 1	Choice 1
6	Choice 4	1	-3	-3	3	1	0	Choice 4	Choice 4
7	n.a.	-3	-3	0	-2	-5	-5	n.a.	0
8	n.a.	n.a.	n.a.	n.a.	n.a.	n.a.	n.a.	Choice 6	0
9	Choice 1	3	2	2	-1	2	3	Choice 3	0
10	n.a.	-5	-5	-5	-5	-5	-5	Choice 6	0
11	Choice 2	2	-2	4	2	-5	n.a.	Choice 2	Choice 2
12	n.a.	2	2	2	0	3	2	Choice 3	0
13	Choice 1	5	3	-5	-5	3	3	Choice 1	Choice 1
14	n.a.	1	1	-2	-2	3	3	n.a.	0
15	n.a.	1	-1	0	-1	2	3	Choice 3	0
16	Choice 3	3	2	2	1	3	3	n.a.	Choice 3
17	Choice 3	2	2	2	2	4	5	n.a.	0
18	Choice 1	5	3	0	0	2	2	Choice 1	Choice 1
19	Choice 2	-3	-4	0	2	-5	-5	Choice 4	Choice 2
20	Choice 4	3	2	2	1	1	0	Choice 4	Choice 5

V7 and the other variables with generic variables work perfect. So does V4
which can be used with both a generic and a alternative specific regression
coefficient. I only have problems with VS. There, R tells me that the length
of the variable causes problems (“Error in
model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data),  : 
variable lengths differ (found for 'P_id')). However, comparing lengths and
dimensions of V4 and VS, I see no difference! Both original data are
transformed into numeric values (as.numeric) (all values become to either
zero or one, depending on the alternative) and then put into (previously
defined) matrixes of the same dimensions. There were no differences visible
when checking the transformed variables with STR or CLASS. What else can I
check?

As stated above, I tried to isolate the problem-laden variable VS to set up
a single conditional logit model, but I did not manage it to make it  to the
long format (R comment was: Error in data[[choice]] : subscript out of
bounds). No idea whether there is a connection between the two problems. 

Any comment would be much appreciated.

Best regards and a nice weekend!




--
View this message in context: http://r.789695.n4.nabble.com/length-of-variable-in-mlogit-tp4638323p4639069.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list