R/fit_and_eval_spline_model.R

Defines functions fit_and_eval_spline_model

fit_and_eval_spline_model <- function(df, xNew, modelFormula){
  splineFit <- try(rlm(as.formula(modelFormula), 
                       data = df, maxit = 150),
                   silent = TRUE)
  if (!inherits(splineFit, "try-error")){
    yNew <- predict(splineFit, list(x = xNew))
  } else {
    yNew <- NA
  }
  normDF <- data.frame(x = xNew, splinePrediction = yNew)
  return(normDF)
}
DoroChilds/TPP documentation built on Oct. 31, 2021, 4:38 a.m.