EDIT the data is here
https://www.dropbox.com/s/ufrqesp1tmeh3ll/my.data.csv?dl=0
My data consists of a crop yield value collected over multiple locations and year. This is what my data looks like:
yield admin1 admin2 x1 x2 year
6000 31 31002 0.61842540 0.5265148 -1.63343256
7000 31 31002 0.61842540 0.5265148 -1.05893532
6500 31 31002 0.61842540 0.5265148 -0.48443809
7800 31 31002 0.03556101 0.1613198 -0.19718947
7500 31 31002 0.61842540 0.5265148 0.09005915
8500 31 31002 -0.44165048 -0.1268841 0.37730777
The locations from which yield data are collected are nested within admin2 and admin2 are nested with admin1. I have two indepenent variables x1 and x2. I did some pre-processing such that x1 and x2 are in standardised units (i.e. from original x1 and x2, I subtracted the respective mean and divided by the respective SD. Same was done for the year variable) Some raw plots:
There is weak quadratic relationship between yield
with x1
and x2
. I fitted a mixed model:
mod <- lmer(log(yield) ~ x1 + x2 + year + (year |admin1/admin2), REML = FALSE, data = dat)
summary(mod)
Fixed effects:
Estimate Std. Error t value
(Intercept) 8.41458 0.08582 98.054
x1 -0.07341 0.01559 -4.709
x2 0.13192 0.01522 8.667
year 0.11647 0.02992 3.893
One thing I do not understand is why the coefficient of x1 is negative. Given the raw plot, the coefficient of x1 and x2 should be positive since they have a positive relationship with yield. Even if x1 and x2 are correlated, the correlation is positive so they should not reverse their coefficients sign.
My ultimate aim is to predict yield as a function of x1 and x2
EDIT
I followed the suggesting in the comment and plotted x1 and log yield for different range of x2 and this is what I get. Could anyone tell me what does it tell me w.r.t to why the signs of x1 and x2 are opposite in the model and if does it affect my predictions (I am more interested in the prediction than the sign of the regression coefficient itself).
EDIT
Following Ben's explanation, I am extending this question to get more understanding
x1
and x2
are variables that measure the water availability to crops so as x1 or x2 increases (better water availability), the yield should go up as well (i.e. a positive correlation of x1 and x2 with yield which the univariate plots show). Does this result mean that I cannot use this model for any prediction since the coefficient of x1 is wrong (negative indicting yield goes down with increasing x1) or does it mean that interpreting the reg coefficients as it is not practical in this case?