# Wrong functions fitted opposite to raw data

I need advice on fitted functions in the below image.

I fitted the below function using a multivariate adaptive regression splines from the earth package in R.

   fit <- earth(x = pred, y = resp, keepxy = T,newvar.penalty = 2, degree= 1,pmethod = "cv", nfold = 10, ncross =3, varmod.method = "rlm")


Visually seeing, the line should always go down but as you can see for the later part of the data, my function goes up even though there are not really data. I am not sure why this is happening. Any advice

Since we don't have access to your data, it's difficult to give a definitive answer. However, if you have more than one variable in the input matrix x, then this kind of behaviour (where the model curve doesn't appear to follow the data) is common, because the graph plots a slice through the data for one variable in isolation, but the model is built using all the variables.
For a simple 2D example of this, see the the cover page of the vignette for the plotmo package. On that cover page, we can see how in the humidity degree1 plot, the MARS curve doesn't appear to follow the dots for the plotted response. (In your example, the effect is more extreme.)
• Thank you for your answer. Yes I have multiple predictors. I am slightly confused about the line when it says 'taking into account the interactive effect of other variables'. If I understand the earth 's degree= 1, it means no interaction is modeled yet your answer seems to suggest that this is the case in the above model. Let me get back to this again after running the model just in case I have done something wrong. I would appreciate if you could reply to my question again when I tag it with mars. I am quite liking this package. Jan 26, 2018 at 14:41