# [R-sig-ME] Set two coefficients to be equal in lme()

Simon Harmel @|m@h@rme| @end|ng |rom gm@||@com
Sat Jan 16 17:37:00 CET 2021

```Dear James,

Thank you for your answer. I have a follow-up question. In my `dat` dataset
below, "Treat" is coded {-.5, .5}. D1 & D2 are simply dummy coded {0, 1} .

My question is: why when I recode "Treat" as a factor {-.5="C", .5="T"},
then the model fails? Below is a reproducible example:

library(nlme)

"))

model_works <- lme(value ~ 0 + D1 + D2+D1:Treat+D2:Treat, random = ~0 + D1
+ D2 | Student, data = dat)

(dat2 <- transform(dat, Treat = ifelse(Treat==.5,"T", "C")))  # recode
Treat as a factor

model_fails <- lme(value ~ 0 + D1 + D2+D1:Treat+D2:Treat, random = ~0 + D1
+ D2 | Student, data = dat2)

On Sat, Jan 16, 2021 at 12:10 AM Uanhoro, James <
uanhoro.1 using buckeyemail.osu.edu> wrote:

> Dear Simon,
>
> Create a variable that is the sum of D1 * Treat and D2 * Treat and place
> it in the model:
>
> data\$new_var <- (data\$D1 + data\$D2) * data\$Treat
> lme(value ~ 0 + D1 + D2 + new_var, random = ~0 + D1 + D2 | Student, data =
> data)
>
> The coefficient of new_var in the model above is the coefficient for both
> variables if their coefficients were constrained equal.
>
> James.
>
> On Fri, 2021-01-15 at 23:42 -0600, Simon Harmel wrote:
> Dear All,
>
> I was wondering if it might be possible in my below model to set
> "D1:Treat" and "D2:Treat" to be equal?
>
> lme(value ~ 0 + D1 + D2 + D1:Treat + D2:Treat, random = ~0 + D1 + D2 |
> Student, data = data)
>
> Thank you,
> Simon
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org<mailto:R-sig-mixed-models using r-project.org>
> mailing list
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

[[alternative HTML version deleted]]

```