I am trying to carry out the product between two multi dimensional tables,
e.g. A with dim = c(2,2,3,4) and B with dim = c(2,3,4). So, I want to outer
multiply each 3x4 table in A[i,j,,] with B[k,,] to get a table C of dim =
This arises in scenario of conditional probability tables. A could be a
table taking probability values for different values of variables s,t,u,v
and B taking values for different values of variables t,p,q. I want to get a
table of factor (different from the factor in R) got by multiplying these
two CPTs. The new table C will have dimensions (variables) s,t,u,v,p,q as a
result of product of these two.
I am looking at the apply() method as an aid to get this done. But, it seems
that I can't get a multidimensional output by applying any FUN funtion in
apply(X, MARGIN, FUN, ...). for instance a outer product of two vectors
gives back another vector and not a 2 dimensional array.
So, any thoughts on this? Any other place I should be looking at?