# [R] Multinomial Logit Model with lots of Dummy Variables

ghpow1 ghpow1 at student.monash.edu.au
Sun Apr 10 11:37:34 CEST 2011

```Hi All,

I am attempting to build a Multinomial Logit model with dummy variables of
the following form:

Dependent Variable : 0-8 Discrete Choices

Dummy Variable 1: 965 dummy varsghpow at student.monash.edu.augh@gp1.com
Dummy Variable 2: 805 dummy vars

The data set I am using has the dummy columns pre-created, so it's a table
of 72,381 rows and 1770 columns.

The first 965 columns represent the dummy columns for Variable 1
The next 805 columns represent the dummy columns for Variable 2

My code to build the mlogit model looks like the following. I want to
know...is there a better way of doing this without these huge equations? (I
probably also need a more powerful PC to do all of this).

I'll also want to perform a joint test of significance on the first 805
coefficients...

Is this possible?

Thanks

GP

[code]

#install MLOGIT
library(mlogit)

mydata = 0
my_data=0

num.rows=length(mydata[,1])
num.cols=965+805+1

my_data=matrix(0,nr=num.rows,nc=num.cols)

for(i in 1:num.rows) {

nb=mydata[i,2]
np=mydata[i,3]

my_data[i,nb]=1
my_data[i,965+np]=1
my_data[i,1+1770]=mydata[i,1]

}

#convert matrix to data.frame
# convert to data frame
my_data_frame<-as.data.frame(my_data)

#load dataframe into mldata with choice variable
mldata<-mlogit.data(my_data_frame, varying=NULL, choice="V1771",
shape="wide")

#V1771 = dependent var
#V1-V965 = variable 1 dummies
#V966-V1700 = variable 2 dummies

#regress V1771 against all 1700 variables...
mlogit.model<-mlogit(V1771~0|V1+V2+V3...+V1700,data=mldata, reflevel="0")

[/code]

--
View this message in context: http://r.789695.n4.nabble.com/Multinomial-Logit-Model-with-lots-of-Dummy-Variables-tp3439492p3439492.html
Sent from the R help mailing list archive at Nabble.com.

```