Git Product home page Git Product logo

dharma.helpers's Introduction

DHARMa.helpers

R-CMD-check HitCount HitCount

https://pakillo.github.io/DHARMa.helpers

DHARMa.helpers is an R package that facilitates checking fitted statistical models via the DHARMa package. By now, only Bayesian models fitted with brms are implemented. See this blogpost for a detailed explanation of the approach.

Installation

# install.packages("remotes")
remotes::install_github("Pakillo/DHARMa.helpers")

Example

library(brms)
library(DHARMa.helpers)

Poisson regression

Fit model:

# Example model taken brms::brm()
# Poisson regression for the number of seizures in epileptic patients
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
            data = epilepsy, family = poisson(), refresh = 0)
#> Compiling Stan program...
#> Start sampling

Check with DHARMa:

simres <- dh_check_brms(fit1, integer = TRUE)

Note that we use integer = TRUE in this case as we are modelling a discrete response (counts).

Now check residuals against a predictor (zAge):

plot(simres, form = epilepsy$zAge)

Test overdispersion:

DHARMa::testDispersion(simres)

#> 
#>  DHARMa nonparametric dispersion test via sd of residuals fitted vs.
#>  simulated
#> 
#> data:  simulationOutput
#> dispersion = 1.1747, p-value = 0.194
#> alternative hypothesis: two.sided

See https://pakillo.github.io/DHARMa.helpers/reference/dh_check_brms.html for more examples.

dharma.helpers's People

Contributors

pakillo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

dharma.helpers's Issues

DHARMa.helpers error message with Brms Ordinal Logit model

Hi Franscico,

Thank you for providing us with this helpful bridge between brms and dharma.

I applied

dh_check_brms(mymodel, integer = TRUE)

to a repeated measures 3 levels ordinal logit.

The following error message is issued:

Error in t.default(brms::posterior_epred(model, ndraws = nsamples, re.form = NA)) :
argument is not a matrix

What should I do?

Best regards,

Guillaume

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.