[R] library(SenoMineR)- Triangle Test Query

Meyners, Michael meyners.m at pg.com
Wed Jun 8 12:32:55 CEST 2011


Vijayan,

I cannot find an error in your code, but I had a look at the code of triangle.test -- unless I'm missing something, it contains a bug. If you study the way in which the matrix "pref" is updated, you find that the vector preference is compared to 1, 2 and 3 instead of "X", "Y" and "Z" as it should be. That way, some of the non-diagonal entries of pref will always be zero, irrespective of the data, which does not make sense. I think it should work if you modify the code accordingly. Alternatively, a quick patch (untested!) might be to code preferences as 1, 2 and 3 instead of the letters (but I'm not sure whether this has any other implications).
I CC the author of the function and maintainer of the package; he should correct me if needed or could otherwise update the code for the next release (I worked on SensoMineR 1.11).

Hope this helps, 
Michael

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Vijayan Padmanabhan
> Sent: Saturday, June 04, 2011 9:21
> To: r-help at r-project.org
> Subject: [R] library(SenoMineR)- Triangle Test Query
> 
> Dear R Group
> I was trying to use the triangle.test function in SensoMineR and
> strangely i
> encounter a error in the output of preference matrix from the analysis.
> To illustrate, pl see the following dataframe of a design with the
> response
> and preference collected as shown below:
> 
> design<-structure(list(`Product X` = c(3, 1, 4, 2, 4, 2, 1, 3, 4, 2,
> 4, 2, 1, 3, 4, 2, 4, 2, 3, 1), `Product Y` = c(1, 1, 4, 4, 4,
> 3, 1, 1, 4, 4, 4, 3, 1, 1, 4, 4, 4, 3, 1, 1), `Product Z` = c(3,
> 2, 1, 2, 3, 3, 2, 3, 1, 2, 3, 3, 2, 3, 1, 2, 3, 3, 3, 2), Response =
> structure(c(1L,
> 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,
> 1L, 1L, 2L), .Label = c("X", "Z"), class = "factor"), Preference =
> structure(c(1L,
> 3L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 1L, 1L,
> 2L, 1L, 2L), .Label = c("X", "Y", "Z"), class = "factor")), .Names =
> c("Product X",
> "Product Y", "Product Z", "Response", "Preference"), class =
> "data.frame",
> row.names = c("Panelist1.Test1",
> "Panelist1.Test2", "Panelist2.Test1", "Panelist2.Test2",
> "Panelist3.Test1",
> "Panelist3.Test2", "Panelist4.Test1", "Panelist4.Test2",
> "Panelist5.Test1",
> "Panelist5.Test2", "Panelist6.Test1", "Panelist6.Test2",
> "Panelist7.Test1",
> "Panelist7.Test2", "Panelist8.Test1", "Panelist8.Test2",
> "Panelist9.Test1",
> "Panelist9.Test2", "Panelist10.Test1", "Panelist10.Test2"))
> 
> If you were to investigate the above dataframe, you would find that for
> the
> comparision of Product 2 Vs Product 3, the preference indicates product
> 3 is
> preferred over product 2 all the time.
> 
> ## Read output from the following script to see what i mean above:
> subset(design,`Product X`==2&`Product Y`==3&`Product Z`==3)
> 
> ##Output of above would be:
> .                 Product X Product Y Product Z Response Preference
> Panelist3.Test2         2         3         3        X          Y
> Panelist6.Test2         2         3         3        X          Y
> Panelist9.Test2         2         3         3        X          Y
> 
> However when I analyse the design with the answers and preferences
> using the
> following script, I get the $pref output which shows that product 2 is
> preferred over 3 all the time. Can somebody explain what is wrong in my
> script?
> 
> answer<-as.vector(design$Response)
> preference<-as.vector(design$Preference)
> triangle.test (design[,1:3], answer,preference)
> 
> ##$pref output from the triangle.test function shows as follows:
> 
> $pref
>   1 2 3 4
> 1 0 0 0 0
> 2 4 0 3 0
> 3 0 0 0 0
> 4 0 0 0 0
> 
> 
> Any help in helping me identify what is going wrong here would be
> highly
> appreciated.
> Regards
> Vijayan Padmanabhan
> 
> 	[[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.



More information about the R-help mailing list