Skip to content

Commit de0747c

Browse files
authored
Merge pull request #84 from NSAPH-Software/JOSS
Joss
2 parents 7456a22 + 4de488f commit de0747c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+932
-677
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
matrix:
2424
config:
2525
- {os: windows-latest, r: 'release'}
26-
#- {os: macOS-latest, r: 'release'} #deactivate until snprintf issue resolves.
26+
- {os: macOS-latest, r: 'release'}
2727
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
2828
#- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
2929

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
- `estimate_cerf_nngp` takes `outcome_col`, `treatment_col`, and `covariates_col` names as inputs.
66
- `estimate_cerf_gp` takes `outcome_col`, `treatment_col`, and `covariates_col` names as inputs.
77

8+
## Added
9+
10+
- `estimate_cerf_gp` and `estimate_cerf_nngp` have notes on selecting `w`.
11+
12+
813

914
# GPCERF 0.2.2 (2024-02-16)
1015

R/estimate_cerf_gp.R

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#' for the provided set of hyperparameters.
88
#'
99
#' @param data A data.frame of observation data.
10-
#' @param w A vector of exposure level to compute CERF.
10+
#' @param w A vector of exposure level to compute CERF (please also see the
11+
#' notes).
1112
#' @param gps_m An S3 gps object including:
1213
#' gps: A data.frame of GPS vectors.
1314
#' - Column 1: GPS
@@ -31,6 +32,18 @@
3132
#' used by internal packages.
3233
#' @param kernel_fn A kernel function. A default value is a Gaussian Kernel.
3334
#'
35+
#' @note
36+
#' Please note that `w` is a vector representing a grid of exposure levels at
37+
#' which the CERF is to be estimated. This grid can include both observed and
38+
#' hypothetical values of the exposure variable. The purpose of defining this
39+
#' grid is to provide a structured set of points across the exposure spectrum
40+
#' for estimating the CERF. This approach is essential in nonparametric models
41+
#' like Gaussian Processes (GPs), where the CERF is evaluated at specific points
42+
#' to understand the relationship between the exposure and outcome variables
43+
#' across a continuum. It facilitates a comprehensive analysis by allowing
44+
#' practitioners to examine the effect of varying exposure levels, including
45+
#' those not directly observed in the dataset.
46+
#'
3447
#' @return
3548
#' A cerf_gp object that includes the following values:
3649
#' - w, the vector of exposure levels.
@@ -221,8 +234,6 @@ estimate_cerf_gp <- function(data, w, gps_m, params,
221234
})
222235
}
223236

224-
logger::log_debug("Number of generated tuning results: {length(tune_res)}")
225-
226237
# Tuning results include:
227238
# cb: covariate balance for each confounder. This is the average of all
228239
# all covariate balance for each requested exposure values.
@@ -235,6 +246,7 @@ estimate_cerf_gp <- function(data, w, gps_m, params,
235246
# Select the combination of hyperparameters that provides the lowest
236247
# covariate balance ----------------------------------------------------------
237248
if (nrow(tune_params_subset) > 1) {
249+
logger::log_debug("Number of generated tuning results: {length(tune_res)}")
238250
opt_idx <- order(sapply(tune_res, function(x) {mean(x$cb)}))[1]
239251
} else {
240252
opt_idx <- 1

R/estimate_cerf_nngp.R

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#' match (the lowest covariate balance) for the provided set of hyperparameters.
99
#'
1010
#' @param data A data.frame of observation data.
11-
#' @param w A vector of exposure level to compute CERF.
11+
#' @param w A vector of exposure level to compute CERF (please also see the
12+
#' notes).
1213
#' @param gps_m An S3 gps object including:
1314
#' gps: A data.frame of GPS vectors.
1415
#' - Column 1: GPS
@@ -36,6 +37,18 @@
3637
#' @param nthread An integer value that represents the number of threads to be
3738
#' used by internal packages.
3839
#'
40+
#' @note
41+
#' Please note that `w` is a vector representing a grid of exposure levels at
42+
#' which the CERF is to be estimated. This grid can include both observed and
43+
#' hypothetical values of the exposure variable. The purpose of defining this
44+
#' grid is to provide a structured set of points across the exposure spectrum
45+
#' for estimating the CERF. This approach is essential in nonparametric models
46+
#' like Gaussian Processes (GPs), where the CERF is evaluated at specific points
47+
#' to understand the relationship between the exposure and outcome variables
48+
#' across a continuum. It facilitates a comprehensive analysis by allowing
49+
#' practitioners to examine the effect of varying exposure levels, including
50+
#' those not directly observed in the dataset.
51+
#'
3952
#' @return
4053
#' A cerf_nngp object that includes the following values:
4154
#' - w, the vector of exposure levels.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Optimal hyper parameters(#trial: 300):
7373
alpha = 12.9154966501488 beta = 12.9154966501488 g_sigma = 0.1
7474
7575
Optimal covariate balance:
76-
cf1 = 0.072
76+
cf1 = 0.069
7777
cf2 = 0.082
78-
cf3 = 0.062
79-
cf4 = 0.068
78+
cf3 = 0.063
79+
cf4 = 0.066
8080
cf5 = 0.056
81-
cf6 = 0.082
81+
cf6 = 0.081
8282
8383
Original covariate balance:
8484
cf1 = 0.222
@@ -87,7 +87,7 @@ Original covariate balance:
8787
cf4 = 0.318
8888
cf5 = 0.198
8989
cf6 = 0.257
90-
----***----
90+
----***----
9191
```
9292

9393
<p>
@@ -148,10 +148,10 @@ Optimal hyper parameters(#trial: 300):
148148
alpha = 0.0278255940220712 beta = 0.215443469003188 g_sigma = 0.1
149149
150150
Optimal covariate balance:
151-
cf1 = 0.058
152-
cf2 = 0.071
153-
cf3 = 0.087
154-
cf4 = 0.066
151+
cf1 = 0.062
152+
cf2 = 0.070
153+
cf3 = 0.091
154+
cf4 = 0.062
155155
cf5 = 0.076
156156
cf6 = 0.088
157157
@@ -162,7 +162,7 @@ Original covariate balance:
162162
cf4 = 0.296
163163
cf5 = 0.208
164164
cf6 = 0.225
165-
----***----
165+
----***----
166166
```
167167

168168
<p>

docker_singularity/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ RUN R -e "install.packages(c( \
3030
'rlang', \
3131
'Rfast', \
3232
'SuperLearner', \
33+
'ranger', \
3334
'wCorr'), repos='https://cloud.r-project.org')"
3435

35-
ENV RENV_VERSION 0.15.1
3636
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
37-
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"
37+
3838

docker_singularity/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Run the following code to download and spin up the image.
3737

3838
```s
3939
docker run -it --rm \
40-
-p 8230:8787 \
40+
-p 8231:8787 \
4141
-e USER=rstudio \
4242
-e PASSWORD=pass \
43-
-v "/path/to/your/folder/on/host:/home/rstudio/Project" nsaphsoftware/gpcerf_dev
43+
-v $PWD:/home/rstudio/Project nsaphsoftware/gpcerf_dev
4444
4545
```

functional_tests/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

functional_tests/ft_compute_deriv_nn.R

Lines changed: 0 additions & 14 deletions
This file was deleted.

functional_tests/ft_compute_derive_weights_gp.R

Lines changed: 0 additions & 11 deletions
This file was deleted.

functional_tests/ft_compute_inverse.R

Lines changed: 0 additions & 35 deletions
This file was deleted.

functional_tests/ft_compute_m_sigma.R

Lines changed: 0 additions & 24 deletions
This file was deleted.

functional_tests/ft_compute_posterior_m_nn.R

Lines changed: 0 additions & 51 deletions
This file was deleted.

functional_tests/ft_compute_posterior_sd_nn.R

Lines changed: 0 additions & 41 deletions
This file was deleted.

functional_tests/ft_compute_sd_gp.R

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)