[R-sig-ME] equality constraints in lmer/lme4
David Winsemius
dwinsemius at comcast.net
Mon Oct 21 23:21:35 CEST 2013
On Oct 21, 2013, at 1:58 PM, Greg Snow wrote:
> No, think about the algebra, if we start with:
>
> y = b0 + b1*x1 + b2*x2 + ...
>
> then the constraint that b1 = b2 gives us:
>
> y = b0 + b1*x1 + b1*x2 + ...
>
> then factoring:
>
> y = b0 + b1*(x1 + x2) + ...
>
> Or we can demonstrate with a basic simulation example (here the true
> common slope is 2):
>
>> x1 <- rnorm(100, 10, 3)
>> x2 <- rnorm(100, 100, 5)
>> y <- 2*x1 + 2*x2 + rnorm(100,0,1)
>> lm(y ~ x1 + x2)
>
Thanks, Greg. I get it.
I guess I'm more concrete in my thinking. I needed to see it prove experimentally. I just wasn't willing to accept it on the basis of "factoring" a formula, since there are some rather non-mathematical evaluation steps involved in the interpretation of "*" in R formulas.
--
David.
> Call:
> lm(formula = y ~ x1 + x2)
>
> Coefficients:
> (Intercept) x1 x2
> -1.862 2.034 2.015
>
>> lm( y ~ I(x1+x2) )
>
> Call:
> lm(formula = y ~ I(x1 + x2))
>
> Coefficients:
> (Intercept) I(x1 + x2)
> -2.282 2.021
>
>> lm( y ~ I( (x1+x2)/2 ) )
>
> Call:
> lm(formula = y ~ I((x1 + x2)/2))
>
> Coefficients:
> (Intercept) I((x1 + x2)/2)
> -2.282 4.041
>
> So you can see the averaging is not needed (or you could average, but
> then you would need to multiply by 2 because we are going to make
> predictions based on b1*x1+b1*x2, so the 2's would cancel).
>
> This is just linear regression, but the concept should hold for lme as
> well (if you want more convincing, simulate an lme style problem and
> try it).
>
> On Mon, Oct 21, 2013 at 1:46 PM, David Winsemius <dwinsemius at comcast.net> wrote:
>>
>> On Oct 21, 2013, at 10:44 AM, Greg Snow wrote:
>>
>>> If X1 and X2 are both numeric variables then
>>>
>>> Outcome ~ I( X1 + X2 ) + (1|Subject)
>>
>> Would that be:
>>
>> Outcome ~ I( (X1 + X2)/2 ) + (1|Subject) # ?
>>
>> --
>> David.
>>
>>
>>>
>>> should give you what you need.
>>>
>>> If both are categorical, then you need to create a set of variables
>>> that represent the combination (make sure that you understand what
>>> that combination represents).
>>>
>>> On Sun, Oct 20, 2013 at 7:52 PM, Jean-Philippe Laurenceau
>>> <jlaurenceau at psych.udel.edu> wrote:
>>>> Dear R-sig-ME list--
>>>>
>>>> When specifying the following lmer model, I get intercept fixed and random effects, a fixed effect for the X1 predictor, and a fixed effect for the X2 predictor.
>>>>
>>>> fm <- lmer ( Outcome ~ X1 + X2 + ( 1 | Subject ), data = mydata)
>>>>
>>>> My question: is there a way to ask lme4 to re-estimate this model but set an equality constraint on the effects of X1 and X2, such that their estimates would be equal to each other?
>>>>
>>>> Thanks for your time, J-P
>>>>
>>>> Jean-Philippe Laurenceau, Ph.D.
>>>> Department of Psychology
>>>> University of Delaware
>>>>
>>>> [[alternative HTML version deleted]]
>>>>
>>>> _______________________________________________
>>>> R-sig-mixed-models at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>>
>>>
>>>
>>> --
>>> Gregory (Greg) L. Snow Ph.D.
>>> 538280 at gmail.com
>>>
>>> _______________________________________________
>>> R-sig-mixed-models at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>> David Winsemius
>> Alameda, CA, USA
>>
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538280 at gmail.com
David Winsemius
Alameda, CA, USA
More information about the R-sig-mixed-models
mailing list