Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R?
What is the equivalent of column.prods() from S in R?
7 messages · Peng Yu, David Winsemius, William Dunlap
On Nov 9, 2009, at 8:43 PM, Peng Yu wrote:
Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R?
??rowProds ??colProds (They are in both fUtilities and timeSeries.) -- David Winsemius, MD Heritage Laboratories West Hartford, CT
19 days later
On Mon, Nov 9, 2009 at 8:35 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Nov 9, 2009, at 8:43 PM, Peng Yu wrote:
Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R?
??rowProds ??colProds (They are in both fUtilities and timeSeries.)
Are you sure that colProds() is equivalent to column.prods()? It seems that column.prods() should be a very basic function in S, but I have to load a package in order to call colProds(). I don't see how to construct a matrix give terms as mentioned in the book. Would you please give me some examples?
On Nov 28, 2009, at 11:28 PM, Peng Yu wrote:
On Mon, Nov 9, 2009 at 8:35 PM, David Winsemius <dwinsemius at comcast.net
wrote: On Nov 9, 2009, at 8:43 PM, Peng Yu wrote:
Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R?
??rowProds ??colProds (They are in both fUtilities and timeSeries.)
Are you sure that colProds() is equivalent to column.prods()? It seems that column.prods() should be a very basic function in S, but I have to load a package in order to call colProds(). I don't see how to construct a matrix give terms as mentioned in the book. Would you please give me some examples?
Page numbers? Specifics? ....something to go on?
______________________________________________ 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
On Sat, Nov 28, 2009 at 11:00 PM, David Winsemius
<dwinsemius at comcast.net> wrote:
On Nov 28, 2009, at 11:28 PM, Peng Yu wrote:
On Mon, Nov 9, 2009 at 8:35 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Nov 9, 2009, at 8:43 PM, Peng Yu wrote:
Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R?
??rowProds ??colProds (They are in both fUtilities and timeSeries.)
Are you sure that colProds() is equivalent to column.prods()? It seems that column.prods() should be a very basic function in S, but I have to load a package in order to call colProds(). I don't see how to construct a matrix give terms as mentioned in the book. Would you please give me some examples?
Page numbers? Specifics? ....something to go on?
As is mentioned in the appendix of the book, it is on page 38.
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Peng Yu Sent: Saturday, November 28, 2009 8:29 PM To: r-help at stat.math.ethz.ch Subject: Re: [R] What is the equivalent of column.prods() from S in R? On Mon, Nov 9, 2009 at 8:35 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Nov 9, 2009, at 8:43 PM, Peng Yu wrote:
Chambers' book Statistical Models in S mentioned
'column.prods()'. But
I don't find it in R. I'm wondering if there is an equivalent in R?
??rowProds ??colProds (They are in both fUtilities and timeSeries.)
Are you sure that colProds() is equivalent to column.prods()? It seems that column.prods() should be a very basic function in S, but I have to load a package in order to call colProds(). I don't see how to construct a matrix give terms as mentioned in the book. Would you please give me some examples?
S's and S+'s column.prods(x1,x2), where nrow(x1)==nrow(x2),
returns the nrow(x1) row by ncol(x1)*ncol(x2) column matrix
containing the products of all pairs of columns
from x1 and x2, respectively. The column names are set to
reflect which columns in x1 and x2 the products come from.
E.g., one can use it to compute the interaction colunns
in a model matrix:
> x1<-cbind(one=c(1,0,0),two=c(0,1,0))
> x2<-cbind(A=c(11,12,13), B=c(101,105,111))
> column.prods(x1,x2)
oneA twoA oneB twoB
[1,] 11 0 101 0
[2,] 0 12 0 105
[3,] 0 0 0 0
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
______________________________________________ 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.
On Nov 29, 2009, at 12:20 AM, Peng Yu wrote:
On Sat, Nov 28, 2009 at 11:00 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Nov 28, 2009, at 11:28 PM, Peng Yu wrote:
On Mon, Nov 9, 2009 at 8:35 PM, David Winsemius <dwinsemius at comcast.net
wrote:
On Nov 9, 2009, at 8:43 PM, Peng Yu wrote:
Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R?
??rowProds ??colProds (They are in both fUtilities and timeSeries.)
Are you sure that colProds() is equivalent to column.prods()? It seems that column.prods() should be a very basic function in S, but I have to load a package in order to call colProds(). I don't see how to construct a matrix give terms as mentioned in the book. Would you please give me some examples?
Page numbers? Specifics? ....something to go on?
As is mentioned in the appendix of the book, it is on page 38.
It's a chapter on the internal representation of models. So, no, I
agree, the colProds function does not do what column.prods did in S
which was to represent interaction terms. The terms.object help page
says these are different than in S. I suspect that the function you
want is model.matrix. An example with from its help page:
dd <- data.frame(a = gl(3,4), b = gl(4,1,12))# balanced 2-way
options("contrasts")
model.matrix( ~ a + b, dd)
# and then the "product" design matrix
model.matrix( ~ a * b, dd)
David Winsemius, MD Heritage Laboratories West Hartford, CT