Dear all, I have a question with regard to the use of hclust. I would like to be able to specify my own distance matrix instead of asking R to compute the distance matrix for me. It is computationally easier for me this way. My question is: How can I get hclust to accept this? Thanks, Ranjan -- *************************************************************************** Ranjan Maitra, Department of Mathematics and Statistics, University of Maryland, Baltimore County, Baltimore, MD 21250, USA. *************************************************************************** \|/ satyamevajayate | tamasomaajyotirgamaya \|/ -*- | -*- /|\ TRUTH SHALL PREVAIL | FROM DARKNESS TO LIGHT /|\ *************************************************************************** Ph: 410-455-2436 FAX: 410-455-1066 http://www.math.umbc.edu/~maitra *************************************************************************** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 22 Feb 2001, Ranjan Maitra wrote:> Dear all, > > I have a question with regard to the use of hclust. I would like to be > able to specify my own distance matrix instead of asking R to compute > the distance matrix for me. It is computationally easier for me this > way. My question is: How can I get hclust to accept this?I am puzzled: ?hclust Arguments: d: a dissimilarity structure as produced by `dist'. So hclust accepts a dissimilarity matrix as its first argument, and does not compute a distance matrix. Just supply `d'. The `Value' section of ?dist tells you how to specify it. For hclust only the `Size' and `Labels' attributes are needed, I believe. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> On Thu, 22 Feb 2001 22:37:40 -0500 (EST), >>>>> Ranjan Maitra (RM) wrote:> Dear all, > I have a question with regard to the use of hclust. I would like to be > able to specify my own distance matrix instead of asking R to compute > the distance matrix for me. It is computationally easier for me this > way. My question is: How can I get hclust to accept this? simply use as.dist() to convert a matrix of distances to a distance object. e.g.: ## some arbitrary symmetric matrix x R> x 1 2 3 4 5 1 0.0000000 1.5705860 1.0434241 1.7699446 0.6694592 2 1.5705860 0.0000000 0.5271619 0.1993587 0.9011267 3 1.0434241 0.5271619 0.0000000 0.7265205 0.3739649 4 1.7699446 0.1993587 0.7265205 0.0000000 1.1004854 5 0.6694592 0.9011267 0.3739649 1.1004854 0.0000000 R> hclust(as.dist(x)) Call: hclust(d = as.dist(x)) Cluster method : complete Number of objects: 5 hope this helps, -- ------------------------------------------------------------------- Friedrich Leisch Institut f?r Statistik Tel: (+43 1) 58801 10715 Technische Universit?t Wien Fax: (+43 1) 58801 10798 Wiedner Hauptstra?e 8-10/1071 Friedrich.Leisch at ci.tuwien.ac.at A-1040 Wien, Austria http://www.ci.tuwien.ac.at/~leisch ------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Ranjan, On 23-Feb-01 Ranjan Maitra wrote:> Dear all, > > I have a question with regard to the use of hclust. I would like to be > able to specify my own distance matrix instead of asking R to compute > the distance matrix for me. It is computationally easier for me this > way. My question is: How can I get hclust to accept this?Have a look at the help page of dist: Value An object of class "dist". The lower triangle of the distance matrix stored by columns in a single vector. The vector has the attributes "Size", "Diag", "Upper", "Labels" and "class" equal to "dist". So you have to shape your result according to this, when you got your vector d you can add the attributes & class by attr(d, "Size") <- N attr(d, "Labels") <- dimnames(x)[[1]] attr(d, "Diag") <- diag attr(d, "Upper") <- upper attr(d, "method") <- METHODS[method] attr(d, "call") <- match.call() class(d) <- "dist" (cited from the code of dist) Regards, Winfried> > Thanks, > Ranjan > > -- > *************************************************************************** > Ranjan Maitra, Department of Mathematics and Statistics, > University of Maryland, Baltimore County, Baltimore, MD 21250, USA. > *************************************************************************** > > \|/ satyamevajayate | tamasomaajyotirgamaya \|/ > -*- | -*- > /|\ TRUTH SHALL PREVAIL | FROM DARKNESS TO LIGHT /|\ > > *************************************************************************** > Ph: 410-455-2436 FAX: 410-455-1066 http://www.math.umbc.edu/~maitra > *************************************************************************** > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > - > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _---------------------------------- E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de> Date: 23-Feb-01 Time: 09:58:31 Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg "Angewandte Statistik" Universität Dortmund, 44221 Dortmund Tel.: +49-231-755-5903 FAX: +49-231-755-4387 ---------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Ranjan You can just use this: dissimilarity <- as.dist(your-own-distance-matrix) h <- hclust(dissimilarity, method = "complete") your own distance matrix must be a dissimilarity matrix Olivier Houix Ranjan Maitra wrote:> > Dear all, > > I have a question with regard to the use of hclust. I would like to be > able to specify my own distance matrix instead of asking R to compute > the distance matrix for me. It is computationally easier for me this > way. My question is: How can I get hclust to accept this? > > Thanks, > Ranjan > > -- > *************************************************************************** > Ranjan Maitra, Department of Mathematics and Statistics, > University of Maryland, Baltimore County, Baltimore, MD 21250, USA. > *************************************************************************** > > \|/ satyamevajayate | tamasomaajyotirgamaya \|/ > -*- | -*- > /|\ TRUTH SHALL PREVAIL | FROM DARKNESS TO LIGHT /|\ > > *************************************************************************** > Ph: 410-455-2436 FAX: 410-455-1066 http://www.math.umbc.edu/~maitra > *************************************************************************** > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Olivier Houix <houix at ircam.fr> tel: 01 44 78 15 51 Equipe Perception et Cognition Musicales http://www.ircam.fr/ IRCAM 1 place Igor Stravinsky 75004 Paris -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._