Skip to content

Commit

Permalink
Expanding the candidate set to be square failed when no alternative s…
Browse files Browse the repository at this point in the history
…pecific attributes were present. This is now captured by an if-statement. We only try to expand in the presence of alternative specific attributes.
  • Loading branch information
edsandorf committed Feb 9, 2024
1 parent ae63074 commit 36366d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/design.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,16 @@ generate_design <- function(utility,
)
}

# Expand candidate set to be square, i.e., fill in zero columns, for non-specified
# Expand candidate set to be square, i.e., fill in zero columns, for non-specified. This in case of
# Alternative specific attributes!
expanded_names <- names(expand_attribute_levels(utility))
expr <- paste("cbind(candidate_set, ", paste(paste(expanded_names[!(expanded_names %in% utility_attributes)], 0, sep = " = "), collapse = ", "), ")")
candidate_set <- eval(parse(text = expr))

# Skip expansion if no alternative specific attributes are present
if (any(!(expanded_names %in% utility_attributes))) {
expr <- paste("cbind(candidate_set, ", paste(paste(expanded_names[!(expanded_names %in% utility_attributes)], 0, sep = " = "), collapse = ", "), ")")
candidate_set <- eval(parse(text = expr))
}

candidate_set <- candidate_set[, expanded_names]

}
Expand Down

0 comments on commit 36366d9

Please sign in to comment.