Skip to contents

Uses randomForest if available; otherwise a base-R bagged-tree fallback (regression CART approximation).

Usage

morie_random_forest_genomic(
  x,
  y,
  markers,
  n_trees = 100,
  max_depth = 10,
  min_samples = 2,
  mtry = NULL,
  seed = 0
)

Arguments

x

Optional fixed features.

y

Numeric response.

markers

Genotype matrix (n x m).

n_trees

Number of trees.

max_depth

Max depth (fallback only).

min_samples

Min samples per node.

mtry

Features sampled per split (default sqrt(p)).

seed

Seed.

Value

list(estimate, y_hat, oob_score, feature_importance, se, n, method).

References

Breiman (2001); Montesinos Lopez Ch 8.

Examples

morie_random_forest_genomic(
  x = rnorm(50), y = rnorm(50),
  markers = matrix(sample(0:2, 200, TRUE), 50, 4)
)
#> $estimate
#> [1] 0.04133773
#> 
#> $y_hat
#>  [1]  0.87796540 -0.03267344  0.59046456  0.80755538  0.13345728 -0.99881454
#>  [7] -0.17353656  0.22553557 -0.01886791  0.95595815  0.25591696 -0.53712656
#> [13] -0.43009324 -0.44239406 -0.11943384 -0.03861692  0.15031785 -0.31710698
#> [19]  0.28967984 -0.45361604  0.15958612  0.29405903  0.05729526  0.40676516
#> [25]  0.07694331  0.30428754  0.59389212 -0.38424570 -0.72597663  0.04516415
#> [31] -0.17471441 -0.15130612  0.01359717 -0.21868395  0.55259965  0.49180149
#> [37]  0.37210769  0.02785734  0.66891176 -0.15313767  0.85406603  0.41776842
#> [43] -0.07973291 -0.54711869 -0.87353891 -0.82100383 -0.66864688  0.60795225
#> [49]  0.44352465 -0.24775764
#> 
#> $oob_score
#> [1] -0.438014
#> 
#> $feature_importance
#> [1] -2.9445062  1.2192296 -0.7008286 -2.6930657 -2.5662108
#> 
#> $se
#> [1] 0.4846495
#> 
#> $n
#> [1] 50
#> 
#> $method
#> [1] "randomForest::randomForest"
#>