note: this is optimized for inverting regressions, but should also do prediction for regular regression at some point

apply_regression(dt, predict, nested_model = FALSE,
  calculate_error = FALSE, model_data = model_data,
  model_name = model_name, model_fit = model_fit,
  model_range = model_range, model_params = model_params,
  predict_value = pred, predict_error = pred_se,
  predict_in_range = pred_in_range, predict_range = NULL)

Arguments

dt

data table with calibrations

predict

which value to calculate, must be one of the regression's independent variables

nested_model

whether the model is nested, if TRUE, must also provide model_params

calculate_error

whether to estimate the standard error from the calibration (using the Wald method), stores the result in the new predict_error column. Note that error calculation slows this function down a fair bit and is therefore disabled by default.

model_data

the nested model data column

model_name

new column with the model formulae or names if supplied

model_fit

the new model objects column

model_range

the range of each variable in the model

model_params

the nested model information (only relevant if nest_model = TRUE)

predict_value

the new column in the model_data that holds the predicted value

predict_error

the new column in the model_data that holds the error of the predicted value (only created if calculate_error = TRUE)

predict_in_range

the new column in the model_data that holds whether a data entry is within the range of the calibration. Checks whether all dependent and independent variables in the regression model are within the range of the calibration and sets the predict_in_range flag to FALSE if any(!) of them are not - i.e. this column provides information on whether new values are extrapolated beyond a calibration model and treat the extrapolated ones with the appropriate care. Note that all missing predicted values (due to missing parameters) are also automatically flagged as not in range (predict_in_range = FALSE).

predict_range

vector of 2 numbers, if provided will be used for finding the solution for the predict variable. By default uses the range observed in the calibration variables. Specifying the predict_range is usually only necessary if the calibration range should be extrapolated significantely.