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
lm() notation question
6 messages · Ista Zahn, David Winsemius, Carl Witthoft +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091129/026c808f/attachment-0001.pl>
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:
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
______________________________________________ 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.
Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
On Nov 29, 2009, at 11:46 AM, Carl Witthoft wrote:
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?
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 "~."
I couldn't find any such example in the lm() or formula() help pages. thanks Carl
______________________________________________ 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.
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:
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:
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
______________________________________________ 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091129/5763b0a9/attachment-0001.pl>