Coder Social home page Coder Social logo

Comments (25)

emjonaitis avatar emjonaitis commented on May 27, 2024 1

from ggeffects.

richardneilbelcher avatar richardneilbelcher commented on May 27, 2024

I just had a similar issue with the ggpredict function. Setting ci.lvl = NA made it work without the vector allocation error (although ggeffect worked for me). With other lme4 prediction tools they can use some intensive methods for degrees of freedom calculations so that may be it.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

If one of the terms is continuous, try to specify some values, e.g. terms = "cont_var [10, 20, 30, 40, 50]", if cont_var ranges from 10 to 50. I use expand.grid() on all possible values, and computation of CI might be very memory consuming in such cases. The effects package, by default, does not compute effects and CI for all possible values, but for a selection only.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Could you please check if this issue still exists in the current dev-version? I have added a pretty argument, which creates a sequence of "pretty" numbers for predictor terms with many unique values.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Since pretty does not plot splines nicely, I've changed the default to pretty = FALSE. So, if possible, please check if ggpredict(..., pretty = TRUE) solves your issue.

from ggeffects.

vspinu avatar vspinu commented on May 27, 2024

I am having same issue with ggeffects::ggalleffects which blows to 15GB for 64k row x 9col data set. ggeffects::predict doesn't work for me because I have sales(forecast) term in my formula:

> labels(terms(M))
 [1] "error"               "scale(forecast)"     "error2"             
 [4] "waste1"              "waste2"              "sales"              
 [7] "family"              "scale(transactions)" "cluster"            
[10] "aweek"               "year"                "holid_nat"          
> ggeffects::ggpredict(M, labels(terms(M)), pretty = T)
`terms` must have not more than three values. Using first three values now.
Error in scale(forecast, center = 276.325019004872, scale = 375.963889410209) : 
  object 'forecast' not found

The above works just fine with the effects package.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Try to standardise the variable before you fit the model, does this work?

from ggeffects.

vspinu avatar vspinu commented on May 27, 2024

they are standardized. Sorry, I haven't provided the model formula:

waste ~ error + scale(forecast) + error2 + waste1 + waste2 + 
    sales + family + scale(transactions) + cluster + aweek + 
    year + holid_nat

I expect this error has something to do with the inline scale(forecast).

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Yes, please standardize before, and don't use "inline" calls to functions. And it's preferred to use sjmisc::std(), because scale() changes the input type.

from ggeffects.

vspinu avatar vspinu commented on May 27, 2024

Yes, please standardize before, and don't use "inline" calls to functions.

Yerh, one too many restriction; I guess I would stay away then. All other standard R software works with "inline" functions and doesn't require standardization (effects package including). But well, every package is different ;)

As a side note, subsampling or pretty=TRUE should be the default. The splines issue is really not an excuse to blow people's R sessions during basic plotting (especially with small data sets).

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Actually, ggpredict() should work with the the inline-use of functions, however, the term-argument must use the original term names. So term = "forecast" should work, while labels(terms(M)) returns scale(forecast).

Your argument is translated to predict(M, newdata = data.frame('scale(forecast)' = ...)), which causes the error.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

@emjonaitis and @richardneilbelcher do you still have the memory allocation issues if you set pretty = TRUE? I think I will indeed make this as default option, and print a message if prettifying was done, so the user is not too curious about less smoothed plots.

from ggeffects.

emjonaitis avatar emjonaitis commented on May 27, 2024

from ggeffects.

emjonaitis avatar emjonaitis commented on May 27, 2024

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

I revised the calculation for CI for mixed models, which now should be more efficient. When you now either use:

ggpredict(model, term = "myterm", pretty = TRUE)

or

ggpredict(model, term = "myterm [range]") # should really be "range", this is no placeholder

does one of these two options solve your issue? This requires the current GitHub-version of ggeffects.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

@vspinu If you want to plot effects for all model terms, you can now simply leave the terms argument missing or NULL, so just calling ggeffects::ggpredict(M) should work, and is comparable (regarding the effort) to allEffects(M).

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

I'd be happy if someone who still had problems with memory allocation errors, could check the current GitHub-version. It automatically should calculate a reasonable pretty range of predicted values and should be much more memory efficient when calculating SE/CI for predictions.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

bump

from ggeffects.

emjonaitis avatar emjonaitis commented on May 27, 2024

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

No, it's the correct version you are using, either the master branch or the current GitHub version should be more memory efficient.
When you run ggpredict(), does it display a message about prettifying the values?

from ggeffects.

emjonaitis avatar emjonaitis commented on May 27, 2024

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Thanks for looking into this. ggeffect() calls effects::effect(), so it might be an issue of the effects package. I'll try to find out where the issue is located.

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

I just realized that ggeffect() is not optimized, it only applies to ggpredict(). ggeffect() was a bit neglected by me, and I was always thinking of ggpredict() when talking about this issue. 🙄

from ggeffects.

strengejacke avatar strengejacke commented on May 27, 2024

Ok, memory allocation problems with ggeffect() should also be solved now.

from ggeffects.

emjonaitis avatar emjonaitis commented on May 27, 2024

from ggeffects.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.