Hi,
I am trying to work with the output of the MINE analysis routine found at
   http://www.exploredata.net

Specifically, I am trying to read the results into a matrix (ideally an 
n x n x 6 matrix, but I'll settle right now for getting one column into 
a matrix.)

The problem I have is not knowing how to take what amounts to being one 
half of a symmetric matrix - excluding the diagonal - and getting it 
into a matrix.  I have tried using "lower.tri" as found here
   https://stat.ethz.ch/pipermail/r-help/2008-September/174516.html
but it appears to only partially fill in the matrix.  My code and an 
example of the output is below.  Can anyone point me to an example that 
shows how to create a matrix with this sort of input?

Thank you in advance,
Matt

require(PortfolioAnalytics)
#load market index data
data(indexes)
#save data as a CSV
write.table(indexes, "C:/Rwork/indexes.csv", sep=",", col.names=TRUE,
   row.names=FALSE, quote=FALSE, na="NA")
#assumes rJava is installed, MINE.r and MINE.jar are in the working 
directory
#read in MINE.r
source.with.encoding('C:/Rwork/MINE.r', encoding='UTF-8')
#run MINE on indexes
MINE("C:/Rwork/indexes.csv","all.pairs")
#read the output file of MINE analysis
x=read.csv("C:/Rwork/indexes.csv,B=n^0.6,k=15,Results.csv",header=TRUE)
#isolate one half of matrix
newx<-x[,1:3]
newx
             X.var          Y.var MIC..strength.
1     US.Equities Int.l.Equities        0.33740
2        US.Bonds       US.Tbill        0.26657
3        US.Tbill      Inflation        0.23388
4     Commodities      Inflation        0.23122
5     Commodities       US.Tbill        0.21476
6     US.Equities       US.Tbill        0.20829
7        US.Bonds      Inflation        0.20486
8  Int.l.Equities    Commodities        0.19439
9        US.Bonds    Commodities        0.19237
10    US.Equities    Commodities        0.18633
11       US.Bonds    US.Equities        0.17298
12    US.Equities      Inflation        0.17174
13 Int.l.Equities       US.Tbill        0.16822
14       US.Bonds Int.l.Equities        0.16480
15 Int.l.Equities      Inflation        0.15027

#v<-newx[,3]
#or, for the sake of this example
v<-c(0.33740, 0.26657, 0.23388, 0.23122, 0.21476, 0.20829, 0.20486, 
0.19439, 0.19237,
0.18633, 0.17298, 0.17174, 0.16822, 0.16480, 0.15027)
z<-diag(6)
ind <- lower.tri(z)
z[ind] <- t(v)[ind]

z
         [,1]    [,2] [,3] [,4] [,5] [,6]
[1,] 1.00000 0.00000    0    0    0    0
[2,] 0.26657 1.00000    0    0    0    0
[3,] 0.23388 0.19237    1    0    0    0
[4,] 0.23122 0.18633   NA    1    0    0
[5,] 0.21476 0.17298   NA   NA    1    0
[6,] 0.20829 0.17174   NA   NA   NA    1


        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to