Skip to content

Creating the mean using algebra matrix

5 messages · flokke, David Winsemius, Timothy Bates +1 more

#
Dear all, 
I wanted to create the mean using a algebra matrix. 
so I tried this one:
(Calculates the matrix multiplication of the new3 * factorial).

But I get the following error message: 

Error in new3 %*% factorial : non-conformable arguments

These are my matrices:
[,1]   [,2]
 [1,]     1.350    8.1
 [2,]   465.000  423.0
 [3,]    36.330  119.5
 [4,]    27.660  115.0
 [5,]     1.040    5.5
 [6,] 11700.000   50.0
 [7,]  2547.000 4603.0
 [8,]   187.100  419.0
 [9,]   521.000  655.0
[10,]    10.000  115.0
[11,]     3.300   25.6
[12,]   529.000  680.0
[13,]   207.000  406.0
[14,]    62.000 1320.0
[15,]  6654.000 5712.0
[16,]  9400.000   70.0
[17,]     6.800  179.0
[18,]    35.000   56.0
[19,]     0.120    1.0
[20,]     0.023    0.4
[21,]     2.500   12.1
[22,]    55.500  175.0
[23,]   100.000  157.0
[24,]    52.160  440.0
[25,]     0.280    1.9
[26,] 87000.000  154.5
[27,]     0.122    3.0
[28,]   192.000  180.0
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[,14] [,15] [,16] [,17]
[1,]    1    1    1    1    1    1    1    1    1     1     1     1     1    
1     1     1     1
     [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28]
[1,]     1     1     1     1     1     1     1     1     1     1     1


Can anyone help me out of this?

Cheers, maria

--
View this message in context: http://r.789695.n4.nabble.com/Creating-the-mean-using-algebra-matrix-tp3895378p3895378.html
Sent from the R help mailing list archive at Nabble.com.
#
On Oct 11, 2011, at 1:45 PM, flokke wrote:

            
You probably want to transpose `factorial`. I don't understand how the  
result would be particularly interesting, however.
#
To do matrix multiplication: m x n, the Rows and columns of  m must be equal to the columns and rows of n, respectively. 


Sent from my iPhone
On 11 Oct 2011, at 06:45 PM, flokke <ingaschwabe at gmail.com> wrote:

            
#
On 12/10/11 08:31, Timothy Bates wrote:
No.  The number of columns of m must equal the number of rows of n,
that's all.  The number of *rows* of m and the number of *columns* of n
can be anything you like.

     cheers,

         Rolf Turner
#
On Oct 12, 2011, at 12:04 AM, Rolf Turner wrote:
Yes, I don't know how I wrote that.. conflating criteria for conformability with the shape of the output,,, 

The easiest way to remember this is to visualize the dimensions of the two matrices side by side:

R1 C1 %*% R2 C2

The adjacent numbers must match (C1 & R2)

The resultant matrix will have dimensions of the outside numbers (R1 C2). 

i.e., 
A = matrix(1:4,nrow=1); B = matrix(1:4,ncol=1); A; B; A %*% B; B %*% A
A
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
B
     [,1]
[1,]    1
[2,]    2
[3,]    3
[4,]    4
A %*% B
     [,1]
[1,]   30
B %*% A
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    2    4    6    8
[3,]    3    6    9   12
[4,]    4    8   12   16