From nola at stanford.edu Fri Feb 6 17:12:11 2009 From: nola at stanford.edu (Nola M. Stephens) Date: Fri, 06 Feb 2009 17:12:11 -0800 Subject: [R-lang] Estimated scale in R 2.8.1 Message-ID: <498CDFEB.7010800@stanford.edu> Hi, When using earlier version of R (2.6.2), I got a scale factor for an lmer model (where family=binomial). But after downloading R version 2.8.1, I'm unable to find this value. I'd really appreciate some advice on how to find this. Thanks! nola From rlevy at ucsd.edu Sun Feb 8 10:06:20 2009 From: rlevy at ucsd.edu (Roger Levy) Date: Sun, 08 Feb 2009 10:06:20 -0800 Subject: [R-lang] Estimated scale in R 2.8.1 In-Reply-To: <498CDFEB.7010800@stanford.edu> References: <498CDFEB.7010800@stanford.edu> Message-ID: <498F1F1C.4040800@ucsd.edu> Nola M. Stephens wrote: > Hi, > When using earlier version of R (2.6.2), I got a scale factor for an > lmer model (where family=binomial). But after downloading R version > 2.8.1, I'm unable to find this value. > > I'd really appreciate some advice on how to find this. Hi Nola, This question is best posed to the R-sig-ME mailing list! Best Roger -- Roger Levy Email: rlevy at ling.ucsd.edu Assistant Professor Phone: 858-534-7219 Department of Linguistics Fax: 858-534-4789 UC San Diego Web: http://ling.ucsd.edu/~rlevy From hugh.rabagliati at gmail.com Thu Feb 26 12:53:30 2009 From: hugh.rabagliati at gmail.com (Hugh Rabagliati) Date: Thu, 26 Feb 2009 15:53:30 -0500 Subject: [R-lang] lmer objects and mcmcsamp Message-ID: Hi all, This is a bit of a general question, but it arose out of using the pvals.fnc function so I figured this forum might have a few ideas about it. The issue is whether there's a very odd bug in the mcmcsamp package of lme4? (or whether I still don't understand mcmc methods well enough). If I create a mer object using lmer, use it as an argument for mcmcsamp (sampling > 1 times), assign the output to a new mermcmc object and then examine my mer object again, I notice a rather peculiar thing. In particular, all of the variance/standard error terms change, as do the associated t values for the fixed effects. The estimated coefficients are unaffected. I figure this is a bug, because I can't see any reason why mcmcsamp would want to do this. I took a look through the code for mcmcsamp, but I don't speak C and nothing jumped out at me. Certainly, the code is only supposed to return a mermcmc object, so I have no idea why its messing with my mer. I've got this same result on a couple of different computers (all macs). It does, however, seem to be specific to either the version of lmer ( 0.999375-28) or of R (2.8.1) that I'm using. I tried it on an old PC version of R (2.5.1) using lme4 version 0.99875-9, and the same problems don't happen then. I've included the output from both the PC and mac versions below. Sage advice, comments, or confirmation that this is a known bug (I couldn't find mention of it elsewhere) would be welcome. Thanks very much, Hugh Rabagliati ######## # #PC Code & output - R v. 2.5.1 & lme4 v. 0.99875-9. # (fm1 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy)) #Linear mixed-effects model fit by REML #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) # Data: sleepstudy # AIC BIC logLik MLdeviance REMLdeviance # 1752 1764 -871.8 1752 1744 #Random effects: # Groups Name Variance Std.Dev. # Subject (Intercept) 627.508 25.0501 # Subject Days 35.858 5.9881 # Residual 653.590 25.5654 #number of obs: 180, groups: Subject, 18; Subject, 18 #Fixed effects: # Estimate Std. Error t value #(Intercept) 251.405 6.885 36.51 #Days 10.467 1.560 6.71 #Correlation of Fixed Effects: # (Intr) #Days -0.184 fm1 -> fm1.old samp0 <- mcmcsamp(fm1, n = 1000) fm1 #Linear mixed-effects model fit by REML #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) # Data: sleepstudy # AIC BIC logLik MLdeviance REMLdeviance # 1752 1764 -871.8 1752 1744 #Random effects: # Groups Name Variance Std.Dev. # Subject (Intercept) 627.508 25.0501 # Subject Days 35.858 5.9881 # Residual 653.590 25.5654 #number of obs: 180, groups: Subject, 18; Subject, 18 #Fixed effects: # Estimate Std. Error t value #(Intercept) 251.405 6.885 36.51 #Days 10.467 1.560 6.71 #Correlation of Fixed Effects: # (Intr) #Days -0.184 # # As you can see, the estimates don't change here # ########### ######### # # Mac R v. 2.8.1, ?lme4? version 0.999375-28 # # I make two mers, which should be identical (I make two because there are some assignment weirdnesses going on here too, #which I haven't yet understood) (fm1.to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days| Subject), sleepstudy)) #Linear mixed model fit by REML #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) # Data: sleepstudy # AIC BIC logLik deviance REMLdev # 1754 1770 -871.8 1752 1744 #Random effects: # Groups Name Variance Std.Dev. # Subject (Intercept) 627.568 25.0513 # Subject Days 35.858 5.9882 # Residual 653.584 25.5653 #Number of obs: 180, groups: Subject, 18 #Fixed effects: # Estimate Std. Error t value #(Intercept) 251.405 6.885 36.51 #Days 10.467 1.559 6.71 #Correlation of Fixed Effects: # (Intr) #Days -0.184 (fm1.not_to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days| Subject), sleepstudy)) #Linear mixed model fit by REML #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) # Data: sleepstudy # AIC BIC logLik deviance REMLdev # 1754 1770 -871.8 1752 1744 #Random effects: # Groups Name Variance Std.Dev. # Subject (Intercept) 627.568 25.0513 # Subject Days 35.858 5.9882 # Residual 653.584 25.5653 #Number of obs: 180, groups: Subject, 18 #Fixed effects: # Estimate Std. Error t value #(Intercept) 251.405 6.885 36.51 #Days 10.467 1.559 6.71 #Correlation of Fixed Effects: # (Intr) #Days -0.184 samp0 <- mcmcsamp(fm1.to_mcmc, n = 1000) fm1.to_mcmc #Linear mixed model fit by REML #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) # Data: sleepstudy # AIC BIC logLik deviance REMLdev # 1763 1779 -876.7 1761 1753 #Random effects: # Groups Name Variance Std.Dev. # Subject (Intercept) 868.398 29.469 # Subject Days 49.619 7.044 #Residual 904.398 30.073 #Number of obs: 180, groups: Subject, 18 #Fixed effects: # Estimate Std. Error t value #(Intercept) 251.405 5.260 47.79 #Days 10.467 1.518 6.90 # All the variances etc are different from before #Correlation of Fixed Effects: # (Intr) #Days -0.343 fm1.not_to_mcmc #Linear mixed model fit by REML #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) # Data: sleepstudy # AIC BIC logLik deviance REMLdev # 1754 1770 -871.8 1752 1744 #Random effects: # Groups Name Variance Std.Dev. # Subject (Intercept) 627.568 25.0513 # Subject Days 35.858 5.9882 # Residual 653.584 25.5653 #Number of obs: 180, groups: Subject, 18 #Fixed effects: # Estimate Std. Error t value #(Intercept) 251.405 6.885 36.51 #Days 10.467 1.559 6.71 # Variances are unaffected here #Correlation of Fixed Effects: # (Intr) #Days -0.184 From rlevy at ucsd.edu Thu Feb 26 14:12:02 2009 From: rlevy at ucsd.edu (Roger Levy) Date: Thu, 26 Feb 2009 14:12:02 -0800 Subject: [R-lang] lmer objects and mcmcsamp In-Reply-To: References: Message-ID: <49A713B2.9000908@ucsd.edu> Hi Hugh, Yes, I've been able to reproduce this behavior (on OS X R 2.8.1, same lme4 version as you). I don't see any reason why this should happen and it violates R's functional-programming modus operandi. I suggest you report it to the R-sig-ME list as Doug Bates will probably be grateful. Best Roger Hugh Rabagliati wrote: > Hi all, > > This is a bit of a general question, but it arose out of using the > pvals.fnc function so I figured this forum might have a few ideas about it. > > The issue is whether there's a very odd bug in the mcmcsamp package of > lme4? (or whether I still don't understand mcmc methods well enough). > > If I create a mer object using lmer, use it as an argument for mcmcsamp > (sampling > 1 times), assign the output to a new mermcmc object and then > examine my mer object again, I notice a rather peculiar thing. In > particular, all of the variance/standard error terms change, as do the > associated t values for the fixed effects. The estimated coefficients > are unaffected. I figure this is a bug, because I can't see any reason > why mcmcsamp would want to do this. I took a look through the code for > mcmcsamp, but I don't speak C and nothing jumped out at me. Certainly, > the code is only supposed to return a mermcmc object, so I have no idea > why its messing with my mer. > > I've got this same result on a couple of different computers (all macs). > It does, however, seem to be specific to either the version of lmer ( > 0.999375-28) or of R (2.8.1) that I'm using. I tried it on an old PC > version of R (2.5.1) using lme4 version 0.99875-9, and the same problems > don't happen then. I've included the output from both the PC and mac > versions below. > > Sage advice, comments, or confirmation that this is a known bug (I > couldn't find mention of it elsewhere) would be welcome. > > Thanks very much, > > Hugh Rabagliati > > > ######## > # > #PC Code & output - R v. 2.5.1 & lme4 v. 0.99875-9. > # > (fm1 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), > sleepstudy)) > #Linear mixed-effects model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik MLdeviance REMLdeviance > # 1752 1764 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.508 25.0501 > # Subject Days 35.858 5.9881 > # Residual 653.590 25.5654 > #number of obs: 180, groups: Subject, 18; Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.560 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > fm1 -> fm1.old > samp0 <- mcmcsamp(fm1, n = 1000) > fm1 > #Linear mixed-effects model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik MLdeviance REMLdeviance > # 1752 1764 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.508 25.0501 > # Subject Days 35.858 5.9881 > # Residual 653.590 25.5654 > #number of obs: 180, groups: Subject, 18; Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.560 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > # > # As you can see, the estimates don't change here > # > ########### > > > ######### > # > # Mac R v. 2.8.1, ?lme4? version 0.999375-28 > # > # I make two mers, which should be identical (I make two because there > are some assignment weirdnesses going on here too, #which I haven't yet > understood) > > (fm1.to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), > sleepstudy)) > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1754 1770 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.568 25.0513 > # Subject Days 35.858 5.9882 > # Residual 653.584 25.5653 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.559 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > > (fm1.not_to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + > (0+Days|Subject), sleepstudy)) > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1754 1770 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.568 25.0513 > # Subject Days 35.858 5.9882 > # Residual 653.584 25.5653 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.559 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > > samp0 <- mcmcsamp(fm1.to_mcmc, n = 1000) > fm1.to_mcmc > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1763 1779 -876.7 1761 1753 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 868.398 29.469 > # Subject Days 49.619 7.044 > #Residual 904.398 30.073 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 5.260 47.79 > #Days 10.467 1.518 6.90 > > # All the variances etc are different from before > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.343 > > fm1.not_to_mcmc > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1754 1770 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.568 25.0513 > # Subject Days 35.858 5.9882 > # Residual 653.584 25.5653 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.559 6.71 > > # Variances are unaffected here > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > > _______________________________________________ > R-lang mailing list > R-lang at ling.ucsd.edu > http://pidgin.ucsd.edu/mailman/listinfo/r-lang -- Roger Levy Email: rlevy at ling.ucsd.edu Assistant Professor Phone: 858-534-7219 Department of Linguistics Fax: 858-534-4789 UC San Diego Web: http://ling.ucsd.edu/~rlevy From austin.frank at gmail.com Thu Feb 26 14:23:43 2009 From: austin.frank at gmail.com (Austin Frank) Date: Thu, 26 Feb 2009 17:23:43 -0500 Subject: [R-lang] [SPAM] Re: lmer objects and mcmcsamp References: Message-ID: Hugh-- Interesting question. I just tried it out and replicated the report on R version 2.8.1 (2008-12-22) powerpc-apple-darwin8.11.1 with lme4_0.999375-28 and Matrix_0.999375-21. I don't have the first idea what's going on here, but I'm quite certain this question should also go to R-sig-mixed-models, so I've copied that group in this response. Thanks for the report, /au On Thu, Feb 26 2009, Hugh Rabagliati wrote: > This is a bit of a general question, but it arose out of using the > pvals.fnc function so I figured this forum might have a few ideas > about it. > > The issue is whether there's a very odd bug in the mcmcsamp package of > lme4? (or whether I still don't understand mcmc methods well enough). > > If I create a mer object using lmer, use it as an argument for > mcmcsamp (sampling > 1 times), assign the output to a new mermcmc > object and then examine my mer object again, I notice a rather > peculiar thing. In particular, all of the variance/standard error > terms change, as do the associated t values for the fixed effects. > The estimated coefficients are unaffected. I figure this is a bug, > because I can't see any reason why mcmcsamp would want to do this. I > took a look through the code for mcmcsamp, but I don't speak C and > nothing jumped out at me. Certainly, the code is only supposed to > return a mermcmc object, so I have no idea why its messing with my > mer. > > I've got this same result on a couple of different computers (all > macs). It does, however, seem to be specific to either the version of > lmer ( 0.999375-28) or of R (2.8.1) that I'm using. I tried it on an > old PC version of R (2.5.1) using lme4 version 0.99875-9, and the > same problems don't happen then. I've included the output from both > the PC and mac versions below. > > Sage advice, comments, or confirmation that this is a known bug (I > couldn't find mention of it elsewhere) would be welcome. > > Thanks very much, > > Hugh Rabagliati > > > ######## > # > #PC Code & output - R v. 2.5.1 & lme4 v. 0.99875-9. > # > (fm1 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), > sleepstudy)) > #Linear mixed-effects model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik MLdeviance REMLdeviance > # 1752 1764 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.508 25.0501 > # Subject Days 35.858 5.9881 > # Residual 653.590 25.5654 > #number of obs: 180, groups: Subject, 18; Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.560 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > fm1 -> fm1.old > samp0 <- mcmcsamp(fm1, n = 1000) > fm1 > #Linear mixed-effects model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik MLdeviance REMLdeviance > # 1752 1764 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.508 25.0501 > # Subject Days 35.858 5.9881 > # Residual 653.590 25.5654 > #number of obs: 180, groups: Subject, 18; Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.560 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > # > # As you can see, the estimates don't change here > # > ########### > > > ######### > # > # Mac R v. 2.8.1, ?lme4? version 0.999375-28 > # > # I make two mers, which should be identical (I make two because there > are some assignment weirdnesses going on here too, #which I haven't > yet understood) > > (fm1.to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days| > Subject), sleepstudy)) > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1754 1770 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.568 25.0513 > # Subject Days 35.858 5.9882 > # Residual 653.584 25.5653 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.559 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > > (fm1.not_to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days| > Subject), sleepstudy)) > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1754 1770 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.568 25.0513 > # Subject Days 35.858 5.9882 > # Residual 653.584 25.5653 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.559 6.71 > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 > > > samp0 <- mcmcsamp(fm1.to_mcmc, n = 1000) > fm1.to_mcmc > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1763 1779 -876.7 1761 1753 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 868.398 29.469 > # Subject Days 49.619 7.044 > #Residual 904.398 30.073 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 5.260 47.79 > #Days 10.467 1.518 6.90 > > # All the variances etc are different from before > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.343 > > fm1.not_to_mcmc > > #Linear mixed model fit by REML > #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) > # Data: sleepstudy > # AIC BIC logLik deviance REMLdev > # 1754 1770 -871.8 1752 1744 > #Random effects: > # Groups Name Variance Std.Dev. > # Subject (Intercept) 627.568 25.0513 > # Subject Days 35.858 5.9882 > # Residual 653.584 25.5653 > #Number of obs: 180, groups: Subject, 18 > > #Fixed effects: > # Estimate Std. Error t value > #(Intercept) 251.405 6.885 36.51 > #Days 10.467 1.559 6.71 > > # Variances are unaffected here > > #Correlation of Fixed Effects: > # (Intr) > #Days -0.184 -- Austin Frank http://aufrank.net GPG Public Key (D7398C2F): http://aufrank.net/personal.asc From hugh.rabagliati at gmail.com Thu Feb 26 17:44:58 2009 From: hugh.rabagliati at gmail.com (Hugh Rabagliati) Date: Thu, 26 Feb 2009 20:44:58 -0500 Subject: [R-lang] Fwd: [R-sig-ME] lmer & mcmcsamp bug? References: <40e66e0b0902261451w42eeff2dwe6f2c1588cf01844@mail.gmail.com> Message-ID: <496640E6-CAB1-48B0-92FA-195C5287C01A@gmail.com> Hi all, So it turns out to be a bug. I've attached Douglas Bates' response below. It doesn't seem like this should be a hard problem to fix, so hopefully there'll be an update soonish. Thanks for the replies, Hugh Begin forwarded message: > From: Douglas Bates > Date: February 26, 2009 5:51:58 PM EST > To: Hugh Rabagliati > Cc: r-sig-mixed-models at r-project.org > Subject: Re: [R-sig-ME] lmer & mcmcsamp bug? > > On Thu, Feb 26, 2009 at 4:21 PM, Hugh Rabagliati > wrote: >> Hi all, >> >> Yesterday I noticed what I take to be a bug in the current version >> of lme4, >> and the folks over at the R-lang forum suggested checking in about >> it here. >> >> If I create a mer object using lmer, use it as an argument for >> mcmcsamp >> (sampling > 1 times) and then examine my mer object again, I >> notice a rather >> peculiar thing. In particular, all of the variance/standard error >> terms >> change, as do the associated t values for the fixed effects. The >> estimated >> coefficients are unaffected. I figure this is a bug, because I >> can't see any >> reason why mcmcsamp would want to do this. I took a look through >> the code >> for mcmcsamp, but I don't speak C and nothing jumped out at me. >> Certainly >> the function looks like its only meant to return a mermcmc object, >> so I have >> no idea why its messing with my mer. >> >> I've got this same result on a couple of different computers (all >> macs). It >> does, however, seem to be specific to either the version of lmer ( >> 0.999375-28) or of R (2.8.1) that I'm using. I tried it on an old >> PC version >> of R (2.5.1) using lme4 version 0.99875-9, and the same problems >> don't >> happen then. I've included the output from both the PC and mac >> versions >> below. >> >> Sage advice, comments, or confirmation that this is a known bug (I >> couldn't >> find mention of it elsewhere) would be welcome. > > Well, it's a bug. > > The C code called by mcmcsamp does something naughty - it changes the > value of slots of the fitted model object in place. I plead the usual > excuse for such inexcusable behavior: efficiency. If one copies the > whole fitted model object at each step in the MCMC iterations the > function would only be applicable to small models and would take > forever, even on those. (Actually I guess such a statement further > makes me guilty of Knuth's "root of all evil" - premature optimization > - because I haven't actually checked that.) > > The code at the end of the C function mer_MCMCsamp is supposed to > restore the original values. I guess some "infelicities", as Bill > Venables calls them, must have crept in. I'll take a look. > >> ######## >> # >> #PC Code & output - R v. 2.5.1 & lme4 v. 0.99875-9. >> # >> (fm1 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), >> sleepstudy)) >> #Linear mixed-effects model fit by REML >> #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) >> # Data: sleepstudy >> # AIC BIC logLik MLdeviance REMLdeviance >> # 1752 1764 -871.8 1752 1744 >> #Random effects: >> # Groups Name Variance Std.Dev. >> # Subject (Intercept) 627.508 25.0501 >> # Subject Days 35.858 5.9881 >> # Residual 653.590 25.5654 >> #number of obs: 180, groups: Subject, 18; Subject, 18 >> >> #Fixed effects: >> # Estimate Std. Error t value >> #(Intercept) 251.405 6.885 36.51 >> #Days 10.467 1.560 6.71 >> >> #Correlation of Fixed Effects: >> # (Intr) >> #Days -0.184 >> >> fm1 -> fm1.old >> samp0 <- mcmcsamp(fm1, n = 1000) >> fm1 >> #Linear mixed-effects model fit by REML >> #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) >> # Data: sleepstudy >> # AIC BIC logLik MLdeviance REMLdeviance >> # 1752 1764 -871.8 1752 1744 >> #Random effects: >> # Groups Name Variance Std.Dev. >> # Subject (Intercept) 627.508 25.0501 >> # Subject Days 35.858 5.9881 >> # Residual 653.590 25.5654 >> #number of obs: 180, groups: Subject, 18; Subject, 18 >> >> #Fixed effects: >> # Estimate Std. Error t value >> #(Intercept) 251.405 6.885 36.51 >> #Days 10.467 1.560 6.71 >> >> #Correlation of Fixed Effects: >> # (Intr) >> #Days -0.184 >> >> # >> # As you can see, the estimates don't change here >> # >> ########### >> >> >> ######### >> # >> # Mac R v. 2.8.1, ?lme4? version 0.999375-28 >> # >> # I make two mers, which should be identical (I make two because >> there are >> some assignment weirdnesses going on here too, #which I haven't yet >> understood) >> >> (fm1.to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days| >> Subject), >> sleepstudy)) >> >> #Linear mixed model fit by REML >> #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) >> # Data: sleepstudy >> # AIC BIC logLik deviance REMLdev >> # 1754 1770 -871.8 1752 1744 >> #Random effects: >> # Groups Name Variance Std.Dev. >> # Subject (Intercept) 627.568 25.0513 >> # Subject Days 35.858 5.9882 >> # Residual 653.584 25.5653 >> #Number of obs: 180, groups: Subject, 18 >> >> #Fixed effects: >> # Estimate Std. Error t value >> #(Intercept) 251.405 6.885 36.51 >> #Days 10.467 1.559 6.71 >> >> #Correlation of Fixed Effects: >> # (Intr) >> #Days -0.184 >> >> >> (fm1.not_to_mcmc <- lmer(Reaction ~ Days + (1|Subject) + (0+Days| >> Subject), >> sleepstudy)) >> >> #Linear mixed model fit by REML >> #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) >> # Data: sleepstudy >> # AIC BIC logLik deviance REMLdev >> # 1754 1770 -871.8 1752 1744 >> #Random effects: >> # Groups Name Variance Std.Dev. >> # Subject (Intercept) 627.568 25.0513 >> # Subject Days 35.858 5.9882 >> # Residual 653.584 25.5653 >> #Number of obs: 180, groups: Subject, 18 >> >> #Fixed effects: >> # Estimate Std. Error t value >> #(Intercept) 251.405 6.885 36.51 >> #Days 10.467 1.559 6.71 >> >> #Correlation of Fixed Effects: >> # (Intr) >> #Days -0.184 >> >> >> samp0 <- mcmcsamp(fm1.to_mcmc, n = 1000) >> fm1.to_mcmc >> >> #Linear mixed model fit by REML >> #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) >> # Data: sleepstudy >> # AIC BIC logLik deviance REMLdev >> # 1763 1779 -876.7 1761 1753 >> #Random effects: >> # Groups Name Variance Std.Dev. >> # Subject (Intercept) 868.398 29.469 >> # Subject Days 49.619 7.044 >> #Residual 904.398 30.073 >> #Number of obs: 180, groups: Subject, 18 >> >> #Fixed effects: >> # Estimate Std. Error t value >> #(Intercept) 251.405 5.260 47.79 >> #Days 10.467 1.518 6.90 >> >> # All the variances etc are different from before >> >> #Correlation of Fixed Effects: >> # (Intr) >> #Days -0.343 >> >> fm1.not_to_mcmc >> >> #Linear mixed model fit by REML >> #Formula: Reaction ~ Days + (1 | Subject) + (0 + Days | Subject) >> # Data: sleepstudy >> # AIC BIC logLik deviance REMLdev >> # 1754 1770 -871.8 1752 1744 >> #Random effects: >> # Groups Name Variance Std.Dev. >> # Subject (Intercept) 627.568 25.0513 >> # Subject Days 35.858 5.9882 >> # Residual 653.584 25.5653 >> #Number of obs: 180, groups: Subject, 18 >> >> #Fixed effects: >> # Estimate Std. Error t value >> #(Intercept) 251.405 6.885 36.51 >> #Days 10.467 1.559 6.71 >> >> # Variances are unaffected here >> >> #Correlation of Fixed Effects: >> # (Intr) >> #Days -0.184 >> >> _______________________________________________ >> R-sig-mixed-models at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From cec at psych.umass.edu Fri Feb 27 06:10:12 2009 From: cec at psych.umass.edu (Charles Clifton) Date: Fri, 27 Feb 2009 09:10:12 -0500 Subject: [R-lang] lmer objects, mcmcsamp, and aovlmer.fnc Message-ID: <49A7F444.7080807@psych.umass.edu> Here's one thing to add to the discussion of how mcmcsamp affects lmer objects (discussion by Rabagliati, Frank, and Bates): the changes that mcmcsamp makes to the lmer object result in crashes when one attempts to apply aovlmer.fnc to the lmer crashing, producing error messages (see, e.g., http://www.nabble.com/Problem-with-aovlmer.fnc-in-languageR-td20706128.html ). I had corresponded with Harald Baayen, who verified the problem, and noted that the p values returned by current versions of mcmcsamp may not be the same as those returned by older versions. I am delighted that Dr. Bates is now aware of the problem. Chuck Clifton -- Charles Clifton Department of Psychology 435 Tobin Hall University of Massachusetts Amherst, MA 01003 USA webpage: people.umass.edu/cec cec at psych.umass.edu (413) 545 2653 fax (413) 545 0996