% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pls-modeling.R
\name{fit_rf}
\alias{fit_rf}
\title{Calibration sampling, and random forest model tuning and evaluation}
\usage{
fit_rf(
  spec_chem,
  response,
  variable = NULL,
  evaluation_method = "test_set",
  validation = NULL,
  split_method = "ken_stone",
  ratio_val,
  ken_sto_pc = 2,
  pc = NULL,
  invert = TRUE,
  tuning_method = "resampling",
  resampling_seed = 123,
  cv = NULL,
  ntree_max = 500,
  print = TRUE,
  env = parent.frame()
)
}
\arguments{
\item{spec_chem}{Tibble that contains spectra, metadata and chemical
reference as list-columns. The tibble to be supplied to \code{spec_chem} can
be generated by the \verb{join_chem_spc() function}}

\item{response}{Response variable as symbol or name
(without quotes, no character string). The provided response symbol needs to be
a column name in the \code{spec_chem} tibble.}

\item{variable}{Depreciated and replaced by \code{response}}

\item{evaluation_method}{Character string stating evaluation method.
Either \code{"test_set"} (default) or \code{"resampling"}. \code{"test_set"}
will split the data into a calibration (training) and validation (test) set,
and evaluate the final model by predicting on the validation set.
If \code{"resampling"}, the finally selected model will be evaluated based
on the cross-validation hold-out predictions.}

\item{validation}{Depreciated and replaced by \code{evaluation_method}.
Default is \code{TRUE}.}

\item{split_method}{Method how to to split the data into a independent test
set. Default is \code{"ken_sto"}, which will select samples for calibration
based on Kennard-Stone sampling algorithm of preprocessed spectra. The
proportion of validation to the total number of samples can be specified
in the argument \code{ratio_val}.
\code{split_method = "random"} will create a single random split.}

\item{ratio_val}{Ratio of validation (test) samples to
total number of samples (calibration (training) and validation (test)).}

\item{ken_sto_pc}{Number of component used
for calculating mahalanobsis distance on PCA scores for computing
Kennard-Stone algorithm.
Default is \code{ken_sto_pc = 2}, which will use the first two PCA
components.}

\item{pc}{Depreciated; renamed argument is \code{ken_sto_pc}.}

\item{invert}{Logical}

\item{tuning_method}{Character specifying tuning method. Tuning method
affects how caret selects a final tuning value set from a list of candidate
values. Possible values are \code{"resampling"}, which will use a
specified resampling method such as repeated k-fold cross-validation (see
argument \code{resampling_method}) and the generated performance profile
based on the hold-out predictions to decide on the final tuning values
that lead to optimal model performance. The value \code{"none"} will force
caret to compute a final model for a predefined canditate PLS tuning
parameter number of PLS components. In this case, the value
supplied by \code{ncomp_fixed}` is used to set model complexity at
a fixed number of components.}

\item{resampling_seed}{Random seed (integer) that will be used for generating
resampling indices, which will be supplied to \code{caret::trainControl}.
This makes sure that modeling results are constant when re-fitting.
Default is \code{resampling_seed = 123}.}

\item{cv}{Depreciated. Use \code{resampling_method} instead.}

\item{ntree_max}{Maximum random forest trees
by caret::train. Caret will aggregate a performance profile using resampling
for an integer sequence from 1 to \code{ntree_max} trees.}

\item{print}{Logical expression whether model evaluation graphs shall be
printed}

\item{env}{Environment where function is evaluated. Default is
\code{parent.frame}.}
}
\description{
Perform calibration sampling and use selected
calibration set for model tuning
}
