diff --git a/.gitignore b/.gitignore index 91ecf0235734e3886eaa001790a1704ee0268ae8..9b4ef08f921c978bc3ab2b95636d3b87ae4e7a77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .Rproj.user .Rhistory +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 470a1e7fa37fe1189482f17c9bf2e513de591252..7b8f8dad70b7cf9e4322f5850f31e9462b4f5b8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,9 @@ Imports: tictoc, tidyr Suggests: + knitr, testthat (>= 3.0.0) Config/testthat/edition: 3 Depends: R (>= 3.6.0) +VignetteBuilder: knitr diff --git a/tests/manual-tests/Rbookfull.R b/tests/manual-tests/Rbookfull.R index 4596edf730d4f9c1a205d95c28e012ecb89e9e0d..4a089080958a65a11ca8d38045357b19c7046bd1 100644 --- a/tests/manual-tests/Rbookfull.R +++ b/tests/manual-tests/Rbookfull.R @@ -14,14 +14,15 @@ resps =240 # number of respondents nosim=2 # number of simulations to run (about 500 is minimum) #betacoefficients should not include "-" -bsq=0.00 -bredkite=-0.05 -bdistance=0.50 -bcost=-0.05 -bfarm2=0.25 -bfarm3=0.50 -bheight2=0.25 -bheight3=0.50 +bcoeff<-list( + bsq=0.00, + bredkite=-0.05, + bdistance=0.50, + bcost=-0.05, + bfarm2=0.25, + bfarm3=0.50, + bheight2=0.25, + bheight3=0.50) destype <- "spdesign" @@ -38,7 +39,7 @@ ul<- list(u1= list( rbook <- simulateDCE::sim_all(nosim = nosim, resps=resps, destype = destype, - designpath = designpath, u= ul) + designpath = designpath, u= ul, bcoeff = bcoeff) diff --git a/tests/manual-tests/SE_Drive.R b/tests/manual-tests/SE_Drive.R index 322d93391b6f6ff465dda9d858e47fbb33075883..e5d644deea9838a0f7cd0cb9aa96fa70df0a13cb 100644 --- a/tests/manual-tests/SE_Drive.R +++ b/tests/manual-tests/SE_Drive.R @@ -52,14 +52,3 @@ destype="ngene" sedrive <- sim_all(nosim = nosim, resps=resps, destype = destype, designpath = designpath, u=ul, bcoeff = bcoeff) - -## nested results are hard coded, if the design changes this must aswell -coeffNestedOutput <- sedrive$olddesign$coefs - -variable_names <- names(coeffNestedOutput) - -# Filter variable names that start with "est_" -est_variables <- grep("^est_", variable_names, value = TRUE) - -print('hello') -print(class(coeffNestedOutput)) diff --git a/tests/manual-tests/agora.R b/tests/manual-tests/agora.R new file mode 100644 index 0000000000000000000000000000000000000000..ae40bc5af6ce21bfcd787e14bdb0e5108e416da9 --- /dev/null +++ b/tests/manual-tests/agora.R @@ -0,0 +1,40 @@ +designpath<- system.file("extdata","agora" ,package = "simulateDCE") + +resps =360 # number of respondents +nosim=2 # number of simulations to run (about 500 is minimum) + +#betacoefficients should not include "-" + +#design priors parameters +bcoeff <- list( + basc = -1.2, + basc2 = -1.4, + baction = 0.1, + badvisory = 0.4, + bpartner = 0.3, + bcomp = 0.02) + + +# from survey + +# basc = -2.2 +# basc2 = -2.7 +# baction = -0.15 +# badvisory = 0.26 +# bpartner = -0.09 +# bcomp = 0.004 + + + +#place your utility functions here +ul<-list( u1 = + list( + v1=V.1 ~ basc + baction*alt1.b + badvisory * alt1.c + bpartner * alt1.d + bcomp * alt1.p , #Utility of alternative 1 + v2=V.2 ~ basc2 + baction*alt2.b + badvisory * alt2.c + bpartner * alt2.d + bcomp * alt2.p , #Utility of alternative 2 + v3=V.3 ~ 0) +) + +destype="ngene" + +agora <- sim_all(nosim = nosim, resps=resps, destype = destype, + designpath = designpath, u=ul, bcoeff = bcoeff) diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..097b241637da023174b0f2e3715bd0291d9ded37 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/vignette_SE_Drive.Rmd b/vignettes/vignette_SE_Drive.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..51c9d6e293c8d37bc2af927b7aa8c1463bdea01e --- /dev/null +++ b/vignettes/vignette_SE_Drive.Rmd @@ -0,0 +1,19 @@ +--- +title: "vignette_SE_Drive" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{vignette_SE_Drive} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup} +library(simulateDCE) +```