[R] using SVD to get an inverse matrix of covariance matrix
Dear R-users, I have one question about using SVD to get an inverse matrix of covariance matrix Sometimes I met many singular values d are close to 0: look this example $d [1] 4.178853e+00 2.722005e+00 2.139863e+00 1.867628e+00 1.588967e+00 [6] 1.401554e+00 1.256964e+00 1.185750e+00 1.060692e+00 9.932592e-01 [11] 9.412768e-01 8.530497e-01 8.211395e-01 8.077817e-01 7.706618e-01 [16] 7.007119e-01 6.237449e-01 5.709922e-01 5.550645e-01 5.062633e-01 [21] 4.792278e-01 4.222183e-01 3.660419e-01 3.293667e-01 3.026312e-01 [26] 2.942821e-01 2.811098e-01 2.626359e-01 2.199134e-01 1.943776e-01 [31] 1.712359e-01 1.561616e-01 1.359116e-01 1.280704e-01 1.099847e-01 [36] 1.013633e-01 9.622151e-02 8.396722e-02 7.083654e-02 6.755967e-02 [41] 5.392306e-02 3.807169e-02 2.942905e-02 2.726249e-02 4.555067e-16 [46] 3.095299e-16 2.918951e-16 2.672369e-16 2.336190e-16 2.239488e-16 [51] 2.089471e-16 1.970283e-16 1.863823e-16 1.775903e-16 1.698164e-16 [56] 1.594850e-16 1.500927e-16 1.469157e-16 1.406057e-16 1.366468e-16 [61] 1.319553e-16 1.252144e-16 1.193341e-16 1.142526e-16 1.064905e-16 [66] 1.040117e-16 1.005124e-16 9.310727e-17 8.995158e-17 8.529797e-17 [71] 8.204344e-17 7.759612e-17 7.478445e-17 7.225679e-17 6.709050e-17 [76] 5.996665e-17 5.830386e-17 5.687619e-17 5.121094e-17 4.848857e-17 [81] 4.549679e-17 4.307547e-17 3.830520e-17 3.450571e-17 3.312035e-17 [86] 3.260300e-17 2.399392e-17 2.141970e-17 1.996962e-17 1.881993e-17 [91] 1.567323e-17 1.062695e-17 6.730278e-18 2.118570e-18 4.991002e-19 Since the inverse matrix = u * inverse(d) * v', If I calculate inverse d based on formula : 1/d, then most values of inverse matrix will be huge. This must be not a good way. MOre special case, if a single value is 0, then we can not calculate inverse d based on 1/d. Therefore, my question is how I can calculate inverse d (that is inverse diag(d) more efficiently??? Thanks ping __ Post your free ad now! http://personals.yahoo.ca __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] estimate the number of clusters
Dear All, I am using Silhouette to estimate the number of clusters in a microarray dataset. Initially, I used the iris data to test my piece of code as follows: library(cluster) data(iris) mydata-iris[,1:4] maxk-15# at most 15 clusters myindex-rep(0,maxk) # hold the si values for each k clusters mdist-1-cor(t(mydata)) #dissimlarity mdist-as.dist(mdist) for(k in 2:maxk) { hc-diana(mdist,diss =TRUE, stand = FALSE) si-silhouette.default(cutree(as.hclust(hc),k=k),mdist) myindex-summary(si)$avg.width } myk-rev(order(myindex))[1] #select the number of k clusters with the #largest si value I met the following problems: for(k in 2:maxk) + { + hc-diana(mdist,diss =TRUE, stand = FALSE) + si-silhouette.default(cutree(as.hclust(hc),k=k),mdist) + myindex-summary(si)$avg.width + } Error in [-(*tmp*, iC, sil_width, value = s.i) : number of items to replace is not a multiple of replacement length In addition: Warning messages: 1: longer object length is not a multiple of shorter object length in: b.i - a.i 2: number of rows of result is not a multiple of vector length (arg 2) in: cbind(mmm, as.vector(each)) Could any one help me how I can solve the problems??? Your kind help is highly appreciated!! ping - Post your free ad now! Yahoo! Canada Personals [[alternate HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help