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)
}

Try the TPP package in your browser

Any scripts or data that you put into this service are public.

TPP documentation built on Nov. 8, 2020, 5:55 p.m.