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

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived