Skip to content

Commit e2413f0

Browse files
committed
Updated R kernel code
1 parent eb32b11 commit e2413f0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# stochtree 0.1.2
2+
3+
* Fixed indexing bug in cleanup of grow-from-root (GFR) samples in BART and BCF models
4+
* Avoid using covariate preprocessor in `computeForestLeafIndices` function when a `ForestSamples` object is provided
5+
16
# stochtree 0.1.1
27

38
* Fixed initialization bug in several R package code examples for random effects models

R/kernel.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@ computeForestLeafIndices <- function(model_object, covariates, forest_type=NULL,
8383
if ((!is.data.frame(covariates)) && (!is.matrix(covariates))) {
8484
stop("covariates must be a matrix or dataframe")
8585
}
86-
train_set_metadata <- model_object$train_set_metadata
87-
covariates_processed <- preprocessPredictionData(covariates, train_set_metadata)
86+
if (model_type %in% c("bart", "bcf")) {
87+
train_set_metadata <- model_object$train_set_metadata
88+
covariates_processed <- preprocessPredictionData(covariates, train_set_metadata)
89+
} else {
90+
if (!is.matrix(covariates)) {
91+
stop("covariates must be a matrix since no covariate preprocessor is stored in a `ForestSamples` object provided as `model_object`")
92+
}
93+
covariates_processed <- covariates
94+
}
8895

8996
# Preprocess forest indices
9097
num_forests <- forest_container$num_samples()

0 commit comments

Comments
 (0)