Backtransforming response for plotting allEffectsbacktransform `scale()` for plottingPlot two graphs in same plot in RHow to set limits for axes in ggplot2 R plots?Save plot to image file instead of displaying it using Matplotlibvisreg plot binomial distributionCannot run glmer models with na.action=na.fail, necessary for MuMIn dredge functionMeaning of SE for lsmeans type=“response”ggplot: rescale axis (log) and cut axisCorrect way to scale for multilevel regression using lmer [R]scale on effect plot using GLMScaling predictors in lme4 glmer doesn't resolve eigenvalue warnings; neither does alternative optimization

What is the tangent at a sharp point on a curve?

Extract substring according to regexp with sed or grep

Can a Knock spell open the door to Mordenkainen's Magnificent Mansion?

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

Should a narrator ever describe things based on a character's view instead of facts?

New Order #2: Turn My Way

Is this saw blade faulty?

Not hide and seek

Would this string work as string?

Is there a distance limit for minecart tracks?

How would a solely written language work mechanically

How to get directions in deep space?

Capacitor electron flow

Why didn't Voldemort know what Grindelwald looked like?

Derivative of an interpolated function

Relations between homogeneous polynomials

Put the phone down / Put down the phone

What can I do if I am asked to learn different programming languages very frequently?

Do I have to take mana from my deck or hand when tapping this card?

Air travel with refrigerated insulin

Highest stage count that are used one right after the other?

How do I lift the insulation blower into the attic?

Pre-Employment Background Check With Consent For Future Checks

Why is indicated airspeed rather than ground speed used during the takeoff roll?



Backtransforming response for plotting allEffects


backtransform `scale()` for plottingPlot two graphs in same plot in RHow to set limits for axes in ggplot2 R plots?Save plot to image file instead of displaying it using Matplotlibvisreg plot binomial distributionCannot run glmer models with na.action=na.fail, necessary for MuMIn dredge functionMeaning of SE for lsmeans type=“response”ggplot: rescale axis (log) and cut axisCorrect way to scale for multilevel regression using lmer [R]scale on effect plot using GLMScaling predictors in lme4 glmer doesn't resolve eigenvalue warnings; neither does alternative optimization













1















I have fitted a few models using glmer from thelme4 package and did model selection with MuMIn::dredge() followed by model averaging. My response is frequency of occurrence of an animal in front of camera traps (continuous, number of photos per 100 hours of camera time); the predictors are minimum distances from a camera trap to landscape categories in meters, sometimes with an interaction with the day phase (day/night).



The response shows Gamma-distribution, but to make the model work I had to transform my response by adding 1, as the Gamma distribution can't handle non-positive data and quite a few of my data points were zeros as shown in this histogram:



in this histogram



Also, I had to scale the predictors, otherwise I got convergence warnings like




Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?




I did this with scale(..., center = TRUE).



My model formula looks like this:



mod <- glmer(Species_Frequency ~ scaled_Minimal_Distance1 + 
scaled_Minimal_Distance2 +
(scaled_Minimal_Distance3 * Dayphase),
data = data,
na.action = na.fail,
family = Gamma(link = "log"),
control = glmerControl(optimizer = "bobyqa"))


Now I want to plot the results of mod using plot(allEffects(mod)).



For plotting, I am backscaling my predictors in the allEffects-object by accessing



allEffects(mod)[["scaled_Minimal_Distance1"]][["x"]][["scaled_Minimal_Distance1"]] and doing as shown Here. I would also like to back-transform my response, to make the plot more understandable. Otherwise one would always have to keep in mind that 1 on the y-axis is actually 0, 2 is 1 etc. Can someone help me on how to do this, as I hit a roadblock and can't seem to figure it out myself.



Thank you very much in advance.










share|improve this question



















  • 1





    What do you mean by "frequency of occurrence"? You seem to say that the responses are 0,1,2,... which you transform to 1,2,3,... This seems more like number of occurrences (and counts are discrete while the Gamma distribution is continuous).

    – dipetkov
    Mar 7 at 20:57











  • What is the ratio of zero to non-zero? It might be worth looking at a Poisson or Negative Binomial distribution, they have ways of dealing with zeroes - en.wikipedia.org/wiki/Zero-inflated_model

    – hrabel
    Mar 7 at 21:16











  • Please see my edits. I have misformulated this, the "1 is 0 etc" thing described the values on the y-axis, my frequency is continuous. @hrabel I have added a histogram of my non-transformed data. I tried poisson, but as it is non-integer, it didn't work. I should maybe add, that I am quite unexperienced in statistics.

    – Matthias
    Mar 8 at 7:35
















1















I have fitted a few models using glmer from thelme4 package and did model selection with MuMIn::dredge() followed by model averaging. My response is frequency of occurrence of an animal in front of camera traps (continuous, number of photos per 100 hours of camera time); the predictors are minimum distances from a camera trap to landscape categories in meters, sometimes with an interaction with the day phase (day/night).



The response shows Gamma-distribution, but to make the model work I had to transform my response by adding 1, as the Gamma distribution can't handle non-positive data and quite a few of my data points were zeros as shown in this histogram:



in this histogram



Also, I had to scale the predictors, otherwise I got convergence warnings like




Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?




I did this with scale(..., center = TRUE).



My model formula looks like this:



mod <- glmer(Species_Frequency ~ scaled_Minimal_Distance1 + 
scaled_Minimal_Distance2 +
(scaled_Minimal_Distance3 * Dayphase),
data = data,
na.action = na.fail,
family = Gamma(link = "log"),
control = glmerControl(optimizer = "bobyqa"))


Now I want to plot the results of mod using plot(allEffects(mod)).



For plotting, I am backscaling my predictors in the allEffects-object by accessing



allEffects(mod)[["scaled_Minimal_Distance1"]][["x"]][["scaled_Minimal_Distance1"]] and doing as shown Here. I would also like to back-transform my response, to make the plot more understandable. Otherwise one would always have to keep in mind that 1 on the y-axis is actually 0, 2 is 1 etc. Can someone help me on how to do this, as I hit a roadblock and can't seem to figure it out myself.



Thank you very much in advance.










share|improve this question



















  • 1





    What do you mean by "frequency of occurrence"? You seem to say that the responses are 0,1,2,... which you transform to 1,2,3,... This seems more like number of occurrences (and counts are discrete while the Gamma distribution is continuous).

    – dipetkov
    Mar 7 at 20:57











  • What is the ratio of zero to non-zero? It might be worth looking at a Poisson or Negative Binomial distribution, they have ways of dealing with zeroes - en.wikipedia.org/wiki/Zero-inflated_model

    – hrabel
    Mar 7 at 21:16











  • Please see my edits. I have misformulated this, the "1 is 0 etc" thing described the values on the y-axis, my frequency is continuous. @hrabel I have added a histogram of my non-transformed data. I tried poisson, but as it is non-integer, it didn't work. I should maybe add, that I am quite unexperienced in statistics.

    – Matthias
    Mar 8 at 7:35














1












1








1








I have fitted a few models using glmer from thelme4 package and did model selection with MuMIn::dredge() followed by model averaging. My response is frequency of occurrence of an animal in front of camera traps (continuous, number of photos per 100 hours of camera time); the predictors are minimum distances from a camera trap to landscape categories in meters, sometimes with an interaction with the day phase (day/night).



The response shows Gamma-distribution, but to make the model work I had to transform my response by adding 1, as the Gamma distribution can't handle non-positive data and quite a few of my data points were zeros as shown in this histogram:



in this histogram



Also, I had to scale the predictors, otherwise I got convergence warnings like




Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?




I did this with scale(..., center = TRUE).



My model formula looks like this:



mod <- glmer(Species_Frequency ~ scaled_Minimal_Distance1 + 
scaled_Minimal_Distance2 +
(scaled_Minimal_Distance3 * Dayphase),
data = data,
na.action = na.fail,
family = Gamma(link = "log"),
control = glmerControl(optimizer = "bobyqa"))


Now I want to plot the results of mod using plot(allEffects(mod)).



For plotting, I am backscaling my predictors in the allEffects-object by accessing



allEffects(mod)[["scaled_Minimal_Distance1"]][["x"]][["scaled_Minimal_Distance1"]] and doing as shown Here. I would also like to back-transform my response, to make the plot more understandable. Otherwise one would always have to keep in mind that 1 on the y-axis is actually 0, 2 is 1 etc. Can someone help me on how to do this, as I hit a roadblock and can't seem to figure it out myself.



Thank you very much in advance.










share|improve this question
















I have fitted a few models using glmer from thelme4 package and did model selection with MuMIn::dredge() followed by model averaging. My response is frequency of occurrence of an animal in front of camera traps (continuous, number of photos per 100 hours of camera time); the predictors are minimum distances from a camera trap to landscape categories in meters, sometimes with an interaction with the day phase (day/night).



The response shows Gamma-distribution, but to make the model work I had to transform my response by adding 1, as the Gamma distribution can't handle non-positive data and quite a few of my data points were zeros as shown in this histogram:



in this histogram



Also, I had to scale the predictors, otherwise I got convergence warnings like




Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?




I did this with scale(..., center = TRUE).



My model formula looks like this:



mod <- glmer(Species_Frequency ~ scaled_Minimal_Distance1 + 
scaled_Minimal_Distance2 +
(scaled_Minimal_Distance3 * Dayphase),
data = data,
na.action = na.fail,
family = Gamma(link = "log"),
control = glmerControl(optimizer = "bobyqa"))


Now I want to plot the results of mod using plot(allEffects(mod)).



For plotting, I am backscaling my predictors in the allEffects-object by accessing



allEffects(mod)[["scaled_Minimal_Distance1"]][["x"]][["scaled_Minimal_Distance1"]] and doing as shown Here. I would also like to back-transform my response, to make the plot more understandable. Otherwise one would always have to keep in mind that 1 on the y-axis is actually 0, 2 is 1 etc. Can someone help me on how to do this, as I hit a roadblock and can't seem to figure it out myself.



Thank you very much in advance.







r plot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 20:43









Ben Bolker

135k13228320




135k13228320










asked Mar 7 at 20:31









MatthiasMatthias

63




63







  • 1





    What do you mean by "frequency of occurrence"? You seem to say that the responses are 0,1,2,... which you transform to 1,2,3,... This seems more like number of occurrences (and counts are discrete while the Gamma distribution is continuous).

    – dipetkov
    Mar 7 at 20:57











  • What is the ratio of zero to non-zero? It might be worth looking at a Poisson or Negative Binomial distribution, they have ways of dealing with zeroes - en.wikipedia.org/wiki/Zero-inflated_model

    – hrabel
    Mar 7 at 21:16











  • Please see my edits. I have misformulated this, the "1 is 0 etc" thing described the values on the y-axis, my frequency is continuous. @hrabel I have added a histogram of my non-transformed data. I tried poisson, but as it is non-integer, it didn't work. I should maybe add, that I am quite unexperienced in statistics.

    – Matthias
    Mar 8 at 7:35













  • 1





    What do you mean by "frequency of occurrence"? You seem to say that the responses are 0,1,2,... which you transform to 1,2,3,... This seems more like number of occurrences (and counts are discrete while the Gamma distribution is continuous).

    – dipetkov
    Mar 7 at 20:57











  • What is the ratio of zero to non-zero? It might be worth looking at a Poisson or Negative Binomial distribution, they have ways of dealing with zeroes - en.wikipedia.org/wiki/Zero-inflated_model

    – hrabel
    Mar 7 at 21:16











  • Please see my edits. I have misformulated this, the "1 is 0 etc" thing described the values on the y-axis, my frequency is continuous. @hrabel I have added a histogram of my non-transformed data. I tried poisson, but as it is non-integer, it didn't work. I should maybe add, that I am quite unexperienced in statistics.

    – Matthias
    Mar 8 at 7:35








1




1





What do you mean by "frequency of occurrence"? You seem to say that the responses are 0,1,2,... which you transform to 1,2,3,... This seems more like number of occurrences (and counts are discrete while the Gamma distribution is continuous).

– dipetkov
Mar 7 at 20:57





What do you mean by "frequency of occurrence"? You seem to say that the responses are 0,1,2,... which you transform to 1,2,3,... This seems more like number of occurrences (and counts are discrete while the Gamma distribution is continuous).

– dipetkov
Mar 7 at 20:57













What is the ratio of zero to non-zero? It might be worth looking at a Poisson or Negative Binomial distribution, they have ways of dealing with zeroes - en.wikipedia.org/wiki/Zero-inflated_model

– hrabel
Mar 7 at 21:16





What is the ratio of zero to non-zero? It might be worth looking at a Poisson or Negative Binomial distribution, they have ways of dealing with zeroes - en.wikipedia.org/wiki/Zero-inflated_model

– hrabel
Mar 7 at 21:16













Please see my edits. I have misformulated this, the "1 is 0 etc" thing described the values on the y-axis, my frequency is continuous. @hrabel I have added a histogram of my non-transformed data. I tried poisson, but as it is non-integer, it didn't work. I should maybe add, that I am quite unexperienced in statistics.

– Matthias
Mar 8 at 7:35






Please see my edits. I have misformulated this, the "1 is 0 etc" thing described the values on the y-axis, my frequency is continuous. @hrabel I have added a histogram of my non-transformed data. I tried poisson, but as it is non-integer, it didn't work. I should maybe add, that I am quite unexperienced in statistics.

– Matthias
Mar 8 at 7:35













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052338%2fbacktransforming-response-for-plotting-alleffects%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052338%2fbacktransforming-response-for-plotting-alleffects%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page