Giter Site home page Giter Site logo

Comments (3)

joshyam-k avatar joshyam-k commented on July 24, 2024 1

ah, amazing!!! thank you so much!

from multilevelmod.

hfrick avatar hfrick commented on July 24, 2024

You can access the fitted stanreg model stored inside the parsnip model object with extract_fit_engine() and then call as.data.frame() on it like you did in your example 🙌

library(tidymodels)
library(multilevelmod)
library(bayesrules)
library(rstanarm)
#> [...]

data(cherry_blossom_sample)
running <- cherry_blossom_sample

running_model_1 <- stan_glmer(
  net ~ age + (1 | runner), 
  data = running, family = gaussian,
  prior_intercept = normal(100, 10),
  prior = normal(2.5, 1), 
  prior_aux = exponential(1, autoscale = TRUE),
  prior_covariance = decov(reg = 1, conc = 1, shape = 1, scale = 1),
  chains = 4, iter = 5000*2, seed = 84735)
#> [...]
coef_1 <- as.data.frame(running_model_1)

# with multilevelmod
running_model_2 <- linear_reg() %>% 
  set_engine("stan_glmer", family = gaussian,
             prior_intercept = normal(100, 10),
             prior = normal(2.5, 1), 
             prior_aux = exponential(1, autoscale = TRUE),
             prior_covariance = decov(reg = 1, conc = 1, shape = 1, scale = 1),
             chains = 4, iter = 5000*2, seed = 84735) %>% 
  fit(net ~ age + (1 | runner), data = running)

coef_2 <- running_model_2 %>% 
  extract_fit_engine() %>% 
  as.data.frame()

waldo::compare(coef_1, coef_2)
#> ✔ No differences

Created on 2022-11-14 with reprex v2.0.2

from multilevelmod.

github-actions avatar github-actions commented on July 24, 2024

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

from multilevelmod.

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.