[R] Some questions about R's modelling algebra

Kingsford Jones kingsfordjones at gmail.com
Mon Jul 5 21:43:51 CEST 2010


On Fri, Jul 2, 2010 at 8:16 AM, Hadley Wickham <hadley at rice.edu> wrote:
>> ?formula in R 2.9.2 says in para 2:
>> "The %in% operator indicates that the terms on its left are nested
>> within those on the right. For example a + b %in% a expands to the
>> formula a + a:b. "
>
> Ooops, missed that.  So b %in% a = a:b, and that's what's meant by
> "different coding".

Or would this be true only if "b %in% a" was preceded by "a"?

attr(terms(y ~ B %in% A), 'term.labels')
#[1] "B:A"
attr(terms(y ~ B + B %in% A), 'term.labels')
#[1] "B"   "B:A"
attr(terms(y ~ A + B %in% A), 'term.labels')
#[1] "A"   "A:B"

suggesting a documentation buglet in Sec 11.1 of An Introduction to R,
where it states:

\begin{quote}
y ~ A*B
y ~ A + B + A:B
y ~ B %in% A
y ~ A/B
    Two factor non-additive model of y on A and B. The first two
specify the same crossed classification and the second two specify the
same nested classification. In abstract terms all four specify the
same model subspace.
\end{quote}

I think "y ~ B %in% A"  should be changed to "y ~ A + B %in% A" since

attr(terms(y ~ A/B), 'term.labels')
#[1] "A"   "A:B"

Or am I missing something?

Kingsford


>
> Hadley
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list