Help with mdscale starting configuration?

2 visualizaciones (últimos 30 días)
Ryan
Ryan el 9 de Mayo de 2013
I am having a hard time using mdscale.
Basically, I have a series of distance matrices that I want to reconstruct into Cartesian coordinates. Due to missing values, I can't use cmdscale. This is all well and good, because that's what mdscale is for.
However, mdscale only has two possible options that will work with regards to the starting configuration. One is ('Start','random'), which I don't want. I want it to start at the same point every time.
The problem is, I do not understand how to pass a specific starting configuration into mdscale! The documentation only says this:
"An n-by-p matrix of initial locations, where n is the size of the matrix D and p is the number of columns of the output matrix Y. In this case, you can pass in [] for p and mdscale infers p from the second dimension of the matrix. You can also supply a three-dimensional array, implying a value for 'Replicates' from the array's third dimension."
But, to be blunt, this doesn't make any $%*&$*%(& sense!
Okay, so an n-by-p matrix, where n is the size of D and p is the number of columns in Y. I am doing two-dimensional analysis, so p is 2. Let's say my matrix D is 6x6. So I need a 6 by 2 matrix ... but what values do I use?! What does it mean "matrix of initial locations"? Is it all zeros with a 1 where I want to start? This is incredibly confusing, and it bothers me that nowhere in the Matlab documentation for mdscale do they even give an example of how to use a starting configuration beside 'random' (or cmdscale).
Can anybody help me here? If I just want it to start at the 1st cell of my input matrix, for example, how do I define this n-by-p starting configuration matrix?

Respuestas (2)

Tom Lane
Tom Lane el 10 de Mayo de 2013
You could set R=rand(6,2) outside the function, and try using that as the 'Start' argument each time you run the function. This would be random at first, but then you could use it repeatedly.
The idea is that the function apparently needs a set of 6 2-D points, which it will try to modify iteratively to match up to the distance matrix you supply.
I would imagine that, if you had some idea of a reasonable set of coordinates to come close to matching your distance matrix, that would help. But it appears that the function is willing to try generating points at random, so perhaps it will perform reasonably well even if you generate your own points at random.
  1 comentario
Ryan
Ryan el 13 de Mayo de 2013
The problem is that I am trying to use mdscale in order to estimate the coordinates of the values from my distance matrix. So I don't see how I can have any reasonable input parameters in this case.

Iniciar sesión para comentar.


Peter Perkins
Peter Perkins el 11 de Mayo de 2013
You want to reconstruct the cartesian coordinates of six points from their 6x6 distance matrix. What would such a reconstruction look like? In MATLAB, at least in this case, it would be a 6 (points) -by- two (dimensions) matrix. Each row is the two coordinates of a point -- (x,y) if you will. The 6z2 matrix you pass into mdscale is simply your initial guess at that. It's the same kind of thing that mdscale returns when it's done. As Tom says, your guess might be rand(6,2), or you might have some better idea of what the coordinates ought to be.
I'm not sure what you mean by
the 1st cell of my input matrix
but the matrix of initial locations that you pass in has to be a set of six (x,y) coordinates.
  2 comentarios
Ryan
Ryan el 13 de Mayo de 2013
But why do I need 6 points? That's what I don't understand. If I am specifying the starting point for the scaling, why do I need 6 different points? What does it actually do with the different points?
I think you misunderstood what I meant. By 'input matrix' I meant the distance matrix on which I am trying to apply the scaling. The only values in my matrix are distances, not x,y coordinates. I just want the algorithm to always evaluate things from the same starting point. But how do I get it to do this?
The issue is that I don't HAVE x,y coordinates for my data. I only have the relative distances between the points.
Peter Perkins
Peter Perkins el 14 de Mayo de 2013
Editada: Peter Perkins el 14 de Mayo de 2013
First, to always get the same output, either
  • type "rng(0)" or something like it before running mdscale, or
  • create a matrix initialLocations = rand(6,1) and always pass that same thing into mdscale as the initial locations
But to your other questions: You need six points to start the optimization that mdscale carries out. This might sound like circular reasoning. When you start out what you have is a 6x6 distance matrix, and you don't have a 6x2 matrix of six (x,y) coordinates to which those distances correspond -- that's the answer that you want mdscale to spit out. But the process of finding that answer is nothing more than an optimization problem. Here's what mdscale does inside:
  1. starting from some initial set of six (x,y) coordinates ...
  2. compute the 6x6 distance matrix among those six points
  3. compare that to the desired distance matrix (the one you gave it)
  4. if close enough, stop
  5. if not, adjust the six locations to improve the comparison
  6. repeat (2)-(5)
mdscale needs either you, or the rand function, to do step (1) before it can do anything. So if you have some idea what the final answer might look like, that's a good starting point. If not, things usually work out (albeit more slowly) from random locations.
Hope this helps.

Iniciar sesión para comentar.

Categorías

Más información sobre Analysis of Variance and Covariance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by