1

My code looks like this:

Endo.v.Mass_Extant_Stages<-gls(log.Endo~log.Mb+Stage, data = CrocOntogenyData)

My results change based on whether I'm using a +,*, or : between log.Mb (continuous) and Stage (categorical). Does anyone actually know what these operators are doing? I can't seem to find anything on it.

Arthur Erb
  • 21
  • 1

1 Answers1

2

Models in R have a special syntax described here (you can also type help(formula) into R). They aren't only used in the gls function (lm also uses them, for instance).

Z ~ x + y corresponds to the mathematical formula "z = ax + by + c" for every x and y value, for some constants a, b, c.

Z ~ x * y corresponds to the mathematical formula "z = ax + by + cxy + d" for every x and y value, for some constants a, b, c, d.

Z ~ x / y corresponds to the mathematical formula "z = ax + bxy + c" for every x and y value, for some constants a, b, c.

Z ~ x:y corresponds to the mathematical formula "z = axy" for every x and y value, for some constant a.

See this Stack Exchange post for more information

luke
  • 465
  • 1
  • 14
  • 1
    Your link to the help page is helpful, but your summary is wrong. For example, `Z ~ x + y` means `E(Z) = a x + b y + c` for some `a`, `b` and `c` when `x` and `y` are continuous. – user2554330 Jun 27 '22 at 15:30
  • 1
    That's better. Still, if `x` or `y` is a factor, things are different: e.g. instead of `ax`, you'd use `a_x` (i.e. `a[x]`) with a different constant for each `x` value. – user2554330 Jun 28 '22 at 14:51