Hi there, I am trying to apply mlogit for a panel data set. I have 22 individuals (countries), for a 228 points in time domain, and 8 variables. I set my data in Excel in long format (I think!). I am trying to write a command to prepare data for mlogit by applying the following code. mdat<- mlogit.data (dat ,choice = "y", id="id", shape = "long", alt.var = "y") But I get the error below; Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.0", "1.0", "1.0", : duplicate 'row.names' are not allowed In addition: Warning message: non-unique values when setting 'row.names': '1.0', '100.1', '1000.0', '1001.1', '1002.0', '1003.0', '1004.0', '1005.0', '1006.0', '1007.0', '1008.0', '1009.0', '1010.0', '1011.1', '1012.2', '1013.1', '1015.0', '1016.0', '102.1', '1020.0', '1021.1', '1023.1', '1024.1', '1025.1', '1026.2', '1027.1', '103.1', '1030.1', '1034.1', '1036.0', '1037.1', '1038.0', '1039.0', '1040.1', '1042.2', '1043.1', '1044.2', '1045.1', '1046.1', '1048.1', '1049.0', '105.1', '1050.0', '1051.0', '1053.0', '1054.1', '1055.0', '1056.0', '1057.1', '1059.0', '106.1', '1061.1', '1062.1', '1063.0', '1064.0', '1065.0', '1066.0', '1067.0', '1068.0', '1069.0', '107.1', '1070.0', '1071.0', '1072.0', '1073.0', '1074.0', '1075.0', '1076.0', '1077.0', '1078.0', '1079.1', '1080.0', '1081.0', '1082.0', '1083.0', '1085.0', '1086.0', '1087.0', '1088.0', '1089.0', '109.1', '1090.0', '1091.0', '1092.0', '1093.0', '1095.0', '1096.0', '1097.1', '1098.2', '1099.1', '11.1', '110.0', '1101.1', '1102.0', '1103.0', '1104.1', '1105.0', [... truncated] I would say 'y' is an independent variable that takes 3 states i.e. 0,1,2. By the way, when I run the following command, it seems every thin is fine without any error but in 'mdat' data, 'chid' and 'alt' would not appear! I think there is something wrong with that. mdat <- mlogit.data(dat, id="id", choice="y", shape = "long", varying = NULL, alt.levels=c("0", "1", "2"),sep = "") Any help would be appreciated in advance. Regards, Houra [[alternative HTML version deleted]]
HI, It is better to provide a reproducible example.? From the nature of the error, it looks like the problem is similar to the one in the link below: http://r.789695.n4.nabble.com/mlogit-error-td4663601.html A.K. ----- Original Message ----- From: "Haghpanahan, Houra" <hh132 at leicester.ac.uk> To: "'r-help at r-project.org'" <r-help at r-project.org> Cc: Sent: Sunday, September 1, 2013 12:35 PM Subject: [R] help Hi there, I am trying to apply mlogit for a panel data set. I have 22 individuals (countries), for a 228 points in time domain, and 8 variables. I set my data in Excel in long format (I think!). I am trying to write a command to prepare data for mlogit by applying the following code. mdat<- mlogit.data (dat ,choice = "y", id="id", shape = "long", alt.var = "y") But I get the error below; Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.0", "1.0", "1.0",? :???duplicate 'row.names' are not allowed In addition: Warning message: non-unique values when setting 'row.names': '1.0', '100.1', '1000.0', '1001.1', '1002.0', '1003.0', '1004.0', '1005.0', '1006.0', '1007.0', '1008.0', '1009.0', '1010.0', '1011.1', '1012.2', '1013.1', '1015.0', '1016.0', '102.1', '1020.0', '1021.1', '1023.1', '1024.1', '1025.1', '1026.2', '1027.1', '103.1', '1030.1', '1034.1', '1036.0', '1037.1', '1038.0', '1039.0', '1040.1', '1042.2', '1043.1', '1044.2', '1045.1', '1046.1', '1048.1', '1049.0', '105.1', '1050.0', '1051.0', '1053.0', '1054.1', '1055.0', '1056.0', '1057.1', '1059.0', '106.1', '1061.1', '1062.1', '1063.0', '1064.0', '1065.0', '1066.0', '1067.0', '1068.0', '1069.0', '107.1', '1070.0', '1071.0', '1072.0', '1073.0', '1074.0', '1075.0', '1076.0', '1077.0', '1078.0', '1079.1', '1080.0', '1081.0', '1082.0', '1083.0', '1085.0', '1086.0', '1087.0', '1088.0', '1089.0', '109.1', '1090.0', '1091.0', '1092.0', '1093.0', '1095.0', '1096.0', '1097.1', '1098.2', '1099.1', '11.1', '110.0', '1101.1', '1102.0', '1103.0', '1104.1'! , '1105.0', [... truncated] I would say 'y' is an independent variable that takes 3 states i.e. 0,1,2. By the way, when I run the following command, it seems every thin is fine without any error but in 'mdat' data,? 'chid' and 'alt' would not appear! I think there is something wrong with that. mdat <- mlogit.data(dat, id="id", choice="y", shape = "long", varying = NULL, alt.levels=c("0", "1", "2"),sep = "") Any help would be appreciated in advance. Regards, Houra ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
tt <- function(x) { obrien <- function(x) { r <- rank(x) (r - 0.5)/(0.5 + length(r) - r) } unlist(tapply(x, riskset, obrien)) } hi, i am newer in R. when dealing with a survival data, i have found the variable progression was not met the PH assumption.the picture show the residual agaist time.So i use Cox model for time-depandent varibles. i use the default tt in function coxph,but when i use tt in "f<-cph(Surv(os$Stime,os$Status==1)~Metastasis+Surgery+Post.chem. +Age+tt(Progression)+ ALP, data=os, x=T, y=T, surv=TRUE, time.inc=60)",it didn't work. i don't kown what the arg"riskset" is .i beg your help . can you help me write down a appropriate tt expression to let me use in cph. thanks. Zhongxin Dong
The tt function is documented for coxph, and you are using cph. They are not the same. On 09/03/2013 05:00 AM, r-help-request at r-project.org wrote:> tt<- function(x) { > obrien<- function(x) { > r<- rank(x) > (r - 0.5)/(0.5 + length(r) - r) > } > unlist(tapply(x, riskset, obrien)) > } > hi, i am newer in R. when dealing with a survival data, i have found the variable progression was not met the PH assumption.the picture show the residual agaist time.So i use Cox model for time-depandent varibles. i use the default tt in function coxph,but when i use tt in "f<-cph(Surv(os$Stime,os$Status==1)~Metastasis+Surgery+Post.chem. +Age+tt(Progression)+ ALP, data=os, x=T, y=T, surv=TRUE, time.inc=60)",it didn't work. i don't kown what the arg"riskset" is .i beg your help . can you help me write down a appropriate tt expression to let me use in cph. thanks. > Zhongxin Dong >