Please don't ask me why. It was a wild guess
library(DCchoice)
#> Loading required package: MASS
#> Loading required package: interval
#> Loading required package: survival
#> Loading required package: perm
#> Loading required package: Icens
#> Loading required package: MLEcens
#> Loading required package: Formula
require(dplyr)
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following object is masked from 'package:MASS':
#>
#> select
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
dbbd <- structure(list(yorn1a = c(0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 0L,
1L), bid1a = c(476L, 952L, 476L, 19L, 95L, 57L, 19L, 95L, 952L,
19L), FF1 = c(285L, 476L, 285L, 57L, 285L, 19L, 57L, 57L, 476L,
57L), FFY1 = c(0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L), gtra = c(6L,
6L, 4L, 5L, 6L, 5L, 5L, 5L, 5L, 4L), geoegba = c(6L, 5L, 4L,
5L, 5L, 4L, 6L, 3L, 4L, 6L), inhospa = c(0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L), expena = c(0L, 2000L, 0L, 100L, 500L, 0L,
0L, 0L, 0L, 100L), watpa = c(10L, 8L, 9L, 9L, 9L, 10L, 9L, 9L,
7L, 9L), agea = c(27L, 29L, 26L, 30L, 26L, 32L, 33L, 32L, 46L,
28L), genda = c(0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L), mincomea = c(4000L,
10000L, 15000L, 2500L, 4000L, 10000L, 6500L, 10000L, 6500L, 4000L
), ideologya = c(5L, 4L, 4L, 5L, 5L, 2L, 4L, 4L, 2L, 4L), intnewa = c(2L,
1L, 1L, 1L, 2L, 1L, 2L, 1L, NA, 2L)), row.names = c(NA, 10L), class = "data.frame")
double1<-dbchoice(formula=yorn1a+FFY1~gtra+geoegba+inhospa+expena+watpa+agea+genda+mincomea+ideologya+intnewa|bid1a+FF1,data=dbbd,na.action=na.omit,dist="normal")
#> Error in optim(ini, fn = dbLL, method = "BFGS", hessian = TRUE, dvar = yvar, : non-finite value supplied by optim
# remove inhospa because it *seems* to have too few values
dbbd1 <- dbbd %>% select(-inhospa)
formula = yorn1a + FF1 ~ gtra + geoegba + expena + agea + genda + mincomea + bid1a + FFY1 | ideologya + intnewa
re_choose <- function(x,y) {
(dbchoice(formula = x, data=y, na.action=na.omit, dist="normal"))
}
re_choose(formula, dbbd1)
#> Error in optim(ini, fn = dbLL, method = "BFGS", hessian = TRUE, dvar = yvar, : non-finite value supplied by optim
# persists
# remove `expena` for too few
dbbd2 <- dbbd1 %>% select(-expena)
formula = yorn1a + FF1 ~ gtra + geoegba + agea + genda + mincomea + bid1a + FFY1 | ideologya + intnewa
re_choose(formula, dbbd2)
#>
#> Distribution: normal
#> (Intercept) gtra geoegba agea genda mincomea
#> 3.07427955 4.47348318 9.81653755 -1.73440170 19.27346249 0.00167941
#> bid1a FFY1 BID
#> -0.03420042 -11.11615366 -19.48828201
Created on 2020-01-20 by the reprex package (v0.3.0)