Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simulateDCE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dj44vuri
simulateDCE
Commits
e51dbdde
Commit
e51dbdde
authored
1 year ago
by
samuelsmock
Browse files
Options
Downloads
Patches
Plain Diff
Reasonable results test now checks every b coeff.
parent
0c1de67f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/manual-tests/SE_Drive.R
+11
-0
11 additions, 0 deletions
tests/manual-tests/SE_Drive.R
tests/testthat/Rplots.pdf
+0
-0
0 additions, 0 deletions
tests/testthat/Rplots.pdf
tests/testthat/test-sim_all.R
+40
-2
40 additions, 2 deletions
tests/testthat/test-sim_all.R
with
51 additions
and
2 deletions
tests/manual-tests/SE_Drive.R
+
11
−
0
View file @
e51dbdde
...
...
@@ -52,3 +52,14 @@ 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
))
This diff is collapsed.
Click to expand it.
tests/testthat/Rplots.pdf
+
0
−
0
View file @
e51dbdde
No preview for this file type
This diff is collapsed.
Click to expand it.
tests/testthat/test-sim_all.R
+
40
−
2
View file @
e51dbdde
...
...
@@ -152,7 +152,45 @@ test_that("Simulation results are reasonable", {
result1
<-
sim_all
(
nosim
=
nosim
,
resps
=
resps
,
destype
=
destype
,
designpath
=
designpath
,
u
=
ul
,
bcoeff
=
bcoeff
)
expect_gt
(
result1
$
est_bsq
,
-1
)
expect_lt
(
result1
$
est_bsq
,
1
)
## The function below is intended to find a dataframe called $coef in the output
## regardless of the output data structure which can vary
find_dataframe
<-
function
(
list_object
,
dataframe_name
)
{
# Check if the current object is a list
if
(
is.list
(
list_object
))
{
# Check if the dataframe_name exists in the names of the current list object
if
(
dataframe_name
%in%
names
(
list_object
))
{
# Check if the object corresponding to dataframe_name is a data frame
if
(
is.data.frame
(
list_object
[[
dataframe_name
]]))
{
return
(
list_object
[[
dataframe_name
]])
# Return the data frame if found
}
}
# Recursively search through each element of the current list object
for
(
element
in
list_object
)
{
result
<-
find_dataframe
(
element
,
dataframe_name
)
if
(
!
is.null
(
result
))
{
return
(
result
)
# Return the data frame if found in any nested list
}
}
}
return
(
NULL
)
# Return NULL if dataframe_name not found
}
# Now access the coef data frame to compare to the input
coeffNestedOutput
<-
find_dataframe
(
result1
,
"coefs"
)
for
(
variable
in
names
(
bcoeff
)){
### Compare singular input value (hypothesis) with the average value of all iterations. ###
### This could be made more rigorous by testing each iteration or by changing the ###
### tolerance around the input value considered valid.
input_value
<-
bcoeff
[[
variable
]]
mean_output_value
<-
mean
(
coeffNestedOutput
[[
paste0
(
"est_"
,
variable
)]])
## access the mean value of each iteration
##change this depending on how rigorous you want to be
expect_gt
(
mean_output_value
,
input_value
-
1
)
expect_lt
(
mean_output_value
,
input_value
+
1
)
}
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment