Here's my data.

https://www.dropbox.com/s/puf57efqkdl8zt0/data.csv?dl=0

It's too big, therefore I did not know to use the dput(data) command.

I am using a mixed effect model to model response as a function of 8 climate variables. response is derived from yield of 2 crops yld.lc and yld.nc as follows

response = (yld.lc - yld.nc/yld.nc) * 100

Therefore response is in percentage and can be both negative and positive. In R, the package lme4 can be used to run a mixed model as follows:

library(lme4)
mdl<-lmer(response ~ z.tx + I(z.tx^2) + z.ad + I(z.ad^2) + z.bd + I(z.bd^2) + z.dhs + I(z.dhs^2) + z.nwa + I(z.nwa^2) + z.tr + I(z.tr^2) + z.adr + I(z.adr^2) + z.nhs + I(z.nhs^2) + (1|site.code) + (1|year),data = yd.nc)

I have used the linear as well as quadratic term for all variables.

plot(mdl)
hist(resid(mdl)) # violation of model assumptions
qqnorm(resid(mdl)) # violation of model assumptions
qqline(resid(mdl)) # violation of model assumptions

How do I transform response which is in percentage as well as has both negative and positive percentage values so that my model assumptions are met?

  • Why do you think it needs transformation? – Nick Cox Mar 3 '17 at 16:23
  • My residuals are not normally distributed and there is some evidence of heteroskedasticity. That is why I am want to transform my data. – user53020 Mar 3 '17 at 16:27
  • You mention the least important (normal ...) and the second least important (homo...) ideal conditions for regression. Is there evidence that the linear structure is wrong (most important!)? Backing up, the asymmetry here needs a story. Why not (l - r) / r ? (l - r) / (l + r) might be better behaved. Can you post the data? Looks like you have yld.l yld.r x1 x2 etc. I wouldn't assume that R notation is universally transparent outside an R-specific forum. I confess freely to not knowing what 1|rand1 means. – Nick Cox Mar 3 '17 at 17:21
  • I have edited my question with the example data. Hopefully it is a bit more clear now. – user53020 Mar 3 '17 at 18:33
  • The model and the notation have changed since the first posting. What's most obvious from a very quick look is massive variability (well over a hundred fold variation between min and max) and a suspicion that analysis on the logarithmic scale might be a good idea. As before full understanding of the model notation requires fluency in R. – Nick Cox Mar 3 '17 at 22:12

Things to consider or try:

  • to deal with the negative values you might take the absolute value, but be wary of how interpretation changes if you do this
  • using a nonparametric analysis that "fits" your data better (perhaps ordinal regression like "nnet"
  • using a robust regression available in the "MASS" package to deal with violations of regression assumptions
  • transforming your data with any number of functions (Manikandan provides a basic overview here)
  • Absolute value sounds like a dubious idea in this case. I doubt that any agronomist (or farmer!) would regard {80 and 60} and {60 and 80} for two crop yields as equivalent. – Nick Cox Mar 3 '17 at 17:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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