[R] sammon fails with duplicates error, but no duplicates there (MASS package)
Martin Guetlein
guetlein at informatik.uni-freiburg.de
Fri Jul 4 11:06:50 CEST 2014
Hi Frede,
awesome, thanks a lot. Helped me to understand how sammon is working as well.
Martin
On 4 July 2014 10:02, Frede Aakmann Tøgersen <frtog at vestas.com> wrote:
> Hi
>
> It seems to be related to the way that the default start values (y argument of sammon) are calculated.
>
> Here the last two rows are the same:
>
>> cmdscale(dist(data), 2)
> [,1] [,2]
> c1 2.04910556 -0.3627887
> c2 -0.01889892 -0.1822057
> c3 0.40767629 0.2599026
> c4 0.81569304 -0.4165993
> c5 0.70362596 -0.3573003
> c6 -1.69673266 -1.7209956
> c7 -0.65997449 -0.2888096
> c8 -0.24449262 0.4502489
> c9 -0.67800108 1.3092739
> c10 -0.67800108 1.3092739
>
> Try to perturb the start values using jitter(). Like this
>
>> sammon(dist(data), y = jitter(cmdscale(dist(data), 2)))
> Initial stress : 0.18304
> stress after 10 iters: 0.07867, magic = 0.092
> stress after 20 iters: 0.05149, magic = 0.500
> stress after 30 iters: 0.05101, magic = 0.500
> stress after 40 iters: 0.05096, magic = 0.500
> $points
> [,1] [,2]
> c1 2.12900041 -1.7255589
> c2 0.32144017 -0.4397770
> c3 1.09694083 1.2989299
> c4 1.90228818 0.3198121
> c5 0.09479179 -1.7229204
> c6 -2.35619505 -1.2913663
> c7 -0.95749355 -0.2635698
> c8 -0.08310984 0.6903391
> c9 -1.48236001 1.2443252
> c10 -0.66530292 1.8897858
>
> $stress
> [1] 0.0509611
>
> $call
> sammon(d = dist(data), y = jitter(cmdscale(dist(data), 2)))
>
>>
>
> Yours sincerely / Med venlig hilsen
>
>
> Frede Aakmann Tøgersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
>
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> frtog at vestas.com
> http://www.vestas.com
>
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
>> On Behalf Of Martin Guetlein
>> Sent: 4. juli 2014 09:13
>> To: r-help at r-project.org
>> Subject: [R] sammon fails with duplicates error, but no duplicates there
>> (MASS package)
>>
>> Hi all,
>>
>> the sammon mapping fails with message "initial configuration has
>> duplicates". But there are no duplicates in my data (see example
>> below).
>> Apparently, the problem is that row 9 and 10 have an equal distance to
>> all other rows (but they are not equal, see last two columns).
>>
>> Any help to get sammon working would be great,
>> Kind regards,
>> Martin
>>
>>
>> library("MASS")
>> c1 <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0)
>> c2 <- c(0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0)
>> c3 <- c(1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0)
>> c4 <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0)
>> c5 <- c(1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0)
>> c6 <- c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1,
>> 1, 1, 1, 0, 0)
>> c7 <- c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
>> 0, 0, 0, 0, 0)
>> c8 <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0)
>> c9 <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 1, 0)
>> c10<- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 1)
>> # working
>> data <- rbind(c1,c2,c3,c4,c5,c6,c7,c8,c9)
>> sammon(dist(data))
>> # not working:
>> data <- rbind(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
>> sammon(dist(data))
>>
>> ______________________________________________
>> 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.
--
Dipl-Inf. Martin Gütlein
Phone:
+49 (0)761 203 8442 (office)
+49 (0)177 623 9499 (mobile)
Email:
guetlein at informatik.uni-freiburg.de
More information about the R-help
mailing list