Giter Club home page Giter Club logo

Comments (15)

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024 1

Thanks! I’ll close the issue now, feel free to open a new one for any further question or issue!

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

Thanks, Alejandro.

L1 search in varsel fails with a different error:

> vs <- varsel(reffull, method='L1')
Error in Reduce(function(current, pattern) { : subscript out of bounds

The forward search in varsel works, but then fails at as.matrix(proj):

vs <- varsel(reffull, method='forward')
proj <- project(vs, nterms = 3


, ns = 500)
mcmc_areas(as.matrix(proj)) +  coord_cartesian(xlim = c(-2, 2))
Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

I think you're right about the model type, as when I add random terms as.matrix(proj) works (but this model gives poor varsel plots, but that's for another post!).

Thanks very much for your help. I've tried to upload the proj object but it's huge (~120MB). Will find out how to reduce it.

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

Here's the original model object (brms_cfull in the below): this is the smallest part I can upload! Hope that's OK. Thank you.
projpred_model.Rdata.zip

reffull <- get_refmodel(brms_cfull)
vs <- varsel(reffull, method='forward')
proj <- project(vs, nterms = 3, ns = 500)

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

Hi @AlejandroCatalina. Thanks very much for the fix, and for the explanation regarding the varsel plots. I really appreciate your help with this.

The varsel(..., method='L1' fix works for me, but I still get the same error with as.matrix(proj):

packageVersion("projpred")
[1] ‘2.0.0’
> mcmc_areas(as.matrix(proj)) +  coord_cartesian(xlim = c(-2, 2))
Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

I'm still trying the varsel(…, ndraws_pred = 400) fix for the model with the random effects - it's taking a very long time to run....!

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

Thanks, Alejandro.

Even with 400 draws, I'm still getting a flat varsel plot which doesn't get near the reference when I add the random terms. The order of solution_terms is also not what I expect from other model comparisons.

priorh <- set_prior("horseshoe(scale_global = tau0, scale_slab=1)", class="b")
cfull_formula_rand <-  as.formula( y ~ v1_cts * f1 + v2_cts * f2 + f1:f2 + f3 + v3_cts + v4_cts + v5_cts + (1|r1) + (1|r2) + (1|r3)  )
fit <- brm(cfull_formula_rand, data=data, family="bernoulli", iter=5000, prior =  priorh,  sample_prior = T, control=list(adapt_delta=0.999,max_treedepth = 15), save_all_pars = F, refresh=0)

vs <- varsel(fit, method='forward', ndraws_pred=400)  

solution_terms(vs) 
 "(1 | r1)"                    "(1 | r2)"                    "(1 | r3)”                      "v1_cts"                   “f3”                "v2_cts”                    "v5_cts”                           "f2"                 “v2_cts:f2”    "f1”                 “v1_cts:f1”    “f1:f2”   “v4_cts”     
plot(vs, stats=c('elpd', 'rmse'), baseline='ref')

varsel_with_random

When I remove the random terms, the varsel results are as expected.

solution_terms(vs)  
“f2” “f3” “v2_cts” “f1” “f1:f2” “v4_cts” “v1_cts” “f1:vt_cts” “f2:v2_cts” “v5_cts"

varsel_without_random

I'd be grateful for any suggestions as to what's going wrong here, or tips for diagnosis.

It'd be great if you can fix the as.matrix(proj) issue, so I can look at the projected posterior.

Thanks again for your help.

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

OK, thanks for explaining.

I'll work off the fixed effect model for now, and will wait and hope that you can tweak projpred to constrain the projections.

I'm guessing that's a longer-term fix? Please let me know if you need more information about this example to help with that.

Thanks,

Andrew

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

Thanks for the update about the plan. So I'll anticipate it being a few months off, and will find a workaround for now.

Regarding the as.matrix(proj) issue, I get this error for method="L1":

vs <- varsel(brms_cfull, method='L1', ndraws_pred=400)
Error in stop("l1 search is not supported for multilevel models", ) : 
  argument is missing, with no default

Using method="forward" works OK.

I'm using the develop version:

packageVersion("projpred")
[1] ‘2.0.0’

from projpred.

AlejandroCatalina avatar AlejandroCatalina commented on June 5, 2024

from projpred.

andrewdigby avatar andrewdigby commented on June 5, 2024

Ah, sorry. Yes: that now works. Thanks!

from projpred.

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.