Discussion:
[R-sig-ME] (no subject)
Peter Paprzycki
2018-08-02 03:30:15 UTC
Permalink
This is very basic, is there a way to specify in lmer function that I would
like to run my grouping variable as a fixed factor only, without reverting
to lm or plm functions. If one does not specify a random variable, one gets
the error message with lmer function; something that is equivalent to the
statement, "index = "grouping variable", model = "within"" with the plm
function.

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[[alternative HTML version deleted]]
Ben Bolker
2018-08-02 03:57:38 UTC
Permalink
(please keep r-sig-mixed-models in the Cc:)

I'm pretty sure that lmer and lm models are commensurate, in case that
helps. Here's an example rigged to make the random-effects variance
equal to zero, so we can check that the log-likelihoods etc. are identical.

set.seed(101)
dd <- data.frame(y=rnorm(20),x=rnorm(20),f=factor(rep(1:2,10)))
library(lme4)
m1 <- lmer(y~x+(1|f),data=dd,REML=FALSE) ## estimated sigma^2_f=0
m2 <- lm(y~x,data=dd)
all.equal(c(logLik(m1)),c(logLik(m2))) ## TRUE
all.equal(fixef(m1),coef(m2))
anova(m1,m2)
Thank you. Oh, was just trying to compare my random-effects model to the
one where my grouping variable (schools) is treated as fixed.
Peter
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
  I'm not 100% sure I understand the question, but I think the answer is
"no": lmer cannot fit a model that doesn't contain any random effects.
Perhaps you can give more context as to why it won't work for you to
revert to lm() or plm() in these cases?
Post by Peter Paprzycki
This is very basic, is there a way to specify in lmer function
that I would
Post by Peter Paprzycki
like to run my grouping variable as a fixed factor only, without
reverting
Post by Peter Paprzycki
to lm or plm functions. If one does not specify a random variable,
one gets
Post by Peter Paprzycki
the error message with lmer function; something that is equivalent
to the
Post by Peter Paprzycki
statement, "index = "grouping variable", model = "within"" with
the plm
Post by Peter Paprzycki
function.
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>>
Post by Peter Paprzycki
Virus-free.
www.avg.com <http://www.avg.com>
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>>
Post by Peter Paprzycki
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
       [[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
<https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
Peter Paprzycki
2018-08-02 04:08:10 UTC
Permalink
Perfect. Thank you. It is good to know that we can specify the
random-effects variance
equal to zero. Thanks.
Peter

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Post by Ben Bolker
(please keep r-sig-mixed-models in the Cc:)
I'm pretty sure that lmer and lm models are commensurate, in case that
helps. Here's an example rigged to make the random-effects variance
equal to zero, so we can check that the log-likelihoods etc. are identical.
set.seed(101)
dd <- data.frame(y=rnorm(20),x=rnorm(20),f=factor(rep(1:2,10)))
library(lme4)
m1 <- lmer(y~x+(1|f),data=dd,REML=FALSE) ## estimated sigma^2_f=0
m2 <- lm(y~x,data=dd)
all.equal(c(logLik(m1)),c(logLik(m2))) ## TRUE
all.equal(fixef(m1),coef(m2))
anova(m1,m2)
Thank you. Oh, was just trying to compare my random-effects model to the
one where my grouping variable (schools) is treated as fixed.
Peter
<http://www.avg.com/email-signature?utm_medium=email&
utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&
utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
I'm not 100% sure I understand the question, but I think the
answer is
"no": lmer cannot fit a model that doesn't contain any random
effects.
Perhaps you can give more context as to why it won't work for you to
revert to lm() or plm() in these cases?
Post by Peter Paprzycki
This is very basic, is there a way to specify in lmer function
that I would
Post by Peter Paprzycki
like to run my grouping variable as a fixed factor only, without
reverting
Post by Peter Paprzycki
to lm or plm functions. If one does not specify a random variable,
one gets
Post by Peter Paprzycki
the error message with lmer function; something that is equivalent
to the
Post by Peter Paprzycki
statement, "index = "grouping variable", model = "within"" with
the plm
Post by Peter Paprzycki
function.
<http://www.avg.com/email-signature?utm_medium=email&
utm_source=link&utm_campaign=sig-email&utm_content=webmail
<http://www.avg.com/email-signature?utm_medium=email&
utm_source=link&utm_campaign=sig-email&utm_content=webmail>>
Post by Peter Paprzycki
Virus-free.
www.avg.com <http://www.avg.com>
<http://www.avg.com/email-signature?utm_medium=email&
utm_source=link&utm_campaign=sig-email&utm_content=webmail
<http://www.avg.com/email-signature?utm_medium=email&
utm_source=link&utm_campaign=sig-email&utm_content=webmail>>
Post by Peter Paprzycki
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
<https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager

Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
email: ***@usm.edu


Sidere mens eadum mutato

[[alternative HTML version deleted]]
Peter Paprzycki
2018-08-02 04:24:10 UTC
Permalink
Sorry, you estimated it to be very close to zero, I see.
Peter
Post by Peter Paprzycki
Perfect. Thank you. It is good to know that we can specify the
random-effects variance
equal to zero. Thanks.
Peter
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_981606773260833816_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Post by Ben Bolker
(please keep r-sig-mixed-models in the Cc:)
I'm pretty sure that lmer and lm models are commensurate, in case that
helps. Here's an example rigged to make the random-effects variance
equal to zero, so we can check that the log-likelihoods etc. are identical.
set.seed(101)
dd <- data.frame(y=rnorm(20),x=rnorm(20),f=factor(rep(1:2,10)))
library(lme4)
m1 <- lmer(y~x+(1|f),data=dd,REML=FALSE) ## estimated sigma^2_f=0
m2 <- lm(y~x,data=dd)
all.equal(c(logLik(m1)),c(logLik(m2))) ## TRUE
all.equal(fixef(m1),coef(m2))
anova(m1,m2)
Thank you. Oh, was just trying to compare my random-effects model to the
one where my grouping variable (schools) is treated as fixed.
Peter
<http://www.avg.com/email-signature?utm_medium=email&utm_
source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free. www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_
source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
I'm not 100% sure I understand the question, but I think the
answer is
"no": lmer cannot fit a model that doesn't contain any random
effects.
Perhaps you can give more context as to why it won't work for you to
revert to lm() or plm() in these cases?
Post by Peter Paprzycki
This is very basic, is there a way to specify in lmer function
that I would
Post by Peter Paprzycki
like to run my grouping variable as a fixed factor only, without
reverting
Post by Peter Paprzycki
to lm or plm functions. If one does not specify a random variable,
one gets
Post by Peter Paprzycki
the error message with lmer function; something that is equivalent
to the
Post by Peter Paprzycki
statement, "index = "grouping variable", model = "within"" with
the plm
Post by Peter Paprzycki
function.
<http://www.avg.com/email-signature?utm_medium=email&utm_
source=link&utm_campaign=sig-email&utm_content=webmail
<http://www.avg.com/email-signature?utm_medium=email&utm_
source=link&utm_campaign=sig-email&utm_content=webmail>>
Post by Peter Paprzycki
Virus-free.
www.avg.com <http://www.avg.com>
<http://www.avg.com/email-signature?utm_medium=email&utm_
source=link&utm_campaign=sig-email&utm_content=webmail
<http://www.avg.com/email-signature?utm_medium=email&utm_
source=link&utm_campaign=sig-email&utm_content=webmail>>
Post by Peter Paprzycki
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
<https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager

Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
email: ***@usm.edu


Sidere mens eadum mutato

[[alternative HTML version deleted]]
Ben Bolker
2018-08-02 05:26:27 UTC
Permalink
Yes. I think you can specify a fixed residual variance in blme::blmer, but
not to exactly zero.
Post by Peter Paprzycki
Sorry, you estimated it to be very close to zero, I see.
Peter
On Wed, Aug 1, 2018 at 11:08 PM, Peter Paprzycki <
Post by Peter Paprzycki
Perfect. Thank you. It is good to know that we can specify the
random-effects variance
equal to zero. Thanks.
Peter
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_3076315220315282584_m_981606773260833816_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Post by Ben Bolker
(please keep r-sig-mixed-models in the Cc:)
I'm pretty sure that lmer and lm models are commensurate, in case that
helps. Here's an example rigged to make the random-effects variance
equal to zero, so we can check that the log-likelihoods etc. are identical.
set.seed(101)
dd <- data.frame(y=rnorm(20),x=rnorm(20),f=factor(rep(1:2,10)))
library(lme4)
m1 <- lmer(y~x+(1|f),data=dd,REML=FALSE) ## estimated sigma^2_f=0
m2 <- lm(y~x,data=dd)
all.equal(c(logLik(m1)),c(logLik(m2))) ## TRUE
all.equal(fixef(m1),coef(m2))
anova(m1,m2)
Thank you. Oh, was just trying to compare my random-effects model to
the
one where my grouping variable (schools) is treated as fixed.
Peter
<
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Virus-free. www.avg.com
<
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
I'm not 100% sure I understand the question, but I think the
answer is
"no": lmer cannot fit a model that doesn't contain any random
effects.
Perhaps you can give more context as to why it won't work for you
to
revert to lm() or plm() in these cases?
Post by Peter Paprzycki
This is very basic, is there a way to specify in lmer function
that I would
Post by Peter Paprzycki
like to run my grouping variable as a fixed factor only, without
reverting
Post by Peter Paprzycki
to lm or plm functions. If one does not specify a random
variable,
one gets
Post by Peter Paprzycki
the error message with lmer function; something that is
equivalent
to the
Post by Peter Paprzycki
statement, "index = "grouping variable", model = "within"" with
the plm
Post by Peter Paprzycki
function.
<
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Post by Peter Paprzycki
Virus-free.
www.avg.com <http://www.avg.com>
<
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Post by Peter Paprzycki
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
<https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager
Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
Sidere mens eadum mutato
[[alternative HTML version deleted]]
Martin Maechler
2018-08-02 06:53:59 UTC
Permalink
Post by Ben Bolker
Post by Peter Paprzycki
Post by Ben Bolker
I'm pretty sure that lmer and lm models are commensurate, in case that
helps. Here's an example rigged to make the random-effects variance
equal to zero, so we can check that the log-likelihoods etc. are identical.
set.seed(101)
dd <- data.frame(y=rnorm(20),x=rnorm(20),f=factor(rep(1:2,10)))
library(lme4)
m1 <- lmer(y~x+(1|f),data=dd,REML=FALSE) ## estimated sigma^2_f=0
m2 <- lm(y~x,data=dd)
all.equal(c(logLik(m1)),c(logLik(m2))) ## TRUE
all.equal(fixef(m1),coef(m2))
anova(m1,m2)
Then, Peter replied
Post by Ben Bolker
Post by Peter Paprzycki
Sorry, you estimated it to be very close to zero, I see.
Peter
Yes. I think you can specify a fixed residual variance in blme::blmer, but
not to exactly zero.
Peter: it is estimated to be *exactly* zero, not just close to
Post by Ben Bolker
VarCorr(m1)$f == 0
(Intercept)
(Intercept) TRUE
(yes, these are always matrices, here of dimension 1x1)

This has been one of the major features of lme4::lmer() wrt to nlme::lme()
that \hat{\sigma_j^2} = 0 is naturally possible
because of the parametrization used.

Martin
Peter Paprzycki
2018-08-02 21:47:08 UTC
Permalink
Thank you, Martin.
Peter

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Post by Martin Maechler
Post by Ben Bolker
Post by Peter Paprzycki
Post by Ben Bolker
I'm pretty sure that lmer and lm models are commensurate, in case that
helps. Here's an example rigged to make the random-effects variance
equal to zero, so we can check that the log-likelihoods etc. are identical.
set.seed(101)
dd <- data.frame(y=rnorm(20),x=rnorm(20),f=factor(rep(1:2,10)))
library(lme4)
m1 <- lmer(y~x+(1|f),data=dd,REML=FALSE) ## estimated sigma^2_f=0
m2 <- lm(y~x,data=dd)
all.equal(c(logLik(m1)),c(logLik(m2))) ## TRUE
all.equal(fixef(m1),coef(m2))
anova(m1,m2)
Then, Peter replied
Post by Ben Bolker
Post by Peter Paprzycki
Sorry, you estimated it to be very close to zero, I see.
Peter
Yes. I think you can specify a fixed residual variance in
blme::blmer, but
Post by Ben Bolker
not to exactly zero.
Peter: it is estimated to be *exactly* zero, not just close to
Post by Ben Bolker
VarCorr(m1)$f == 0
(Intercept)
(Intercept) TRUE
(yes, these are always matrices, here of dimension 1x1)
This has been one of the major features of lme4::lmer() wrt to nlme::lme()
that \hat{\sigma_j^2} = 0 is naturally possible
because of the parametrization used.
Martin
--
Peter Paprzycki, Ph.D.
Visiting Assistant Professor
Research Support Center Manager

Educational Research and Administration
College of Education and Psychology
The University of Southern Mississippi
USM Box 5093; 118 College Drive
Hattiesburg, Mississippi 39406-0001
tel. (601)-266-4708
email: ***@usm.edu


Sidere mens eadum mutato

[[alternative HTML version deleted]]
Loading...