# [R] Surprising Symbolic Model Formula Evaluations

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri Oct 11 20:15:37 CEST 2019

```Rich:

> x <- 1:10
> y <- runif(10)
> lm(y ~ 1:x)

Call:
lm(formula = y ~ 1:x)

Coefficients:
(Intercept)
0.477

> lm(y ~ x:1)

Call:
lm(formula = y ~ x:1)

Coefficients:
(Intercept)
0.477

> lm(y ~ 1*x)

Call:
lm(formula = y ~ 1 * x)

Coefficients:
(Intercept)
0.477

> lm(y ~ x*1)

Call:
lm(formula = y ~ x * 1)

Coefficients:
(Intercept)            x
0.493927    -0.003079

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Oct 11, 2019 at 10:59 AM Richard M. Heiberger <rmh using temple.edu>
wrote:

> I can't duplicate your examples
> This is what I see
> > y ~ 1:x
> y ~ 1:x
>
> Please try again in a vanilla R session, and send a reproducible example.
> vanilla means start R from the operating system command line with
> R --vanilla
>
> this prevents any of your initialization files from being loaded.  See
> ?Startup
> for details.
>
> On Fri, Oct 11, 2019 at 1:05 PM Emi Tanaka <dr.emi.tanaka using gmail.com>
> wrote:
> >
> > Hi,
> >
> > I'm wondering about some logics behind the following simplifications:
> >
> > y ~ 1:x simplifies to y ~ 1
> > y ~ x:1 simplifies to y ~ 1
> > y ~ x*1 simplifies to y ~ x
> > y ~ 1*x simplifies to y ~ 1
> >
> > Mainly I would have expected y ~ 1:x to simplify to y ~ x and the cross
> > operator to be invariant to order.
> >
> > I have some further surprising cases below that I'd also like to know
> more
> > about but just above will also be great.
> >
> > https://rpubs.com/emitanaka/unexpected-formula-eval
> >
> > Best,
> >
> > Emi
> >
> > *Dr. Emi Tanaka* | Lecturer in Statistics
> >
> > Faculty of Science, School of Mathematics and Statistics
> >
> >
> > Secretary, NSW Branch, Statistical Society of Australia
> > <
> https://www.meetup.com/NSW-Branch-of-the-Statistics-Society-of-Australia/>
> >
> > Social Media Coordinator, Central, International Biometrics Society
> >
> >
> > *THE UNIVERSITY OF SYDNEY*
> > 827, Carslaw F07 | The University of Sydney | NSW | 2006
> > *Phone:* +61 2 9351 3039
> > *Website:* * <http://sydney.edu.au/>*https://emitanaka.github.io/
> >
> > CRICOS 00026A
> > This email plus any attachments to it are confidential.
> > Any unauthorised use is strictly prohibited. If you receive this email in
> > error, please delete it and any attachments. Please think of our
> > environment and only print this e-mail if necessary.
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help