[R] lme funcion in R

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Aug 5 10:22:30 CEST 2009


Harry,

I you use dummy variables, then you can only use (n-1) dummy variables
if your variable has n levels. Otherwise you introduce
multicollinearity! If you use n dummy variable then you can express one
dummy variable as a linear combination of the others.

Make use of a factor variable. That is much easier to work with that
dummy variables. The model itself will create the necessary dummy
variables. 

lusdrdata$HousingType <- factor(lusdrdata$HousingType, levels = 1:6,
labels = c("Reference", "MH_D", "APT_D", "ResOth_D", "NonRes_D",
"Vacant_D"))
lme(fixed = LN_unitlandval ~ HousingType +
access_emp1+pct_vacant+transit_D +park_dum,data=lusdrdata, random = ~
HousingType | TAZ)

HTH,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
Namens Hongwei Dong
Verzonden: woensdag 5 augustus 2009 1:49
Aan: r-help at r-project.org
Onderwerp: Re: [R] lme funcion in R

Yeah, I have a very large sample size, about 60,000 observations.
Multicollinearity should not be a problem here. The weird thing is that
SPSS can converge very quickly and gives out reasonable results.
The only problem I can think of is that, my first level (random)
variables are dummy variables: 6 housing types, and I used five dummies
in model and one as the reference. I also tried to combine them into two
groups and use only dummy at random level, but it does not work either.

is there any one here has similar experience with the LME function in R?

Thanks.

Harry



On Tue, Aug 4, 2009 at 1:28 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be>wrote:

> Dear Harry,
>
> Your model seems rather complex. Do you have enough data to support
it?
> Did you check for multicollinearity between the variables?
>
> HTH,
>
> Thierry
>
>
>
> ----------------------------------------------------------------------
> --
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature

> and Forest Cel biometrie, methodologie en kwaliteitszorg / Section 
> biometrics, methodology and quality assurance Gaverstraat 4 9500 
> Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx at inbo.be 
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no 
> more than asking him to perform a post-mortem examination: he may be 
> able to say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does 
> not ensure that a reasonable answer can be extracted from a given body

> of data.
> ~ John Tukey
>
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org]
> Namens Hongwei Dong
> Verzonden: maandag 3 augustus 2009 19:45
> Aan: r-help at r-project.org
> Onderwerp: Re: [R] lme funcion in R
>
> Thanks for the replies above. Here are my script and data structure:
> library(nlme)
> tlevel<-lme(fixed = LN_unitlandval ~
> MH_D+APT_D+ResOth_D+NonRes_D+Vacant_D+access_emp1+pct_vacant+transit_D
> +p
> ark_dum,data=lusdrdata,random
> = ~MH_D+APT_D+ResOth_D+NonRes_D+Vacant_D | TAZ)
>
> str:
>
> $ TAZ : int 100 100 100 100 100 100 100 100 100 100 ...
> $ MH_D : num 0 0 0 0 0 0 0 0 0 0 ...
> $ APT_D : num 0 0 0 0 0 0 0 0 0 0 ... $ ResOth_D : num 0 0 0 0 0 0 0 0

> 0 0 ... $ NonRes_D : num 0 0 0 0 0 0 0 0 0 1 ...
> $ Vacant_D : num 1 1 1 0 0 1 1 1 1 0 ...
> $ access_emp1 : num 45.8 45.8 45.8 45.8 45.8 ...
> $ pct_vacant : num 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 ... $ 
> transit_D :
> num 0 0 0 0 0 0 0 0 0 0 ... $ park_dum : num 0 0 0 0 0 0 0 0 0 0 ...
>
>
> Thanks.
>
> Harry
>
>
>
> On Mon, Aug 3, 2009 at 10:36 AM, Jason Morgan <jwm-r-help at skepsi.net>
> wrote:
>
> > On 2009.08.03 10:15:46, Hongwei Dong wrote:
> > > Hi, R users,
> > >   I'm using the "lme" function in R to estimate a 2 level mixed 
> > > effects model, in which the size of the subject groups are 
> > > different. It turned
> > out
> > > that It takes forever for R to converge. I also tried the same 
> > > thing
>
> > > in
> > SPSS
> > > and SPSS can give the results out within 20 minutes. Anyone can 
> > > give
>
> > > me
> > some
> > > advice on the lme function in R, especially why R does not
converge?
> > Thanks.
> > >
> > > Harry
> >
> > Hello Harry,
> >
> > As Chuck mentions, providing some more information on the model and 
> > the data you are using would be helpful. Also, be sure to compare 
> > the optimization methods used in SPSS to that used in R. You can 
> > change the optimization method in R if the default seems to be 
> > causing issues. See help(lmeControl) for numerous setting options.
> >
> > ~Jason
> >
> > --
> > Jason W. Morgan
> > Graduate Student
> > Department of Political Science
> > *The Ohio State University*
> > 154 North Oval Mall
> > Columbus, Ohio 43210
> >
> >
>
>         [[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.
>
> Dit bericht en eventuele bijlagen geven enkel de visie van de 
> schrijver weer en binden het INBO onder geen enkel beding, zolang dit 
> bericht niet bevestigd is door een geldig ondertekend document. The 
> views expressed in  this message and any annex are purely those of the

> writer and may not be regarded as stating an official position of 
> INBO, as long as the message is not confirmed by a duly signed 
> document.
>

	[[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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.




More information about the R-help mailing list