0
$\begingroup$

enter image description here

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

$\endgroup$
3
$\begingroup$

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.

In your graph, the effect of the plotted variable has a kink when taking into account the interactive effect of the other 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.)

Figure 5 in the same vignette is another example which shows how the model curve can be counterintuitive when plotted for a single variable in isolation.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – user53020 Jan 26 '18 at 14:41
  • $\begingroup$ An example how the response could go up at the right of the side of the curve even with degree=1: Let's call the variable displayed on the graph x1 and the response y. Consider now another variable x2 that is correlated with x1, with the property that x2 has many cases in the training set where y increases at higher values of x2. Then in the MARS model the effect of x2 on y will override the effect of x1 in that region of the graph, and the model will say y increases in that area for both x1 and x2. $\endgroup$ – Stephen Milborrow Jan 27 '18 at 18:22
  • $\begingroup$ To clarify: when I say "interactive effect of the other variables" I'm referring here to interaction in the actual data (in the real world), which exists independently of whether we choose to model that interaction using the degree argument. $\endgroup$ – Stephen Milborrow Mar 21 '18 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.