Skip to content

Commit 1b7d437

Browse files
committed
bug fixes in getting factor levels, updated cran comments
1 parent b250605 commit 1b7d437

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

CRAN-SUBMISSION

Lines changed: 0 additions & 3 deletions
This file was deleted.

R/encoding.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ dummyCode <- function(df, vars) {
5353
#' result$randPars
5454
#' head(result$X)
5555
recodeData <- function(data, pars, randPars) {
56-
data <- as.data.frame(data) # tibbles break things
5756
data <- orderedFactorsToChars(data) # ordered factors cause weird names
5857
formula <- stats::as.formula(paste0("~ ", paste(pars, collapse = " + ")))
5958
X <- getDesignMatrix(formula, data)
@@ -83,6 +82,12 @@ getColumnTypes <- function(data) {
8382
}
8483

8584
getFactorLevels <- function(data, pars) {
85+
# Separate out interactions
86+
ints <- grepl("\\*", pars)
87+
if (any(ints)) {
88+
pars <- pars[ints == FALSE]
89+
}
90+
factorLevels <- NULL
8691
parTypes <- getParTypes(data, pars)
8792
discrete <- parTypes$discrete
8893
if (!is.null(discrete)) {

R/modelInputs.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ getModelInputs <- function(
4949

5050
# Get the design matrix, recoding parameters that are categorical
5151
# or have interactions
52+
data <- as.data.frame(data) # tibbles break things
5253
factorLevels <- getFactorLevels(data, pars) # need to store for predicting
5354
recoded <- recodeData(data, pars, randPars)
5455
formula <- recoded$formula

cran-comments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88

99
## Notes
1010
* This is a new release.
11+
* The DOI <doi:10.18637/jss.v105.i10> in the CITATION and DESCRIPTION is for a new JSS publication that will be registered after publication on CRAN.

vignettes/data_formatting.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ mnl_pref_dummies <- logitr(
7070
outcome = 'choice',
7171
obsID = 'obsID',
7272
pars = c(
73-
'price', 'feat', 'brand_yoplait', 'brand_dannon', 'brand_weight')
73+
'price', 'feat', 'brand_yoplait', 'brand_dannon', 'brand_weight'
74+
)
7475
)
7576
7677
summary(mnl_pref_dummies)

0 commit comments

Comments
 (0)