Search code examples
rfactorial

Creating a fractional factorial design in R without prohibited pairs


I'm trying to write R code for a choice-based conjoint study. I can create a factorial design using AlgDesign or conjoint - however, there are combinations of attribute levels that should not be together Using an example from the web:

#Creating a full factorial design
library(AlgDesign)
ffd <- gen.factorial(c(2,2,4), varNames=c("Discount","Amount","Price"), factors="all")
ffd

   Discount Amount Price
1    1      1      1
2    2      1      1
3    1      2      1
4    2      2      1
5    1      1      2
6    2      1      2
7    1      2      2
8    2      2      2
9    1      1      3
10   2      1      3
11   1      2      3
12   2      2      3
13   1      1      4
14   2      1      4
15   1      2      4
16   2      2      4

But what if "Discount" 2 ("no discount") should never be paired with "Amount" 1 ("20% discount")

Is there a way to tell AlgDesign or conjoint or some other factorial design to remove any prohibited pairs from the design?

Any advice would be appreciated.


Solution

  • You could always generate ffd as you did there, and then remove rows which meet your criteria, e.g. ffd$Discount == 2 & ffd$Amount==1 . The easy-ish way is to keep all the rows which do not meet the condition:

    ffd<-ffd[(ffd$Discount != 2 | ffd$Amount != 1),]
    

    Repeat for each condition you want to reject.