diff --git a/R/simulate_choices.R b/R/simulate_choices.R index def513d0d9e40ebc27e1c4d6f0348b8f55f9aeef..5ec9b25bc14219afd361675bee829a466993eea6 100644 --- a/R/simulate_choices.R +++ b/R/simulate_choices.R @@ -42,7 +42,7 @@ simulate_choices <- function(data=datadet, utility =utils, setspp) { #the part if(exists("decisiongroups")) { ### create a new variable to classify decision groups. data = dplyr::mutate(data,group = as.numeric(cut(dplyr::row_number(), - breaks = decisiongroups * n(), + breaks = decisiongroups * dplyr::n(), labels = seq_along(decisiongroups[-length(decisiongroups)]), include.lowest = TRUE))) diff --git a/tests/manual-tests/SE_Drive.R b/tests/manual-tests/SE_Drive.R new file mode 100644 index 0000000000000000000000000000000000000000..b4d977b687245988ff069d80753e821549c3774b --- /dev/null +++ b/tests/manual-tests/SE_Drive.R @@ -0,0 +1,57 @@ + + +rm(list=ls()) +devtools::load_all() + + +library(rlang) + +designpath<- system.file("extdata","SE_DRIVE" ,package = "simulateDCE") + +resps =120 # number of respondents +nosim= 2 # number of simulations to run (about 500 is minimum) + + + + + + +# bpreis = -0.036 +# blade = -0.034 +# bwarte = -0.049 + + +decisiongroups=c(0,0.7,1) + +# wrong parameters + +# +bpreis = -0.01 +blade = -0.07 +bwarte = 0.02 + +manipulations = list(alt1.x2= expr(alt1.x2/10), + alt1.x3= expr(alt1.x3/10), + alt2.x2= expr(alt2.x2/10), + alt2.x3= expr(alt2.x3/10) +) + + +#place your utility functions here +u<-list( u1 = + + list( + v1 =V.1~ bpreis * alt1.x1 + blade*alt1.x2 + bwarte*alt1.x3 , + v2 =V.2~ bpreis * alt2.x1 + blade*alt2.x2 + bwarte*alt2.x3 + ) + + , + u2 = list( v1 =V.1~ bpreis * alt1.x1 , + v2 =V.2~ bpreis * alt2.x1) + +) + + +destype="ngene" + +sedrive <- sim_all()