From a71115297db4024f6f921b1ce806d2982d337073 Mon Sep 17 00:00:00 2001
From: samuelsmock <smock.samuel@gmail.com>
Date: Thu, 8 Feb 2024 17:26:15 -0600
Subject: [PATCH] agora test added initial vignette trial structure built

---
 .gitignore                      |  1 +
 DESCRIPTION                     |  2 ++
 tests/manual-tests/Rbookfull.R  | 19 ++++++++--------
 tests/manual-tests/SE_Drive.R   | 11 ---------
 tests/manual-tests/agora.R      | 40 +++++++++++++++++++++++++++++++++
 vignettes/.gitignore            |  2 ++
 vignettes/vignette_SE_Drive.Rmd | 19 ++++++++++++++++
 7 files changed, 74 insertions(+), 20 deletions(-)
 create mode 100644 tests/manual-tests/agora.R
 create mode 100644 vignettes/.gitignore
 create mode 100644 vignettes/vignette_SE_Drive.Rmd

diff --git a/.gitignore b/.gitignore
index 91ecf02..9b4ef08 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 .Rproj.user
 .Rhistory
 
+inst/doc
diff --git a/DESCRIPTION b/DESCRIPTION
index 470a1e7..7b8f8da 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 4596edf..4a08908 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 322d933..e5d644d 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 0000000..ae40bc5
--- /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 0000000..097b241
--- /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 0000000..51c9d6e
--- /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)
+```
-- 
GitLab