Skip to content

lm() notation question

6 messages · Ista Zahn, David Winsemius, Carl Witthoft +1 more

#
Hi,
A recent thread provided a (working) construct for lm:

lm(as.matrix(freeny[ix]) ~., freeny[-ix])


Can someone explain what is meant by the formula in that expression,
that is,  what does "mymatrix~."  do?  I couldn't find any such example 
in the lm() or formula() help pages.

thanks
Carl
#
The help page for lm says:

"If ?response? is a matrix a linear model is fitted separately by
     least-squares to each column of the matrix."

-Ista
On Sun, Nov 29, 2009 at 11:46 AM, Carl Witthoft <carl at witthoft.com> wrote:

  
    
#
On Nov 29, 2009, at 11:46 AM, Carl Witthoft wrote:

            
It doesn't say my matrix, it says as.matrix, and that is because  
freeny[iz] is most probably a dataframe.

The lm function is capable of doing manova when given a matrix on the  
LHS of the formula:

http://www.r-project.org/doc/Rnews/Rnews_2007-2.pdf   see page 2 and  
onward of Dalgaard's article.

Toward the end of the Details section of formula help page (easily  
accessed with a click from the lm help page) you will find the  
explanation for the  "~."
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
As others helpfully pointed out, the meaning of "." in a formula is 
provided in the Details section of ?formula.  (But NOT in ?lm)
Ista Zahn wrote: