Skip to content

Commit 1909782

Browse files
committed
Updated R package code after running and fixing many CRAN errors/warnings/notes
1 parent c222c9a commit 1909782

Some content is hidden

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

52 files changed

+553
-174
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Authors@R:
99
person("Carlos", "Carvalho", role = "aut"),
1010
person("Jingyu", "He", role = "aut")
1111
)
12-
Description: Stochastic tree ensembles (XBART and BART) for supervised learning and causal inference
12+
Description: Stochastic tree ensembles (XBART and BART) for supervised learning and causal inference.
1313
License: MIT + file LICENSE
1414
Encoding: UTF-8
1515
Roxygen: list(markdown = TRUE)
@@ -29,6 +29,7 @@ Suggests:
2929
VignetteBuilder: knitr
3030
SystemRequirements: C++17
3131
Imports:
32-
R6
32+
R6,
33+
stats
3334
URL: https://stochastictree.github.io/stochtree-r/
3435
Config/testthat/edition: 3

LICENSE

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
MIT License
2-
3-
Copyright (c) 2024 Drew Herren
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
YEAR: 2024
2+
COPYRIGHT HOLDER: stochtree authors

NAMESPACE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ export(preprocessTrainMatrix)
4343
export(sample_sigma2_one_iteration)
4444
export(sample_tau_one_iteration)
4545
export(saveBCFModelToJsonFile)
46+
importFrom(R6,R6Class)
47+
importFrom(stats,lm)
48+
importFrom(stats,model.matrix)
49+
importFrom(stats,qgamma)
50+
importFrom(stats,resid)
51+
importFrom(stats,rnorm)
52+
importFrom(stats,sd)
53+
importFrom(stats,sigma)
54+
importFrom(stats,var)
4655
useDynLib(stochtree, .registration = TRUE)

R/bart.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
#' We do not currently support (but plan to in the near future), test set evaluation for group labels
2525
#' that were not in the training set.
2626
#' @param rfx_basis_test (Optional) Test set basis for "random-slope" regression in additive random effects model.
27-
#' @param variable_weights Vector of length `ncol(X_train)` indicating a "weight" placed on each
28-
#' variable for sampling purposes. Default: `rep(1/ncol(X_train),ncol(X_train))`.
2927
#' @param cutpoint_grid_size Maximum size of the "grid" of potential cutpoints to consider. Default: 100.
3028
#' @param tau_init Starting value of leaf node scale parameter. Calibrated internally as `1/num_trees` if not set here.
3129
#' @param alpha Prior probability of splitting for a tree of depth 0. Tree split prior combines `alpha` and `beta` via `alpha*(1+node_depth)^-beta`.
3230
#' @param beta Exponent that decreases split probabilities for nodes of depth > 0. Tree split prior combines `alpha` and `beta` via `alpha*(1+node_depth)^-beta`.
31+
#' @param leaf_model Model to use in the leaves, coded as integer with (0 = constant leaf, 1 = univariate leaf regression, 2 = multivariate leaf regression). Default: 0.
3332
#' @param min_samples_leaf Minimum allowable size of a leaf, in terms of training samples. Default: 5.
3433
#' @param nu Shape parameter in the `IG(nu, nu*lambda)` global error variance model. Default: 3.
3534
#' @param lambda Component of the scale parameter in the `IG(nu, nu*lambda)` global error variance prior. If not specified, this is calibrated as in Sparapani et al (2021).
@@ -298,7 +297,7 @@ bart <- function(X_train, y_train, W_train = NULL, group_ids_train = NULL,
298297

299298
# Variable selection weights
300299
variable_weights <- rep(1/ncol(X_train), ncol(X_train))
301-
300+
302301
# Run GFR (warm start) if specified
303302
if (num_gfr > 0){
304303
gfr_indices = 1:num_gfr
@@ -611,7 +610,7 @@ predict.bartmodel <- function(bart, X_test, W_test = NULL, group_ids_test = NULL
611610
#' Extract raw sample values for each of the random effect parameter terms.
612611
#'
613612
#' @param object Object of type `bcf` containing draws of a Bayesian causal forest model and associated sampling outputs.
614-
#'
613+
#' @param ... Other parameters to be used in random effects extraction
615614
#' @return List of arrays. The alpha array has dimension (`num_components`, `num_samples`) and is simply a vector if `num_components = 1`.
616615
#' The xi and beta arrays have dimension (`num_components`, `num_groups`, `num_samples`) and is simply a matrix if `num_components = 1`.
617616
#' The sigma array has dimension (`num_components`, `num_samples`) and is simply a vector if `num_components = 1`.
@@ -629,7 +628,7 @@ predict.bartmodel <- function(bart, X_test, W_test = NULL, group_ids_test = NULL
629628
#' )
630629
#' snr <- 3
631630
#' group_ids <- rep(c(1,2), n %/% 2)
632-
#' rfx_coefs <- matrix(c(-1, -1, 1, 1),nrow=2,byrow=T)
631+
#' rfx_coefs <- matrix(c(-1, -1, 1, 1), nrow=2, byrow=TRUE)
633632
#' rfx_basis <- cbind(1, runif(n, -1, 1))
634633
#' rfx_term <- rowSums(rfx_coefs[group_ids,] * rfx_basis)
635634
#' E_y <- f_XW + rfx_term
@@ -652,7 +651,7 @@ predict.bartmodel <- function(bart, X_test, W_test = NULL, group_ids_test = NULL
652651
#' bart_model <- bart(X_train = X_train, y_train = y_train,
653652
#' group_ids_train = group_ids_train, rfx_basis_train = rfx_basis_train,
654653
#' X_test = X_test, group_ids_test = group_ids_test, rfx_basis_test = rfx_basis_test,
655-
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100, sample_tau = T)
654+
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100, sample_tau = TRUE)
656655
#' rfx_samples <- getRandomEffectSamples(bart_model)
657656
getRandomEffectSamples.bartmodel <- function(object, ...){
658657
result = list()

R/bcf.R

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#' x2 <- rnorm(n)
6565
#' x3 <- rnorm(n)
6666
#' x4 <- as.numeric(rbinom(n,1,0.5))
67-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
67+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
6868
#' X <- cbind(x1,x2,x3,x4,x5)
6969
#' p <- ncol(X)
7070
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -80,8 +80,8 @@
8080
#' snr <- 4
8181
#' y <- E_XZ + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
8282
#' X <- as.data.frame(X)
83-
#' X$x4 <- factor(X$x4, ordered = T)
84-
#' X$x5 <- factor(X$x5, ordered = T)
83+
#' X$x4 <- factor(X$x4, ordered = TRUE)
84+
#' X$x5 <- factor(X$x5, ordered = TRUE)
8585
#' test_set_pct <- 0.2
8686
#' n_test <- round(test_set_pct*n)
8787
#' n_train <- n - n_test
@@ -766,7 +766,7 @@ bcf <- function(X_train, Z_train, y_train, pi_train = NULL, group_ids_train = NU
766766
#' x2 <- rnorm(n)
767767
#' x3 <- rnorm(n)
768768
#' x4 <- as.numeric(rbinom(n,1,0.5))
769-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
769+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
770770
#' X <- cbind(x1,x2,x3,x4,x5)
771771
#' p <- ncol(X)
772772
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -782,8 +782,8 @@ bcf <- function(X_train, Z_train, y_train, pi_train = NULL, group_ids_train = NU
782782
#' snr <- 4
783783
#' y <- E_XZ + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
784784
#' X <- as.data.frame(X)
785-
#' X$x4 <- factor(X$x4, ordered = T)
786-
#' X$x5 <- factor(X$x5, ordered = T)
785+
#' X$x4 <- factor(X$x4, ordered = TRUE)
786+
#' X$x5 <- factor(X$x5, ordered = TRUE)
787787
#' test_set_pct <- 0.2
788788
#' n_test <- round(test_set_pct*n)
789789
#' n_train <- n - n_test
@@ -928,7 +928,7 @@ predict.bcf <- function(bcf, X_test, Z_test, pi_test = NULL, group_ids_test = NU
928928
#' Extract raw sample values for each of the random effect parameter terms.
929929
#'
930930
#' @param object Object of type `bcf` containing draws of a Bayesian causal forest model and associated sampling outputs.
931-
#'
931+
#' @param ... Other parameters to be used in random effects extraction
932932
#' @return List of arrays. The alpha array has dimension (`num_components`, `num_samples`) and is simply a vector if `num_components = 1`.
933933
#' The xi and beta arrays have dimension (`num_components`, `num_groups`, `num_samples`) and is simply a matrix if `num_components = 1`.
934934
#' The sigma array has dimension (`num_components`, `num_samples`) and is simply a vector if `num_components = 1`.
@@ -940,7 +940,7 @@ predict.bcf <- function(bcf, X_test, Z_test, pi_test = NULL, group_ids_test = NU
940940
#' x2 <- rnorm(n)
941941
#' x3 <- rnorm(n)
942942
#' x4 <- as.numeric(rbinom(n,1,0.5))
943-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
943+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
944944
#' X <- cbind(x1,x2,x3,x4,x5)
945945
#' p <- ncol(X)
946946
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -955,13 +955,13 @@ predict.bcf <- function(bcf, X_test, Z_test, pi_test = NULL, group_ids_test = NU
955955
#' E_XZ <- mu_x + Z*tau_x
956956
#' snr <- 3
957957
#' group_ids <- rep(c(1,2), n %/% 2)
958-
#' rfx_coefs <- matrix(c(-1, -1, 1, 1),nrow=2,byrow=T)
958+
#' rfx_coefs <- matrix(c(-1, -1, 1, 1), nrow=2, byrow=TRUE)
959959
#' rfx_basis <- cbind(1, runif(n, -1, 1))
960960
#' rfx_term <- rowSums(rfx_coefs[group_ids,] * rfx_basis)
961961
#' y <- E_XZ + rfx_term + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
962962
#' X <- as.data.frame(X)
963-
#' X$x4 <- factor(X$x4, ordered = T)
964-
#' X$x5 <- factor(X$x5, ordered = T)
963+
#' X$x4 <- factor(X$x4, ordered = TRUE)
964+
#' X$x5 <- factor(X$x5, ordered = TRUE)
965965
#' test_set_pct <- 0.2
966966
#' n_test <- round(test_set_pct*n)
967967
#' n_train <- n - n_test
@@ -991,7 +991,7 @@ predict.bcf <- function(bcf, X_test, Z_test, pi_test = NULL, group_ids_test = NU
991991
#' Z_test = Z_test, pi_test = pi_test, group_ids_test = group_ids_test,
992992
#' rfx_basis_test = rfx_basis_test,
993993
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100,
994-
#' sample_sigma_leaf_mu = T, sample_sigma_leaf_tau = F)
994+
#' sample_sigma_leaf_mu = TRUE, sample_sigma_leaf_tau = FALSE)
995995
#' rfx_samples <- getRandomEffectSamples(bcf_model)
996996
getRandomEffectSamples.bcf <- function(object, ...){
997997
result = list()
@@ -1026,7 +1026,7 @@ getRandomEffectSamples.bcf <- function(object, ...){
10261026
#' x2 <- rnorm(n)
10271027
#' x3 <- rnorm(n)
10281028
#' x4 <- as.numeric(rbinom(n,1,0.5))
1029-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
1029+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
10301030
#' X <- cbind(x1,x2,x3,x4,x5)
10311031
#' p <- ncol(X)
10321032
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -1041,13 +1041,13 @@ getRandomEffectSamples.bcf <- function(object, ...){
10411041
#' E_XZ <- mu_x + Z*tau_x
10421042
#' snr <- 3
10431043
#' group_ids <- rep(c(1,2), n %/% 2)
1044-
#' rfx_coefs <- matrix(c(-1, -1, 1, 1),nrow=2,byrow=T)
1044+
#' rfx_coefs <- matrix(c(-1, -1, 1, 1), nrow=2, byrow=TRUE)
10451045
#' rfx_basis <- cbind(1, runif(n, -1, 1))
10461046
#' rfx_term <- rowSums(rfx_coefs[group_ids,] * rfx_basis)
10471047
#' y <- E_XZ + rfx_term + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
10481048
#' X <- as.data.frame(X)
1049-
#' X$x4 <- factor(X$x4, ordered = T)
1050-
#' X$x5 <- factor(X$x5, ordered = T)
1049+
#' X$x4 <- factor(X$x4, ordered = TRUE)
1050+
#' X$x5 <- factor(X$x5, ordered = TRUE)
10511051
#' test_set_pct <- 0.2
10521052
#' n_test <- round(test_set_pct*n)
10531053
#' n_train <- n - n_test
@@ -1077,7 +1077,7 @@ getRandomEffectSamples.bcf <- function(object, ...){
10771077
#' Z_test = Z_test, pi_test = pi_test, group_ids_test = group_ids_test,
10781078
#' rfx_basis_test = rfx_basis_test,
10791079
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100,
1080-
#' sample_sigma_leaf_mu = T, sample_sigma_leaf_tau = F)
1080+
#' sample_sigma_leaf_mu = TRUE, sample_sigma_leaf_tau = FALSE)
10811081
#' # bcf_json <- convertBCFModelToJson(bcf_model)
10821082
convertBCFModelToJson <- function(object){
10831083
jsonobj <- createCppJson()
@@ -1160,7 +1160,7 @@ convertBCFModelToJson <- function(object){
11601160
#' x2 <- rnorm(n)
11611161
#' x3 <- rnorm(n)
11621162
#' x4 <- as.numeric(rbinom(n,1,0.5))
1163-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
1163+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
11641164
#' X <- cbind(x1,x2,x3,x4,x5)
11651165
#' p <- ncol(X)
11661166
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -1175,10 +1175,13 @@ convertBCFModelToJson <- function(object){
11751175
#' E_XZ <- mu_x + Z*tau_x
11761176
#' snr <- 3
11771177
#' group_ids <- rep(c(1,2), n %/% 2)
1178-
#' rfx_coefs <- matrix(c(-1, -1, 1, 1),nrow=2,byrow=T)
1178+
#' rfx_coefs <- matrix(c(-1, -1, 1, 1), nrow=2, byrow=TRUE)
11791179
#' rfx_basis <- cbind(1, runif(n, -1, 1))
11801180
#' rfx_term <- rowSums(rfx_coefs[group_ids,] * rfx_basis)
11811181
#' y <- E_XZ + rfx_term + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
1182+
#' X <- as.data.frame(X)
1183+
#' X$x4 <- factor(X$x4, ordered = TRUE)
1184+
#' X$x5 <- factor(X$x5, ordered = TRUE)
11821185
#' test_set_pct <- 0.2
11831186
#' n_test <- round(test_set_pct*n)
11841187
#' n_train <- n - n_test
@@ -1206,9 +1209,9 @@ convertBCFModelToJson <- function(object){
12061209
#' pi_train = pi_train, group_ids_train = group_ids_train,
12071210
#' rfx_basis_train = rfx_basis_train, X_test = X_test,
12081211
#' Z_test = Z_test, pi_test = pi_test, group_ids_test = group_ids_test,
1209-
#' rfx_basis_test = rfx_basis_test, ordered_cat_vars = c(4,5),
1212+
#' rfx_basis_test = rfx_basis_test,
12101213
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100,
1211-
#' sample_sigma_leaf_mu = T, sample_sigma_leaf_tau = F)
1214+
#' sample_sigma_leaf_mu = TRUE, sample_sigma_leaf_tau = FALSE)
12121215
#' # saveBCFModelToJsonFile(bcf_model, "test.json")
12131216
saveBCFModelToJsonFile <- function(object, filename){
12141217
# Convert to Json
@@ -1232,7 +1235,7 @@ saveBCFModelToJsonFile <- function(object, filename){
12321235
#' x2 <- rnorm(n)
12331236
#' x3 <- rnorm(n)
12341237
#' x4 <- as.numeric(rbinom(n,1,0.5))
1235-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
1238+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
12361239
#' X <- cbind(x1,x2,x3,x4,x5)
12371240
#' p <- ncol(X)
12381241
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -1247,10 +1250,13 @@ saveBCFModelToJsonFile <- function(object, filename){
12471250
#' E_XZ <- mu_x + Z*tau_x
12481251
#' snr <- 3
12491252
#' group_ids <- rep(c(1,2), n %/% 2)
1250-
#' rfx_coefs <- matrix(c(-1, -1, 1, 1),nrow=2,byrow=T)
1253+
#' rfx_coefs <- matrix(c(-1, -1, 1, 1), nrow=2, byrow=TRUE)
12511254
#' rfx_basis <- cbind(1, runif(n, -1, 1))
12521255
#' rfx_term <- rowSums(rfx_coefs[group_ids,] * rfx_basis)
12531256
#' y <- E_XZ + rfx_term + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
1257+
#' X <- as.data.frame(X)
1258+
#' X$x4 <- factor(X$x4, ordered = TRUE)
1259+
#' X$x5 <- factor(X$x5, ordered = TRUE)
12541260
#' test_set_pct <- 0.2
12551261
#' n_test <- round(test_set_pct*n)
12561262
#' n_train <- n - n_test
@@ -1278,9 +1284,9 @@ saveBCFModelToJsonFile <- function(object, filename){
12781284
#' pi_train = pi_train, group_ids_train = group_ids_train,
12791285
#' rfx_basis_train = rfx_basis_train, X_test = X_test,
12801286
#' Z_test = Z_test, pi_test = pi_test, group_ids_test = group_ids_test,
1281-
#' rfx_basis_test = rfx_basis_test, ordered_cat_vars = c(4,5),
1287+
#' rfx_basis_test = rfx_basis_test,
12821288
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100,
1283-
#' sample_sigma_leaf_mu = T, sample_sigma_leaf_tau = F)
1289+
#' sample_sigma_leaf_mu = TRUE, sample_sigma_leaf_tau = FALSE)
12841290
#' # bcf_json <- convertBCFModelToJson(bcf_model)
12851291
#' # bcf_model_roundtrip <- createBCFModelFromJson(bcf_json)
12861292
createBCFModelFromJson <- function(json_object){
@@ -1368,7 +1374,7 @@ createBCFModelFromJson <- function(json_object){
13681374
#' x2 <- rnorm(n)
13691375
#' x3 <- rnorm(n)
13701376
#' x4 <- as.numeric(rbinom(n,1,0.5))
1371-
#' x5 <- as.numeric(sample(1:3,n,replace=T))
1377+
#' x5 <- as.numeric(sample(1:3,n,replace=TRUE))
13721378
#' X <- cbind(x1,x2,x3,x4,x5)
13731379
#' p <- ncol(X)
13741380
#' g <- function(x) {ifelse(x[,5]==1,2,ifelse(x[,5]==2,-1,4))}
@@ -1383,10 +1389,13 @@ createBCFModelFromJson <- function(json_object){
13831389
#' E_XZ <- mu_x + Z*tau_x
13841390
#' snr <- 3
13851391
#' group_ids <- rep(c(1,2), n %/% 2)
1386-
#' rfx_coefs <- matrix(c(-1, -1, 1, 1),nrow=2,byrow=T)
1392+
#' rfx_coefs <- matrix(c(-1, -1, 1, 1), nrow=2, byrow=TRUE)
13871393
#' rfx_basis <- cbind(1, runif(n, -1, 1))
13881394
#' rfx_term <- rowSums(rfx_coefs[group_ids,] * rfx_basis)
13891395
#' y <- E_XZ + rfx_term + rnorm(n, 0, 1)*(sd(E_XZ)/snr)
1396+
#' X <- as.data.frame(X)
1397+
#' X$x4 <- factor(X$x4, ordered = TRUE)
1398+
#' X$x5 <- factor(X$x5, ordered = TRUE)
13901399
#' test_set_pct <- 0.2
13911400
#' n_test <- round(test_set_pct*n)
13921401
#' n_train <- n - n_test
@@ -1414,9 +1423,9 @@ createBCFModelFromJson <- function(json_object){
14141423
#' pi_train = pi_train, group_ids_train = group_ids_train,
14151424
#' rfx_basis_train = rfx_basis_train, X_test = X_test,
14161425
#' Z_test = Z_test, pi_test = pi_test, group_ids_test = group_ids_test,
1417-
#' rfx_basis_test = rfx_basis_test, ordered_cat_vars = c(4,5),
1426+
#' rfx_basis_test = rfx_basis_test,
14181427
#' num_gfr = 100, num_burnin = 0, num_mcmc = 100,
1419-
#' sample_sigma_leaf_mu = T, sample_sigma_leaf_tau = F)
1428+
#' sample_sigma_leaf_mu = TRUE, sample_sigma_leaf_tau = FALSE)
14201429
#' # saveBCFModelToJsonFile(bcf_model, "test.json")
14211430
#' # bcf_model_roundtrip <- createBCFModelFromJsonFile("test.json")
14221431
createBCFModelFromJsonFile <- function(json_filename){

R/generics.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#' Generic function for extracting random effect samples from a model object (BCF, BART, etc...)
22
#'
3+
#' @param object Fitted model object from which to extract random effects
4+
#' @param ... Other parameters to be used in random effects extraction
35
#' @return List of random effect samples
46
#' @export
57
getRandomEffectSamples <- function(object, ...) UseMethod("getRandomEffectSamples")

R/serialization.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ createCppJson <- function() {
369369

370370
#' Create a C++ Json object from a Json file
371371
#'
372+
#' @param json_filename Name of file to read. Must end in `.json`.
372373
#' @return `CppJson` object
373374
#' @export
374375
createCppJsonFile <- function(json_filename) {

R/stochtree-package.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1+
## usethis namespace: start
2+
#' @importFrom stats lm
3+
#' @importFrom stats model.matrix
4+
#' @importFrom stats qgamma
5+
#' @importFrom stats resid
6+
#' @importFrom stats rnorm
7+
#' @importFrom stats sd
8+
#' @importFrom stats sigma
9+
#' @importFrom stats var
10+
#' @importFrom R6 R6Class
11+
## usethis namespace: end
12+
NULL
13+
114
#' @useDynLib stochtree, .registration = TRUE
215
"_PACKAGE"

0 commit comments

Comments
 (0)