1
$\begingroup$

I have a set of data I'm analyzing in R with 2 explanatory variables (X1 and X2), and one response variable (Y).

X1<-c(1,2,2,4,5,8,5,4,3,2,1,0,1,2,3,4,6,6,5,4,3,2,1,0,1,1,3,4,3,6,5,5,3,2,1)
X2<-c(20,40,50,40,50,50,50,30,10,5,10,20,10,10,10,10,50,80,20,10,20,40,40,40,5,20,30,40,50,60,20,20,10,20,10)
Y<-c(70,140,200,240,250,250,250,230,160,105,60,20,60,110,160,210,250,250,250,210,170,140,90,40,55,120,180,240,250,250,250,220,160,120,60)

MyData<-data.frame(X1,X2,Y)

My goal is to calculate an equation that will allow me to predict Y based on future X1 and Y1 values. In the past I have used a linear regression like so:

MyFit<-lm(Y~X1+X2,data=MyData)

And then use this formula to predict Y

Y= coefficients(MyFit)[1]+coefficients(MyFit)[2]*X1+coefficients(MyFit)[3]*X2

In the above dummy set, Y is strongly driven by X1. But the issue with my real data is that at some point Y gets saturated, so that further increases in X1 do not bring about increases in Y (for this data the saturation value is 250, but the actual values begin to slow down and form a saturation curve as it approaches peak value, as opposed to an absolute saturation point). The result is that the linear model will always over-predict the peak Y values. This can be seen in a plot here:

plot(Y,type="l",ylim=c(0,350))
lines(X1,col='red')
lines(X2,col='blue')
lines(coefficients(MyFit)[1]+coefficients(MyFit)[2]*X1+coefficients(MyFit)[3]*X2,col='green')

How can I correct for this. Is it possible to do a multiple non-linear regression for this data? Or is there some other technique I can use here?

$\endgroup$
  • 2
    $\begingroup$ A side note: Instead of Y= coefficients(MyFit)[1]+coefficients(MyFit)[2]*X1+coefficients(MyFit)[3]*X2 simply use predict(object = MyFit) $\endgroup$ – Helix123 Mar 8 '16 at 17:27
  • 1
    $\begingroup$ If you've some theory to suggest an asymptote - rather than a mere tailing off - it could be worth looking at simple non-linear models. $\endgroup$ – Scortchi Mar 8 '16 at 17:31
  • 1
    $\begingroup$ What are y, x1 and x2? $\endgroup$ – Roland Mar 9 '16 at 16:22
  • $\begingroup$ The above is dummy data that approximates an issue I'm having with an actual data set. So in this case Y is my response variable (Photosynthetic output), and X1 (Light) and X2 (wind) would be my explanatory variables. $\endgroup$ – Vinterwoo Mar 9 '16 at 23:41
  • $\begingroup$ Then theory & your dummy data concur in suggesting a hyperbolic growth curve for the relationship between photosynthetic rate & light intensity mightn't be a bad model. Wind, up to a point, presumably aids photosynthesis by increasing transpiration, but does it affect the saturated rate or the half-saturation constant, or both? You also need to think about the error structure - is variability in rate roughly the same after light & wind are accounted for? It'd be a good idea to include additional information in your question rather than in comments. $\endgroup$ – Scortchi Mar 10 '16 at 12:53

Your Answer

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

Browse other questions tagged or ask your own question.