Problem with the Kronecker product of a big matrix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with the Kronecker product of a big matrix

Sophia90
This post has NOT been accepted by the mailing list yet.
Hi guys!
I'm a new user of r. I have to calculate the Kronecker product of a matrix 20x20 that are flows of good in the same origins and destinations. Then I have another matrix 3x20 in which there are my 20 destinations/origins linked in 3 variables that are gdp, population and km-highway.
I really don't know how to start with the code of Kronecker. I have an example of my teacher but I tried to do it and it didn't work.
orig = kronecker(matrix(1, length(unique(determinants[, 2])), 1), as.matrix(determinants[determinants$Year == i, -c(1:2)]))
                colnames(orig) = sapply(colnames(determinants)[-c(1:2)], newnames_o)
                dest = kronecker(as.matrix(determinants[determinants$Year == i, -c(1:2)]), matrix(1, length(unique(determinants[, 2])), 1))
                colnames(dest) = sapply(colnames(determinants)[-c(1:2)], newnames_d)
                fulldata = cbind(orig, dest)
                colnames(fulldata) = c(colnames(orig), colnames(dest))
In this code the "determinants and years" are some variables that he created.
Can someone help me? :)
thank you in advance!