An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121114/6e00c91a/attachment.pl>
reversing distance matrix for original values
5 messages · Eliza Botto, Sarah Goslee, Brian Ripley +1 more
Hi Eliza,
On Wed, Nov 14, 2012 at 9:33 AM, eliza botto <eliza_botto at hotmail.com> wrote:
dear useRs, i created a distance matrix, of certain voltage values. unfortunately, i lost the original values. i am only left with the distance matrix that i created from those values. i wanted to ask that is there a way in R to reverse distance matrix for the original values?
There is not, and a bit of thought will tell you why. Say you used Euclidean distance as your metric, and only had one variable. For a distance of 2, the original data could be: dist(c(10, 12)) dist(c(5, 7)) dist(c(7, 5)) dist(c(1, 3)) dist(c(100000, 100002)) dist(c(2, 4)) dist(c(2.1, 4.1)) dist(c(2.2, 4.2)) and so on. Even with known bounds on your voltage values, there are an infinite number of equivalent solutions. I suppose you could try to treat it as a system of X equations and X unknowns and find possible solutions, but that doesn't get you back your original data. Sarah -- Sarah Goslee http://www.functionaldiversity.org
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121114/90ec5467/attachment.pl>
On 14/11/2012 14:33, eliza botto wrote:
dear useRs, i created a distance matrix, of certain voltage values. unfortunately, i lost the original values. i am only left with the distance matrix that i created from those values. i wanted to ask that is there a way in R to reverse distance matrix for the original values?
Partially: see ?cmdscale. Distances contain no information on location, rotations or reflections.
thanks in advance eliza [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
You might reconstruct the values if you have some of the original data. Metric multidimensional scaling (cmdscale) will give you a set of values that produces your distance matrix. If it is based on a single voltage, you only have one dimension to reconstruct. There are an infinite number of sets of values that will produce your distance matrix, but all of them differ by one constant value added to the vector so you must know the voltage of at least one observation to get back to the original values. See the example below:
vals
[1] 1 2 3 4 5 6 7 8 9 10
out <- cmdscale(dist(vals)) out
[,1] [,2] [1,] -4.5 1.793550e-07 [2,] -3.5 -4.537897e-08 [3,] -2.5 -3.241355e-08 [4,] -1.5 -1.944813e-08 [5,] -0.5 -6.482710e-09 [6,] 0.5 6.482710e-09 [7,] 1.5 1.944813e-08 [8,] 2.5 3.241355e-08 [9,] 3.5 4.537897e-08 [10,] 4.5 5.834439e-08
out[,1] + 1-out[1,1]
[1] 1 2 3 4 5 6 7 8 9 10 If the distance matrix is based on more than one variable, you would need to know at least as many of the original observations as variables. ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of Prof Brian Ripley Sent: Wednesday, November 14, 2012 8:48 AM To: eliza botto Cc: r-help at r-project.org Subject: Re: [R] reversing distance matrix for original values On 14/11/2012 14:33, eliza botto wrote:
dear useRs, i created a distance matrix, of certain voltage values.
unfortunately, i lost the original values. i am only left with the distance matrix that i created from those values. i wanted to ask that is there a way in R to reverse distance matrix for the original values? Partially: see ?cmdscale. Distances contain no information on location, rotations or reflections.
thanks in advance eliza [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
-- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________ R-help at r-project.org 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.