Re: [R] problems with MNP

From: Kosuke Imai <kimai_at_Princeton.Edu>
Date: Thu 14 Jul 2005 - 03:49:33 EST


Hi Joan,
  You need to do:                                                                                       

 res1 <- mnp(PREVOTE3 ~ 1, choiceX = list("1"=UCLC, "2"=UDLC, "3"=UPLC),

             cXnames = "ut", data = small, verbose = TRUE)
                                                                                      

The quotations for "1" etc. are necessary because those are names of the list elements. Also, you should check the convergence of the Markov chain as 500 draws is typically not. In our Journal of Statistical Software paper (available at http://www.princeton.edu/~kimai/research/MNP.html), we show how to do this through some examples.

Best,
Kosuke                                                                                       


Kosuke Imai               Office: Corwin Hall 041
Assistant Professor       Phone: 609-258-6601
Department of Politics    eFax:  973-556-1929
Princeton University      Email: kimai@Princeton.Edu
Princeton, NJ 08544-1012 http://www.princeton.edu/~kimai

> > From: Joan Serra <jserra@uchicago.edu>
> > Date: July 13, 2005 6:14:31 AM PDT
> > To: r-help@stat.math.ethz.ch
> > Subject: [R] problems with MNP
> >
> >
> > Hi all,
> >
> > Does anybody have a hint on what may be going wrong in this R code? I
> > mimic the sample code from the MNP developers but I seem unable to
> > get the
> > choice specific variables right.
> >
> > Thanks,
> > Joan Serra
> >
> >
> >> rm(list=ls())
> >> library(foreign)
> >> small<-read.spss("small.sav")
> >>
> > Warning message:
> > small.sav: Unrecognized record type 7, subtype 13 encountered in
> > system
> > file.
> >
> >> library(MNP)
> >>
> > MNP: R Package for Fitting the Multinomial Probit Models
> > Version: 1.3-1
> > URL: http://www.princeton.edu/~kimai/research/MNP.html
> >
> >>
> >> res1 <- mnp(PREVOTE3 ~ 1, choiceX = list(1=UCLC, 2=UDLC,
> >> 3=UPLC),
> >>
> > Error: syntax error
> >
> >> cXnames = "ut", data = small, n.draws = 500,
> >> burnin =
> >>
> > 100,
> > Error: syntax error
> >
> >> verbose = TRUE)
> >>
> > Error: syntax error
> >
> >>
> >> # another try giving arbitrary names to the values of the dependent
> >>
> > variable
> >
> >>
> >> res1 <- mnp(PREVOTE3 ~ 1, choiceX = list(Clinton=UCLC,
> >> Dole=UDLC,
> >>
> > Perot=UPLC),
> > + cXnames = "ut", data = small, n.draws = 500,
> > burnin =
> > 100,
> > + verbose = TRUE)
> >
> > The base category is `1'.
> >
> > The total number of alternatives is 3.
> >
> > Error in xmatrix.mnp(formula, data = eval.parent(data), choiceX =
> > call$choiceX, :
> > Error: Invalid input for `choiceX.'
> > Some variables do not exist.
> >
> >>
> >> # another try using a string type dependent variable
> >>
> >> res1 <- mnp(PRVOTE3 ~ 1, choiceX = list(Clinton=UCLC, Dole=UDLC,
> >>
> > Perot=UPLC),
> > + cXnames = "ut", data = small, n.draws = 500,
> > burnin =
> > 100,
> > + verbose = TRUE)
> > Error in model.frame(formula, rownames, variables, varnames, extras,
> > extranames, :
> > invalid variable type
> >
> >>
> >>
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-
> > guide.html
> >

> 
> 
> --
> Andrew D. Martin, Ph.D.
> Associate Professor of Political Science
> Director, Program in Applied Statistics and Computation
> Professor of Law (by courtesy)
> Washington University in St. Louis
> 
> (314) 935-5863 (Office)
> (314) 753-8377 (Cell)
> (314) 935-5856 (Fax)
> 
> Office: Eliot Hall 326
> Email: admartin@wustl.edu
> WWW:   http://adm.wustl.edu
> 
> 
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 14 03:52:50 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:38 EST