[R] System of logistics Equations

Paul Johnson pauljohn32 at gmail.com
Tue Feb 24 08:57:06 CET 2009

On Fri, Feb 20, 2009 at 4:19 AM, Bernardo Rangel Tura
<tura at centroin.com.br> wrote:
> Hi R-masters
> I need yours help about a problema in one of may ongoing researchers.
> In my research the subjects (20 in total) answer 60 questions (20 type
> G, 20 type S and 20 type P).
> Which questions is classified about 3 factor (2 level each) and the
> subject score with 2 scale (not integer value is possible but rare): Val
> range -7 to 7 and other Car range 1 to 7.
> This a code to fake database of research
> Subj<-rep(1:20,each=60)
> Sti<-rep(c("G","S","P"),40)
> SP<-rep(c("S","P"),60)
> AG<-rep(c("A","P"),60)
> Mer<-rep(c("M","NM"),60)
> Car<-round(runif(120,1,7),0)
> Val<-round(runif(120,-7,7),0)
> base<-data.frame(Subj,Sti,SP,AG,Mer,Car,Val)
> In my hypothesis:
> logit(Sti=="G") ~ SP+AG+Mer+Car+Val+SP*Car+Mer*Val+AG*Val + errorG
> logit(Sti=="S") ~ SP+AG+Mer+Car+Val+SP*Car+Mer*Val+AG*Val + errorS
> logit(Sti=="P") ~ SP+AG+Mer+Car+Val+SP*Car+Mer*Val+AG*Val + errorP
> I test and the 3 terms of error (errorG,errorS,errorP) is correlated.
> So I think useful adjust a system of logistic equations to tread the 3
> equations and in same time to obtain estimatives of effects and
> uncorrelated error terms.
> The systemfit package fit linear system and non-linear system but is
> possible adjust a logistic system in R?

No, but I think this is a very interesting question.

If you just had 3 dichotomous outputs, I think you could estimate this
model with lmer in the lme4 package.  "Stack" the 3 sets of data
together, include dummy variables for the different questions, and
then introduce correlated random errors that affect the 3 groups. lmer
can estimate correlated cariance structures.

That might work, but after reading you question over a few times, I
think first of all you have to reconsider idea about your output
variable.  I've not seen anybody take a 3 category output and treat it
as a sequence of dichotomies in this way. Rather, we'd either need to
treat this as an ordered output or an unordered one.  If it is
ordered, then I do not know of an R estimator that will help.  As luck
would have it, I was recently reading about a Stata package produced
by sociologist R Williams (Notre Dame).  He offers a package for
ordinal model (he calls them ordinal generalized linear models, but
AFAICT that may be a misnomer because the probability model underlying
the ordinal logistic does not fall within the exponential family that
is usually used to define the GLM).  Nevertheless, he offers the code
for Stata http://www.nd.edu/~rwilliam/oglm/ . Since I'm not a Stata
user, I've not tried it.  It seems like a good exercise for one of us
to get a graduate student programmer to find out how he estimates
those models and make an R package.

I believe with 3 or more  unordered categories in the output, you have
a multinomial problem, not just the simpler problem of 3 logistic
models sharing some errors. I suppose if these choices were sequenced,
it could be represented as a conditional logistic regression as well.
(Example, is the subject sick or not?  If sick, is it cancer or heart

There is an R package for fitting to heteroskedastic multinomial
choice models. Fellow political scientist Walter Mebane (Cornell)  and
Jasjeet S. Sekhon published an article on this model and they put
their R package on CRAN "multinomRob"  Robust Estimation of
Overdispersed Multinomial Regression Models.

Oh, well, good luck with your project.  I hope we'll get some lively
answers :). If you get private answers, please forward me the useful


> Thanks in advance
> --
> Bernardo Rangel Tura, M.D,MPH,Ph.D
> National Institute of Cardiology
> Brazil
> ______________________________________________
> 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.

Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

More information about the R-help mailing list