[R] nlme, lme( ) convergence and selection of effects

From: Thiago Cortez Costa <thiago.cortez_at_uol.com.br>
Date: Mon, 14 Jul 2008 07:07:16 -0300

Hi all,  

I've been trying to fit a mixed effects model and I've been having problems.  

=>My aim:

to know whether states atributes, political parties and individual atributes affect the electoral results of men and women candidates.

I use candidates as replications for states and for political parties.  

=>Response: Percentage of valid votes casted to each individual.
(alternative response: electoral result (binomial: elected, non-elected)).  

=>Function used to fit model: lme from nlme package.

=>Data Organization:

Data is unbalanced. 4946 observations. Each row in the data frame has info on the individual candidates (educational level, marital status, sex, age,

party, etc) and on the states in which they run for election (literacy
rates, district magnitude, number of voters, urban population rates, sex
ratio, etc). Individual atributes vary within state and party%in%state.
State atributes vary between states. Though political parties are present across states, I have reasons to believe that they behave differently in each state.  


State ID               Literacy%            #Voters/#Candidates
SexRatio              Individual ID      Sex        Age
EducationalLevel             Party                     Etc.

AC                          84.5                       8241.92
102.56                  1                             M           42
Undergraduate               PT                           ...

AC                          84.5                       8241.92
102.56                  2                             F             35
Undergraduate               PL                           ...

AC                          84.5                       8241.92
102.56                  3                             M           55
Undergraduate               PMDB                   ...

DF                          96.6                       15593.38
89.64                     4                            M           40
PostGraduate                  PSDB                     ...

DF                          96.6                       15593.38
89.64                     5                            F             39
Undergraduate               PSOL

RJ                           96.0                       15363.96
88.42                     6                            M           63
Undergraduate               PT

RJ                           96.0                       15363.96
88.42                     7                            M           52
Undergraduate               PMDB                   ...



  1. I've found that the random effects of the 'state' level have a very low standard deviation.

>depfed.lme3<- lme(Votes~Sex, data=depfed.frm, random=~1|State/Party)

>summary (depfed.lme3)

(...)Random effects:

 Formula: ~1 | State


StdDev: 0.0001089504  

This suggests that there is no significant advantage on using 'state' alone as a grouping factor, I suppose. On the other hand, there is considerable variation in the effects of parties inside states:  

(...)Formula: ~1 | Party %in% State

        (Intercept) Residual

StdDev: 0.9904834 1.002779  

Is it possible to prevent R from calculating the random effects at the State level and still calculate the effects of Parties inside States? It would save degrees of freedom.  

2) When I try to insert variables as random terms, the estimation doesn't converge.  

Ex: > depfed.lme4 <- lme(Votes~Sex, data=depfed.frm, random=~Sex|State/Party)

       >Erro em lme.formula(Votes ~ Sex, data = depfed.frm, random = ~Sex | :

       >nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (9)  

       > depfed.lme4 <- lme(Votes~Age, data=depfed.frm, random=~Sex|State/Party)

       >Erro em lme.formula(Votes ~ Age, data = depfed.frm, random = ~Sex | :

       >nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (9)  

    Am I doing anything wrong? How can I overcome this problem? Any solutions using nlme or other packages are welcome.  

3) I guess I should use State atributes as fixed effects and candidates atributes both as fixed and random effects, any suggestion on this matter is also welcome.  

Thank you guys for your attention  

Thiago Cortez

Rio de Janeiro, Brazil      

        [[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. Received on Mon 14 Jul 2008 - 10:19:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jul 2008 - 11:31:58 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive