R/predict_mm.R

Defines functions predict_mm

Documented in predict_mm

#' Make MM Equation predictions for plotting
#'
#' @param mm_model
#'
#' @return a tibble of theoretetical conc values and their estimated y-values using the parameters generated by the fit of the MM model
#' @export
#'
#' @examples predict_hill(my_drm_model)
predict_mm <- function(mm_model){

  # Makes a list of a lot of random conc values.
  theoretical_concentration_values <- data.frame(conc = seq(0, 4000, by = 0.1))

  # This will make y-predictions based off the theoretical "x" values provided in the "theorectical_pCa_values" list and will include confidence intervals
  predicted_model_values <- predict(mm_model, newdata = theoretical_concentration_values, interval = "confidence", level = 0.95)
  predicted_model_values <- as.tibble(predicted_model_values)


  # Take the predicted values tibble provided from "predicted_model_values" and add the theoretical_conc values as a column

  final_prediction_tibble <- predicted_model_values %>%
    mutate(theoretical_conc = theoretical_concentration_values$conc)

  final_prediction_tibble %>% dplyr::rename(predicted_y = Prediction, lower_error = Lower, upper_error = Upper)

}
brentscott93/biophysr documentation built on Sept. 14, 2021, 2:35 a.m.