edsandorf / spdesign

Contemporary software commonly used to design stated preference experiments are expensive and the code is closed source. spdesignR is a free software package with an easy to use interface to make flexible stated preference experimental designs using state-of-the-art methods.
GNU General Public License v3.0
0 stars 1 forks source link

Allow the user to enforce attribute level balance #15

Closed edsandorf closed 1 year ago

edsandorf commented 3 years ago

The default is to not enforce attribute level balance.

opts$attribute_level_balance = FALSE

This can be set to TRUE to enforce balance or can be provided as a list stating the minimum or maximum occurence of each attribute level

opts$attribute_level_balance = list(
  x1 = list(
    l1 = c(0, 1),
    l2 = c(3, 5)
  )
)

Would also need to write in checks on the complete list against the semi-parsed utility expression to check that all information is present.

Syntax is open for discussion. Is this the best way?

edsandorf commented 3 years ago

Alt:

x1[0, 1](0-1, 3-5)

How to parse this? In combination with TRUE/FALSE in opts?

edsandorf commented 3 years ago

In the case where the user supplies a candidate set to generate_design, then the attributes and levels are inferred from the candidate set, which means that the square brackets in the utility functions are ignored. When we implement this functionality, we have to make sure that the function can pick up both cases:

x1[c(0, 1)](4, 4)

and

x1(4, 4)
edsandorf commented 3 years ago

Alt:

x1[0, 1](0-1, 3-5)

How to parse this? In combination with TRUE/FALSE in opts?

If:

x1[c(0, 1)](4)

then assume that all appear equal number of times.

If attribute level balance parameter is neither 1 nor equal to the number of levels throw an error.

edsandorf commented 3 years ago

So if level_balance = TRUE and the number of levels for each attriute are not multiples of J*S, then issue a warning and impose near attribute level balance for the affected attributes, i.e. as tight a range as possible while retaining attribute level balance for the others.

If level_balance = TRUE and number of times are specified in parenthesis, issue warning and ignore.

The default for level_balance is FALSE.

If a single number is specified and it is less than the level balance multiple of the attribute levels, then use as a minimum. If higher use as a maximum.

Example:

J <- 2
S <- 6

# Attribute level balance
x[1:3](4) 

# Minimum
x[1:3](3)

# Maximum
x[1:3](5)