Skip to content

Commit

Permalink
update test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Slama committed Feb 22, 2024
1 parent 0f1256f commit 0010ca6
Show file tree
Hide file tree
Showing 35 changed files with 344 additions and 206 deletions.
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ add0thPercPV <- function(x) {
#' expect_snapshot_file(save_png(ggplot(mtcars) +
#' geom_point(aes(hp, mpg))), "riskProfile.png")
#'
save_png <- function(code, width = 400, height = 400) {
save_png <- function(code, width = 400, height = 400) { # nocov start
path <- tempfile(fileext = ".png")
png(path, width = width, height = height)
on.exit(dev.off())
print(code)
return(path)
}
} # nocov end
110 changes: 110 additions & 0 deletions tests/testthat/_snaps/calibrationProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,61 @@
outcome score percentile method
1 0.5 0.5098193 0.475 Calibration In The Large

---

Code
as.data.frame(out2$data)
Output
method score percentile outcome estimate
1 gam -0.70851973 0.025 0 0.2280920
2 gam -0.31936674 0.050 1 0.3036047
3 gam -0.28965963 0.075 0 0.3099183
4 gam -0.26854024 0.100 0 0.3144504
5 gam -0.21579546 0.125 0 0.3259235
6 gam -0.12694900 0.150 1 0.3457244
7 gam -0.04228831 0.175 0 0.3651047
8 gam 0.01090609 0.200 0 0.3775141
9 gam 0.09726820 0.225 0 0.3980008
10 gam 0.16686510 0.250 0 0.4147783
11 gam 0.20302153 0.275 0 0.4235757
12 gam 0.21288369 0.300 1 0.4259840
13 gam 0.22782199 0.325 1 0.4296386
14 gam 0.25651524 0.350 1 0.4366793
15 gam 0.29597482 0.375 1 0.4464032
16 gam 0.34292989 0.400 1 0.4580272
17 gam 0.34696534 0.425 0 0.4590285
18 gam 0.37097378 0.450 0 0.4649923
19 gam 0.42893547 0.475 0 0.4794282
20 gam 0.53022892 0.500 1 0.5047243
21 gam 0.54408209 0.525 1 0.5081849
22 gam 0.59036428 0.550 0 0.5197388
23 gam 0.64951309 0.575 1 0.5344723
24 gam 0.71786211 0.600 0 0.5514213
25 gam 0.71962806 0.625 1 0.5518578
26 gam 0.76480480 0.650 1 0.5629956
27 gam 0.78613501 0.675 1 0.5682330
28 gam 0.84226992 0.700 1 0.5819407
29 gam 0.84606645 0.725 0 0.5828634
30 gam 0.84852363 0.750 0 0.5834604
31 gam 0.90794320 0.775 1 0.5978169
32 gam 0.92231184 0.800 1 0.6012645
33 gam 1.02084053 0.825 0 0.6246197
34 gam 1.02111683 0.850 1 0.6246845
35 gam 1.04822764 0.875 0 0.6310149
36 gam 1.12511740 0.900 0 0.6487194
37 gam 1.27747068 0.925 1 0.6825841
38 gam 1.32986226 0.950 0 0.6938183
39 gam 1.35878197 0.975 1 0.6999234
40 gam 1.55167777 1.000 1 0.7387937

---

Code
out2$citl
Output
outcome score percentile method
1 0.5 0.5098193 0.475 Calibration In The Large

---

Code
Expand Down Expand Up @@ -108,6 +163,61 @@
outcome score percentile method
1 0.5 -0.5098193 0.525 Calibration In The Large

---

Code
as.data.frame(out5$data)
Output
method score percentile outcome estimate
1 gam -0.70851973 0.025 0 0.2280920
2 gam -0.31936674 0.050 1 0.3036047
3 gam -0.28965963 0.075 0 0.3099183
4 gam -0.26854024 0.100 0 0.3144504
5 gam -0.21579546 0.125 0 0.3259235
6 gam -0.12694900 0.150 1 0.3457244
7 gam -0.04228831 0.175 0 0.3651047
8 gam 0.01090609 0.200 0 0.3775141
9 gam 0.09726820 0.225 0 0.3980008
10 gam 0.16686510 0.250 0 0.4147783
11 gam 0.20302153 0.275 0 0.4235757
12 gam 0.21288369 0.300 1 0.4259840
13 gam 0.22782199 0.325 1 0.4296386
14 gam 0.25651524 0.350 1 0.4366793
15 gam 0.29597482 0.375 1 0.4464032
16 gam 0.34292989 0.400 1 0.4580272
17 gam 0.34696534 0.425 0 0.4590285
18 gam 0.37097378 0.450 0 0.4649923
19 gam 0.42893547 0.475 0 0.4794282
20 gam 0.53022892 0.500 1 0.5047243
21 gam 0.54408209 0.525 1 0.5081849
22 gam 0.59036428 0.550 0 0.5197388
23 gam 0.64951309 0.575 1 0.5344723
24 gam 0.71786211 0.600 0 0.5514213
25 gam 0.71962806 0.625 1 0.5518578
26 gam 0.76480480 0.650 1 0.5629956
27 gam 0.78613501 0.675 1 0.5682330
28 gam 0.84226992 0.700 1 0.5819407
29 gam 0.84606645 0.725 0 0.5828634
30 gam 0.84852363 0.750 0 0.5834604
31 gam 0.90794320 0.775 1 0.5978169
32 gam 0.92231184 0.800 1 0.6012645
33 gam 1.02084053 0.825 0 0.6246197
34 gam 1.02111683 0.850 1 0.6246845
35 gam 1.04822764 0.875 0 0.6310149
36 gam 1.12511740 0.900 0 0.6487194
37 gam 1.27747068 0.925 1 0.6825841
38 gam 1.32986226 0.950 0 0.6938183
39 gam 1.35878197 0.975 1 0.6999234
40 gam 1.55167777 1.000 1 0.7387937

---

Code
out5$citl
Output
outcome score percentile method
1 0.5 0.5098193 0.475 Calibration In The Large

---

Code
Expand Down
138 changes: 69 additions & 69 deletions tests/testthat/_snaps/getEstimates.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
# getGAMest returns estimates of correct dimensions

Code
res
res1
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.6833384
Expand Down Expand Up @@ -285,7 +285,7 @@
---

Code
res
res2
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.7387937
Expand Down Expand Up @@ -332,7 +332,7 @@
---

Code
res
res3
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.6354516
Expand Down Expand Up @@ -379,7 +379,7 @@
---

Code
res
res4
Output
score percentile outcome estimate
1 1.55167777 1.00000000 1 0.6869731
Expand Down Expand Up @@ -419,7 +419,7 @@
# getCGAMest works

Code
res
res1
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.6899800
Expand Down Expand Up @@ -466,7 +466,7 @@
---

Code
res
res2
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.8173842
Expand Down Expand Up @@ -513,7 +513,7 @@
# getMSPLINEest returns estimates of correct dimensions

Code
res
res1
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.6865854
Expand Down Expand Up @@ -560,7 +560,7 @@
---

Code
res
res2
Output
score percentile outcome estimate
1 1.55167777 1.000 1 0.7473018
Expand Down Expand Up @@ -1343,6 +1343,67 @@
7 0.900
8 1.000

---

Code
out$obslvl
Output
outcome score riskpercentile bin interval min max
1 0 -0.70851973 0.025 1 [0,0.4] 0 0.4
2 1 -0.31936674 0.050 1 [0,0.4] 0 0.4
3 0 -0.28965963 0.075 1 [0,0.4] 0 0.4
4 0 -0.26854024 0.100 1 [0,0.4] 0 0.4
5 0 -0.21579546 0.125 1 [0,0.4] 0 0.4
6 1 -0.12694900 0.150 1 [0,0.4] 0 0.4
7 0 -0.04228831 0.175 1 [0,0.4] 0 0.4
8 0 0.01090609 0.200 1 [0,0.4] 0 0.4
9 0 0.09726820 0.225 1 [0,0.4] 0 0.4
10 0 0.16686510 0.250 1 [0,0.4] 0 0.4
11 0 0.20302153 0.275 1 [0,0.4] 0 0.4
12 1 0.21288369 0.300 1 [0,0.4] 0 0.4
13 1 0.22782199 0.325 1 [0,0.4] 0 0.4
14 1 0.25651524 0.350 1 [0,0.4] 0 0.4
15 1 0.29597482 0.375 1 [0,0.4] 0 0.4
16 1 0.34292989 0.400 1 [0,0.4] 0 0.4
17 0 0.34696534 0.425 2 (0.4,0.75] 0.4 0.75
18 0 0.37097378 0.450 2 (0.4,0.75] 0.4 0.75
19 0 0.42893547 0.475 2 (0.4,0.75] 0.4 0.75
20 1 0.53022892 0.500 2 (0.4,0.75] 0.4 0.75
21 1 0.54408209 0.525 2 (0.4,0.75] 0.4 0.75
22 0 0.59036428 0.550 2 (0.4,0.75] 0.4 0.75
23 1 0.64951309 0.575 2 (0.4,0.75] 0.4 0.75
24 0 0.71786211 0.600 2 (0.4,0.75] 0.4 0.75
25 1 0.71962806 0.625 2 (0.4,0.75] 0.4 0.75
26 1 0.76480480 0.650 2 (0.4,0.75] 0.4 0.75
27 1 0.78613501 0.675 2 (0.4,0.75] 0.4 0.75
28 1 0.84226992 0.700 2 (0.4,0.75] 0.4 0.75
29 0 0.84606645 0.725 2 (0.4,0.75] 0.4 0.75
30 0 0.84852363 0.750 2 (0.4,0.75] 0.4 0.75
31 1 0.90794320 0.775 3 (0.75,1] 0.75 1
32 1 0.92231184 0.800 3 (0.75,1] 0.75 1
33 0 1.02084053 0.825 3 (0.75,1] 0.75 1
34 1 1.02111683 0.850 3 (0.75,1] 0.75 1
35 0 1.04822764 0.875 3 (0.75,1] 0.75 1
36 0 1.12511740 0.900 3 (0.75,1] 0.75 1
37 1 1.27747068 0.925 3 (0.75,1] 0.75 1
38 0 1.32986226 0.950 3 (0.75,1] 0.75 1
39 1 1.35878197 0.975 3 (0.75,1] 0.75 1
40 1 1.55167777 1.000 3 (0.75,1] 0.75 1

---

Code
as.data.frame(out$binlvl)
Output
bin interval n events avg.outcome sd.outcome avg.risk sd.risk
1 1 [0,0.4] 16 7 0.4375 0.5123475 -0.009808285 0.2909537
2 2 (0.4,0.75] 14 7 0.5000 0.5188745 0.641882355 0.1760115
3 3 (0.75,1] 10 6 0.6000 0.5163978 1.156335012 0.2128735
riskpercentile
1 0.40
2 0.75
3 1.00

---

Code
Expand Down Expand Up @@ -1414,64 +1475,3 @@
7 0.900
8 1.000

---

Code
out$obslvl
Output
outcome score riskpercentile bin interval min max
1 0 -0.70851973 0.025 1 [0,0.4] 0 0.4
2 1 -0.31936674 0.050 1 [0,0.4] 0 0.4
3 0 -0.28965963 0.075 1 [0,0.4] 0 0.4
4 0 -0.26854024 0.100 1 [0,0.4] 0 0.4
5 0 -0.21579546 0.125 1 [0,0.4] 0 0.4
6 1 -0.12694900 0.150 1 [0,0.4] 0 0.4
7 0 -0.04228831 0.175 1 [0,0.4] 0 0.4
8 0 0.01090609 0.200 1 [0,0.4] 0 0.4
9 0 0.09726820 0.225 1 [0,0.4] 0 0.4
10 0 0.16686510 0.250 1 [0,0.4] 0 0.4
11 0 0.20302153 0.275 1 [0,0.4] 0 0.4
12 1 0.21288369 0.300 1 [0,0.4] 0 0.4
13 1 0.22782199 0.325 1 [0,0.4] 0 0.4
14 1 0.25651524 0.350 1 [0,0.4] 0 0.4
15 1 0.29597482 0.375 1 [0,0.4] 0 0.4
16 1 0.34292989 0.400 1 [0,0.4] 0 0.4
17 0 0.34696534 0.425 2 (0.4,0.75] 0.4 0.75
18 0 0.37097378 0.450 2 (0.4,0.75] 0.4 0.75
19 0 0.42893547 0.475 2 (0.4,0.75] 0.4 0.75
20 1 0.53022892 0.500 2 (0.4,0.75] 0.4 0.75
21 1 0.54408209 0.525 2 (0.4,0.75] 0.4 0.75
22 0 0.59036428 0.550 2 (0.4,0.75] 0.4 0.75
23 1 0.64951309 0.575 2 (0.4,0.75] 0.4 0.75
24 0 0.71786211 0.600 2 (0.4,0.75] 0.4 0.75
25 1 0.71962806 0.625 2 (0.4,0.75] 0.4 0.75
26 1 0.76480480 0.650 2 (0.4,0.75] 0.4 0.75
27 1 0.78613501 0.675 2 (0.4,0.75] 0.4 0.75
28 1 0.84226992 0.700 2 (0.4,0.75] 0.4 0.75
29 0 0.84606645 0.725 2 (0.4,0.75] 0.4 0.75
30 0 0.84852363 0.750 2 (0.4,0.75] 0.4 0.75
31 1 0.90794320 0.775 3 (0.75,1] 0.75 1
32 1 0.92231184 0.800 3 (0.75,1] 0.75 1
33 0 1.02084053 0.825 3 (0.75,1] 0.75 1
34 1 1.02111683 0.850 3 (0.75,1] 0.75 1
35 0 1.04822764 0.875 3 (0.75,1] 0.75 1
36 0 1.12511740 0.900 3 (0.75,1] 0.75 1
37 1 1.27747068 0.925 3 (0.75,1] 0.75 1
38 0 1.32986226 0.950 3 (0.75,1] 0.75 1
39 1 1.35878197 0.975 3 (0.75,1] 0.75 1
40 1 1.55167777 1.000 3 (0.75,1] 0.75 1

---

Code
as.data.frame(out$binlvl)
Output
bin interval n events avg.outcome sd.outcome avg.risk sd.risk
1 1 [0,0.4] 16 7 0.4375 0.5123475 -0.009808285 0.2909537
2 2 (0.4,0.75] 14 7 0.5000 0.5188745 0.641882355 0.1760115
3 3 (0.75,1] 10 6 0.6000 0.5163978 1.156335012 0.2128735
riskpercentile
1 0.40
2 0.75
3 1.00

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 0010ca6

Please sign in to comment.