Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

how put kernel matrix in a diagonal of a matrix?

$
0
0

I have a data set with 9200 rows and 6 columns. I found the kernel of this data frame with the following code:

  #kernel
  library("kernlab", "v0.9-27")
  D<-as.matrix(X1)
  rbf <- rbfdot(sigma = 0.05)
  kernel<-kernelMatrix(rbf, D)

Now I want to put this as a diagonal of a square matrix. for example suppose kernel matrix is

    K11  k12
    k21  k22

I need a matrix like

    K11  k12   0    0    0    0    0    0
    k21  k22   0    0    0    0    0    0
    0     0   K11  k12   0    0    0    0
    0     0   k21  k22   0    0    0    0
    0     0    0    0   K11  k12   0    0
    0     0    0    0   K21  k22   0    0
    0     0    0    0    0    0    K11  k12
    0     0    0    0    0    0    K21  k22

Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>