Once you get your matrices in order you do not want to use t(X) %*% X. Instead, use crossprod(X). They do the same thing, but the former is the matrix operations based on the algebraic representation whereas numerical analysts will prefer the methods used in crossprod (hence the reason it exists).
-----Original Message----- From: [EMAIL PROTECTED] on behalf of Duncan Murdoch Sent: Fri 7/18/2008 1:00 AM To: Murali K Cc: r-help@r-project.org Subject: Re: [R] matrix multiplication question On 17/07/2008 9:47 PM, Murali K wrote: > Hello, > I am a newcomer to R and therefore apologize for posting such a > basic question. I am > trying to multiply 2 matrices t(X1)%*%X1, where t(X1) is: It's hard to say for sure, but it looks as though X1 really isn't a numeric matrix. The "ones" and "Shadow" entries on the left look like character or factor data. To find out what X1 is, you can run str(X1). Duncan Murdoch > > > 1 2 3 4 5 8 12 13 20 24 26 27 31 33 34 36 37 40 41 42 45 46 > 47 48 49 > ones 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 > Shadow 0 1 1 1 1 1 1 1 0 1 1 1 1 0 1 0 1 0 1 1 > 0 1 0 1 0 > > However, when I try to perform this operation, I obtain: > Error in t(X1) %*% X1 : requires numeric matrix/vector arguments > > Can someone please tell me what I seem to be doing wrong? thanks. > > Sincerely, > Murali Kuchibhotla > > > Murali Kuchibhotla > Department of Economics > Iowa State University > Office:75,Heady > Phone:515-294-5452 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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. [[alternative HTML version deleted]] ______________________________________________ R-help@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.