Hi, I'm trying to plot the original date with the predictions of the best models using curve() because I'm working with polynomial models, but I keep getting this error:
Error in curve(predict(best_models[[i]]$best_model, newdata = data.frame(get(normalized_columns[i]))), :
'expr' must be a function, or a call or an expression containing 'x'
This is the part of the code that it is generating the error:
# Plot the real data vs. the best model for each combination par(mfrow = c(2, 3)) # Arrange plots in a 2x3 grid for (i in 1:6) { curve(predict(best_models[[i]]$best_model, newdata = data.frame(get(normalized_columns[i]))), from = min(filtered_resp_data[[normalized_columns[i]]]), to = max(filtered_resp_data[[normalized_columns[i]]]), col = "blue", lwd = 2, xlab = normalized_columns[i], ylab = "xxx", main = paste("Real Data vs. Best Model (Degree", best_models[[i]]$best_degree, ")"))
This is saying that the first argument you should supply to curve() should be a function, whereas you supplied data instead. Could I ask what led you to use curve()?