R Studio
# Function must be called predict_VOD and have these arguments predict_VOD <- function (lse, newdata){ # Make any transformations (either dependent or independent variables) # Tranfromations must be updated in both lse and newdata lse$STJ.sq <- lse$STJ^2 newdata$STJ.sq <- newdata$STJ^2 # Fit a model (note this is not a good model - just an example) VOD.lm <- lm(VOD ~ STJ.sq + Year, data = lse) # Extract and return the model predictions on the new data set predictions <- predict(VOD.lm, newdata = newdata) return(predictions) }