Reduction in variance is a standard technique for assessing regression tree split purity. It would be great to implement a function in utility.cpp with the following inputs:
y_node (type: arma::vec) the outcome values in the current tree node
w_node (type: arma::vec) a vector of non-zero weights (integer valued) the same length as y_node
g_node (type: arma::uvec) a vector of 0s and 1s the same length as y_node, with 0 indicating going to the left child node and 1 indicating the right.
The excerpt below from Ishwaran et al 2014 summarizes the reduction in variance computation very well. We will need to code this, incorporating weights through w_node. Should be able to check that the function gives the exact right answer using matrixStats::weightedVar. @ciaran-evans, would you like to look into this? You could actually write the function as a stand-alone function in orsf_oop.cpp with the usual //[Rcpp::export] tag rather than put it into utility.cpp, and I could move it over when it's ready. Basically we would just want the function to be named compute_var_reduction and we would want to create the file tests/testthat/test-compute_var_reduction.R that tests to make sure our variance reduction function gives the same answer as a function written in R.
Reduction in variance is a standard technique for assessing regression tree split purity. It would be great to implement a function in utility.cpp with the following inputs:
y_node
(type:arma::vec
) the outcome values in the current tree nodew_node
(type:arma::vec
) a vector of non-zero weights (integer valued) the same length asy_node
g_node
(type:arma::uvec
) a vector of 0s and 1s the same length asy_node
, with 0 indicating going to the left child node and 1 indicating the right.The excerpt below from Ishwaran et al 2014 summarizes the reduction in variance computation very well. We will need to code this, incorporating weights through
w_node
. Should be able to check that the function gives the exact right answer usingmatrixStats::weightedVar
. @ciaran-evans, would you like to look into this? You could actually write the function as a stand-alone function inorsf_oop.cpp
with the usual//[Rcpp::export]
tag rather than put it intoutility.cpp
, and I could move it over when it's ready. Basically we would just want the function to be namedcompute_var_reduction
and we would want to create the filetests/testthat/test-compute_var_reduction.R
that tests to make sure our variance reduction function gives the same answer as a function written in R.