Re: [R] Equivalent of intervals() in lmer
Dear Friends, (1) There may be a solution for those (e.g., experimental psychologists) who are *not at all* interested in generalizing the absolute level of the response variable (say, reaction time, rt) to other subjects, but *only* to generalize the effect of the manipulated variables within subjects (because that's what the theory speaks to) to other subjects. First, center the predictor(s) so as to remove any spurious correlation between mean and intercept, and then write the random effect w/o an intercept. Now the model will not address whether rt is different from 0, it will only estimate the slope and whether it's different from 0: require(lme4) require(gmodels) data(sleepstudy) ss - sleepstudy ss$days - with(ss, Days - mean(Days)) (fm1 - lmer(Reaction ~ days + (days|Subject), ss)) (fm3 - lmer(Reaction ~ days + (-1 + days|Subject), ss)) ci(fm1) ci(fm3) # CIs for days are about 14% smaller (2) When the predictor is not continuous, this approach doesn't work. A solution for a designed experiment is to plot CIs for differences, i.e., 5%LSDs (rather than plot the CIs on cell means). Those CIs are smaller and address the question of interest. Here is a one-way ANOVA: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr)) mm - unique(model.matrix(~ time -1, fr)) cm - mm[1, ] - mm[3, ] cm1 - mm[1, ] - mm[2, ] estimable(fr.lmer, cm = cm, conf.into = 0.95) estimable(fr.lmer, cm = cm1, conf.into = 0.95) plot mean \pm 2* 0.366 and call it a 5%LSD (uncorrected for multiple comparisons) In the case of a more-than-one-way ANOVA with interaction (say 2x2), choose which simple effects are of interest, get SEs for those; and then plot the four points with the CIs. These are not quite right for the difference between simple effects, but I don't know what to do about that. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ On Apr 21, 2008, at 9:05 AM, Dieter Menne wrote: Douglas Bates bates at stat.wisc.edu writes: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) True, but for the notorious error bars in plots that reviewers always request the 0.35 is probable more relevant than the 1.87. Which I think is justified in this case, but in most non-orthogonal designs with three or more factors, where we have a mixture of between/withing subject, there is no clear solution. What to do when required to produce error-bars that reasonably mirror p- values? It's easier with British Journals in the medical field that often have statistical professionals as reviewers, but many American Journals with their amateur physician/statisticians (why no t-test on raw data?) drive me nuts. Dieter #- library(lme4) recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr) summary(fr.lmer) fr.lmer - lmer(rcl ~ time +(1 | subj), fr) summary(fr.lmer) -- Fixed effects: Estimate Std. Error t value time1 11.000 1.879 5.853 time2 13.000 1.879 6.918 time5 14.200 1.879 7.556 Fixed effects: Estimate Std. Error t value (Intercept) 11. 1.8793 5.853 time2 2. 0.3507 5.703 time5 3.2000 0.3507 9.125 [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Equivalent of intervals() in lmer
kedar nadkarni nadkarnikedar at gmail.com writes: I have been trying to obtain confidence intervals for the fit after having used lmer by using intervals(), but this does not work. intervals() is associated with lme but not with lmer(). What is the equivalent for intervals() in lmer()? ci in Gregory Warnes' package gmodels can do this. However, think twice if you really need lmer. Why not lme? It is well documented and has many features that are currently not in lmer. Dieter __ R-help@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.
Re: [R] Equivalent of intervals() in lmer
To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ On Apr 21, 2008, at 2:24 AM, Dieter Menne wrote: kedar nadkarni nadkarnikedar at gmail.com writes: I have been trying to obtain confidence intervals for the fit after having used lmer by using intervals(), but this does not work. intervals() is associated with lme but not with lmer(). What is the equivalent for intervals() in lmer()? ci in Gregory Warnes' package gmodels can do this. However, think twice if you really need lmer. Why not lme? It is well documented and has many features that are currently not in lmer. Dieter [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Equivalent of intervals() in lmer
On 4/21/08, Michael Kubovy [EMAIL PROTECTED] wrote: To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ On Apr 21, 2008, at 2:24 AM, Dieter Menne wrote: kedar nadkarni nadkarnikedar at gmail.com writes: I have been trying to obtain confidence intervals for the fit after having used lmer by using intervals(), but this does not work. intervals() is associated with lme but not with lmer(). What is the equivalent for intervals() in lmer()? ci in Gregory Warnes' package gmodels can do this. However, think twice if you really need lmer. Why not lme? It is well documented and has many features that are currently not in lmer. Dieter [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] Equivalent of intervals() in lmer
Douglas Bates bates at stat.wisc.edu writes: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) True, but for the notorious error bars in plots that reviewers always request the 0.35 is probable more relevant than the 1.87. Which I think is justified in this case, but in most non-orthogonal designs with three or more factors, where we have a mixture of between/withing subject, there is no clear solution. What to do when required to produce error-bars that reasonably mirror p-values? It's easier with British Journals in the medical field that often have statistical professionals as reviewers, but many American Journals with their amateur physician/statisticians (why no t-test on raw data?) drive me nuts. Dieter #- library(lme4) recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) fr.lmer - lmer(rcl ~ time -1 +(1 | subj), fr) summary(fr.lmer) fr.lmer - lmer(rcl ~ time +(1 | subj), fr) summary(fr.lmer) -- Fixed effects: Estimate Std. Error t value time1 11.000 1.879 5.853 time2 13.000 1.879 6.918 time5 14.200 1.879 7.556 Fixed effects: Estimate Std. Error t value (Intercept) 11. 1.8793 5.853 time2 2. 0.3507 5.703 time5 3.2000 0.3507 9.125 __ R-help@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.
Re: [R] Equivalent of intervals() in lmer
Thanks Doug, You write: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) I do just that (which is what Dieter just sent). But the CIs are much too big compared to the CIs for differences between means (which should be bigger than the CIs on the means themselves). If you write the model as ~ 1 - time, then the CIs are roughly of the same (large) size. But I'm really interested in the CIs on the means that capture the variability *within* subjects. I believe that this is what experimentalists in psychology need (and have been debating for a long time what the correct analysis is that produces these error bars). The theory is not about generalizing to people, but generalizing to responses to different situations within people. The article by Brillouin and Riopelle (2005) is the only one that tries to do this within the framework of LMEMs that I know of, and it's couched in terms of SAS. For the moment I wonder if the solution is not to use CIs based on the two low SEs produced by the ~ 1 - time model, and to treat them as least-significant difference intervals. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ On Apr 21, 2008, at 7:56 AM, Douglas Bates wrote: On 4/21/08, Michael Kubovy [EMAIL PROTECTED] wrote: To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:
Re: [R] Equivalent of intervals() in lmer
Sorry, I meant to say: For the moment I wonder if the solution is not to use CIs based on the two low SEs produced by the ~ time model, and to treat them as least-significant difference intervals. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ On Apr 21, 2008, at 9:23 AM, Michael Kubovy wrote: Thanks Doug, You write: If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) I do just that (which is what Dieter just sent). But the CIs are much too big compared to the CIs for differences between means (which should be bigger than the CIs on the means themselves). If you write the model as ~ 1 - time, then the CIs are roughly of the same (large) size. But I'm really interested in the CIs on the means that capture the variability *within* subjects. I believe that this is what experimentalists in psychology need (and have been debating for a long time what the correct analysis is that produces these error bars). The theory is not about generalizing to people, but generalizing to responses to different situations within people. The article by Brillouin and Riopelle (2005) is the only one that tries to do this within the framework of LMEMs that I know of, and it's couched in terms of SAS. For the moment I wonder if the solution is not to use CIs based on the two low SEs produced by the ~ 1 - time model, and to treat them as least-significant difference intervals. On Apr 21, 2008, at 7:56 AM, Douglas Bates wrote: On 4/21/08, Michael Kubovy [EMAIL PROTECTED] wrote: To help Kedar a bit: Here is one way: recall - c(10, 13, 13, 6, 8, 8, 11, 14, 14, 22, 23, 25, 16, 18, 20, 15, 17, 17, 1, 1, 4, 12, 15, 17, 9, 12, 12, 8, 9, 12) fr - data.frame(rcl = recall, time = factor(rep(c(1, 2, 5), 10)), subj = factor(rep(1:10, each = 3))) (fr.lmer - lmer(rcl ~ time + (1 | subj), fr)) require(gmodels) ci(fr.lmer) Now I have a problem to which I would very much appreciate having a solution: The model fr.lmer gives a SE of 1.8793 for the (Intercept) and 0.3507 for the other levels. The reason is that the first took account of the variability of the effect of subjects. Or using simulation: Estimate CI lower CI upper Std. Error p-value (Intercept) 11.107202 6.458765 15.208065 2.1587362 0.004 time22.012064 1.301701 2.795128 0.3743050 0.000 time53.206834 2.502870 3.939791 0.3694384 0.000 Now if I need to draw CI bars around the three means, it seems to me that they should be roughly 11, 13, and 16.2, each \pm 0.75, because I'm trying to estimate the variability of patterns within subjects, and am not interested in the subject to subject variation in the mean for the purposes of prediction. If you want to examine the three means then you should fit the model as lmer(rcl ~ time - 1 + (1 | subj), fr) This what the authors in the paper cited below call on p. 402 a narrow [as opposed to a broad] inference space. My question: ***How do I extract the three narrow CIs from the lmer?*** @ARTICLE{BlouinRiopelle2005, author = {Blouin, David C. and Riopelle, Arthur J.}, title = {On confidence intervals for within-subjects designs}, journal = {Psychological Methods}, year = {2005}, volume = {10}, pages = {397--412}, number = {4}, month = dec, abstract = {Confidence intervals (CIs) for means are frequently advocated as alternatives to null hypothesis significance testing (NHST), for which a common theme in the debate is that conclusions from CIs and NHST should be mutually consistent. The authors examined a class of CIs for which the conclusions are said to be inconsistent with NHST in within- subjects designs and a class for which the conclusions are said to be consistent. The difference between them is a difference in models. In particular, the main issue is that the class for which the conclusions are said to be consistent derives from fixed-effects models with subjects fixed, not mixed models with subjects random. Offered is mixed model methodology that has been popularized in the statistical literature and statistical software procedures. Generalizations to different classes of within-subjects designs are explored, and comments on the future direction of the debate on NHST are offered.}, url = {http://search.epnet.com/login.aspx?direct=truedb=pdhan=met104397 } } On Apr 21, 2008, at 2:24 AM, Dieter Menne wrote: kedar nadkarni nadkarnikedar at gmail.com writes: I have been trying to obtain
[R] Equivalent of intervals() in lmer
Hi all, I have been trying to obtain confidence intervals for the fit after having used lmer by using intervals(), but this does not work. intervals() is associated with lme but not with lmer(). What is the equivalent for intervals() in lmer()? I could not get this information from the documentation. Regards, Kedar [[alternative HTML version deleted]] __ R-help@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.