3
$\begingroup$

I want to analyze my data with linear regression (please see below a subset), but the results do not look realistic and the assumptions are not met. The problem is that I have negative and positive values, I've been struggling trying to find a transformation. I've tried already boxcox,9th root, transformations from package metaphor, transformations mentioned on this post How to transform negative values to logarithms?.

The response variable (Y) is the difference between the proportion of eggs found in a given nest and the expected value of eggs regarding the mean value of the sample; the explanatory variable (X) is the date in which the nest initiated with respect to the population mean.

This is how the histogram and the plots of the complete dataset look like:

enter image description here

enter image description here

Is there any other alternative to analyze this data or to transform the response variable?

Thanks a lot!

structure(list(Y = c(0.372463768115942, 0.186231884057971, 
-0.813768115942029, -1.75169082125604, 0.372463768115942, 0.248309178743961, 
-0.751690821256039, -3.68961352657005, -0.751690821256039, -1.75169082125604, 
-1.75169082125604, -0.813768115942029, 0.310386473429952, 0.124154589371981, 
0.248309178743961, -1.75169082125604, -0.689613526570048, 0.248309178743961, 
-3.68961352657005, 0.372463768115942, 0.248309178743961, -2.62753623188406, 
0.248309178743961, 0.310386473429952, 0.124154589371981, -0.751690821256039, 
0.248309178743961, 0.186231884057971, 0.310386473429952, 0.248309178743961, 
0.248309178743961, 0.186231884057971, -0.875845410628019, 0.248309178743961, 
-0.751690821256039, 0.310386473429952, 0.248309178743961, 0.248309178743961, 
-2.68961352657005, -0.689613526570048, 0.186231884057971, 0.124154589371981, 
0.248309178743961, 0.372463768115942, -1.56545893719807, -0.813768115942029, 
-0.751690821256039, -0.689613526570048, -0.689613526570048, 0.372463768115942, 
0.372463768115942, -0.751690821256039, 0.248309178743961, -1.75169082125604, 
0.310386473429952, 0.248309178743961, -0.627536231884058, 0.310386473429952, 
0.248309178743961, -2.62753623188406, -0.627536231884058, 0.248309178743961, 
-0.689613526570048, -0.813768115942029, -0.751690821256039, -1.56545893719807, 
-0.813768115942029, -0.875845410628019, 0.124154589371981, -0.555128205128205, 
0.190659340659341, 0.127106227106227, 0.127106227106227, 0.190659340659341, 
0.254212454212454, 0.190659340659341, 0.190659340659341, 0.254212454212454, 
-0.745787545787546, 0.317765567765568, 0.317765567765568, 0.381318681318682, 
0.381318681318682, -0.682234432234432, 0.254212454212454, 0.317765567765568, 
0.317765567765568, 0.254212454212454, 0.190659340659341, 0.127106227106227, 
0.127106227106227, 0.190659340659341, 0.254212454212454, -0.745787545787546, 
0.127106227106227, 0.254212454212454, -0.745787545787546, 0.127106227106227, 
0.317765567765568, 0.190659340659341, 0.381318681318682, -0.809340659340659, 
0.317765567765568, -0.745787545787546, 0.254212454212454, -0.745787545787546, 
0.127106227106227, 0.127106227106227, 0.190659340659341, 0.254212454212454, 
0.127106227106227, 0.190659340659341, 0.254212454212454, 0.254212454212454, 
0.381318681318682, 0.190659340659341, 0.127106227106227, 0.254212454212454, 
0.190659340659341, -0.809340659340659, 0.254212454212454, 0.190659340659341, 
-0.809340659340659, -0.745787545787546, -0.682234432234432, -2.74578754578755, 
0.127106227106227, 0.127106227106227, 0.190659340659341, 0.190659340659341, 
0.190659340659341, 0.254212454212454, -0.809340659340659, 0.190659340659341, 
0.190659340659341, 0.317765567765568, 0.127106227106227, 0.190659340659341, 
0.127106227106227, 0.254212454212454, 0.254212454212454, 0.190659340659341, 
0.127106227106227, 0.381318681318682, -1.68223443223443, 0.190659340659341, 
0.254212454212454, 0.190659340659341, 0.190659340659341, -0.872893772893773, 
-0.809340659340659, 0.190659340659341, 0.190659340659341, 0.190659340659341, 
0.254212454212454, 0.254212454212454, 0.254212454212454, 0.444871794871795, 
0.317765567765568, 0.127106227106227, 0.127106227106227, 0.127106227106227, 
0.254212454212454, 0.190659340659341, 0.127106227106227, 0.317765567765568, 
0.127106227106227, -0.745787545787546, -0.809340659340659, 0.190659340659341, 
-0.745787545787546, 0.190659340659341, 0.127106227106227, -0.847089947089947, 
0.152910052910053, 0.267592592592593, 0.152910052910053, 0.191137566137566, 
0.191137566137566, 0.191137566137566, 0.229365079365079, 0.267592592592593, 
0.229365079365079, 0.0764550264550266, 0.152910052910053, 0.191137566137566, 
-3.77063492063492, 0.11468253968254, -0.88531746031746, 0.191137566137566, 
0.191137566137566, 0.191137566137566, 0.191137566137566, 0.152910052910053, 
0.191137566137566, 0.0764550264550266, 0.152910052910053, 0.267592592592593, 
0.191137566137566, 0.191137566137566), X = c(-3, 5, 4, 0, 
-1, -1, 0, 0, 0, 0, -1, 0, -2, 0, -2, 0, 0, 0, -1, -3, -1, 2, 
-1, -3, 3, 1, 1, 3, 2, 0, -1, -1, 0, -3, 0, -2, -2, -2, 0, -1, 
0, 0, -3, -5, -3, 3, -1, 0, -2, -2, -1, -1, -1, 0, -1, -2, -1, 
-3, -1, -1, -3, -4, -3, 1, 2, -1, 2, 5, 5, -5.5, 1.5, -0.5, -1.5, 
-0.5, 0.5, -0.5, 4.5, -2.5, -1.5, -3.5, -1.5, -3.5, -4.5, -4.5, 
-1.5, -2.5, -1.5, -1.5, -0.5, 0.5, -0.5, 4.5, -1.5, 0.5, -0.5, 
-1.5, 2.5, 1.5, -3.5, 0.5, -4.5, 3.5, -1.5, 0.5, -0.5, -2.5, 
7.5, -0.5, -1.5, 0.5, -1.5, -0.5, -2.5, -2.5, -3.5, 1.5, 0.5, 
-0.5, -1.5, 1.5, -1.5, 2.5, 1.5, -1.5, -4.5, 2.5, 0.5, 2.5, -1.5, 
3.5, -0.5, -2.5, 1.5, -1.5, -0.5, -3.5, 1.5, -0.5, 1.5, -2.5, 
-2.5, 1.5, 3.5, -2.5, 0.5, -1.5, -3.5, -1.5, -1.5, 0.5, 2.5, 
2.5, 1.5, 1.5, -0.5, -0.5, -0.5, -5.5, -2.5, 2.5, 1.5, -0.5, 
1.5, 3.5, 0.5, -3.5, 0.5, -4.5, 2.5, -2.5, -0.5, 1.5, 0.5, -0.5, 
-0.5, -6.5, -1.5, -0.5, -3.5, -2.5, -4.5, -3.5, -5.5, 1.5, -2.5, 
-3.5, -2.5, 2.5, 1.5, -1.5, -4.5, -1.5, 0.5, -0.5, -1.5, 0.5, 
-0.5, -2.5, -4.5, -4.5)), .Names = c("Y", "X"), row.names = c(NA, 
200L), class = "data.frame")

UPDATE: Model gym with offset, poisson:

binomial regression with weights for denominator

enter image description here

SOLUTION:

No over dispersion for this model, c_hat=0.3743403enter image description here

$\endgroup$
  • $\begingroup$ You said: "(Y) is the difference between the proportion of eggs found in a given nest and the expected value of eggs regarding the mean value of the sample". Firstly: what is the point of subtracting sample mean from proportion? Secondly: maybe the strange pattern in your data is result of this strange operation? $\endgroup$ – PtrZlnk Apr 29 '17 at 19:51
  • $\begingroup$ Thanks for your comment @PtrZink it is because the response variable cannot be analyzed directly, the proportions will have different values depending on the number of eggs in the nest, I am following this paper, please look at page 325 for more detail (last paragraph on the left column): canuck.dnr.cornell.edu/research/pubs/pdf/age_effects.pdf $\endgroup$ – MSS Apr 29 '17 at 20:13
  • 3
    $\begingroup$ You deal with that problem via incorporating number of eggs into a suitable model for the proportion -- not by (what seems to be) fairly arbitrarily mangling the data. Perhaps you could explain in more detail what your original variables are. You cannot transform discrete data across only a few values to normality. Since you can only move the data values around you'll always end up with at most five different values and the height of each spike will not change -- so there will always be only a few discrete values. $\endgroup$ – Glen_b Apr 30 '17 at 23:35
  • 1
    $\begingroup$ [Linear regression doesn't generally make sense if you're trying to model proportions of things; among numerous other problems, you'll tend to end up with a model that predicts impossible values] $\endgroup$ – Glen_b Apr 30 '17 at 23:42
  • $\begingroup$ @Glen_b♦, the original response variable is the number of eggs in the nest at hatch divided by the total number of eggs found (i.e. the proportion that survived incubation period). Regarding other alternatives, Beta regression doesn't work in my case because I have values =1; I tried with Poisson and logistic regression with weights for the denominator (please see the plots on the update of my question - I shared only for binomial regression because both look similar). Can you recommend me another approach? I really don't know what else can I try. Thanks a lot for your time. $\endgroup$ – MSS May 1 '17 at 15:02
5
$\begingroup$

Based on Glen_b's questions and your clarifications, it sounds like you might want to use your number of eggs that hatched in a Poisson regression with an exposure (number of eggs found), which is done in R's glm via the offset function in your formula. A very readable paper where they are doing something similar to your task -- the number of seeds germinating out of 100 planted in each plot -- is: http://www.stat.umn.edu/geyer/5931/mle/seed2.pdf

Or perhaps binomial (glm can also do "quasi-binomial" which is a little negative-binomial-like) or negative binomial (Package MASS, function nb.glm), depending. I'm not sure how they deal with 0%/100% issues, but...

$\endgroup$
  • $\begingroup$ Thank you @Wayne, this is indeed is a very good solution to analyze my response variable. I used the Poisson regression, based on my raw data the model now makes sense. Can you please confirm that the plots with the assumptions are correct now? Regarding the quasi-binomial, I got this error message "Warning while fitting theta: iteration limit reached" and I found that it was because my data "is closer to Poisson" (see r-sig-ecology.471788.n2.nabble.com/…) $\endgroup$ – MSS May 1 '17 at 22:56

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.