Skip to content

Commit

Permalink
update description and vignette YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
melina-leite committed Oct 17, 2024
1 parent e115e86 commit eec3394
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DHARMa/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: DHARMa
Title: Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models
Version: 0.4.7
Date: 2024-10-16
Authors@R: c(person("Florian", "Hartig", email = "[email protected]", role = c("aut", "cre"), comment=c(ORCID="0000-0002-6255-9059")), person("Lukas", "Lohse", role = "ctb"))
Authors@R: c(person("Florian", "Hartig", email = "[email protected]", role = c("aut", "cre"), comment=c(ORCID="0000-0002-6255-9059")), person("Lukas", "Lohse", role = "ctb"), person("Melina", "de Souza leite", role = "ctb"))
Description: The 'DHARMa' package uses a simulation-based approach to create
readily interpretable scaled (quantile) residuals for fitted (generalized) linear mixed
models. Currently supported are linear and generalized linear (mixed) models from 'lme4'
Expand Down
2 changes: 1 addition & 1 deletion DHARMa/DHARMa.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
PackageRoxygenize: rd,collate,namespace,vignette
10 changes: 6 additions & 4 deletions DHARMa/vignettes/DHARMa.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ title: "DHARMa: residual diagnostics for hierarchical (multi-level/mixed) regres
author: "Florian Hartig, Theoretical Ecology, University of Regensburg [website](https://www.uni-regensburg.de/biologie-vorklinische-medizin/theoretische-oekologie/mitarbeiter/hartig/)"
date: "`r Sys.Date()`"
output:
rmarkdown::html_vignette:
toc: true
pdf_document:
toc: true
vignette: |
%\VignetteIndexEntry{Vignette for the DHARMa package} \usepackage[utf8]{inputenc} %\VignetteEngine{knitr::rmarkdown}
rmarkdown::html_vignette:
toc: true
vignette: >
%\VignetteIndexEntry{Vignette for the DHARMa package}
\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
abstract: "The 'DHARMa' package uses a simulation-based approach to create readily
interpretable scaled (quantile) residuals for fitted generalized linear (mixed)
models. Currently supported are linear and generalized linear (mixed) models from
Expand Down
78 changes: 78 additions & 0 deletions DHARMa/vignettes/DHARMaForBayesians.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
## ----global_options, include=FALSE--------------------------------------------
knitr::opts_chunk$set(fig.width=8.5, fig.height=5.5, fig.align='center', warning=FALSE, message=FALSE)

## ----echo = F, message = F----------------------------------------------------
library(DHARMa)
set.seed(123)

## ----eval = F-----------------------------------------------------------------
# library(rjags)
# library(BayesianTools)
#
# set.seed(123)
#
# dat <- DHARMa::createData(200, overdispersion = 0.2)
#
# Data = as.list(dat)
# Data$nobs = nrow(dat)
# Data$nGroups = length(unique(dat$group))
#
# modelCode = "model{
#
# for(i in 1:nobs){
# observedResponse[i] ~ dpois(lambda[i]) # poisson error distribution
# lambda[i] <- exp(eta[i]) # inverse link function
# eta[i] <- intercept + env*Environment1[i] # linear predictor
# }
#
# intercept ~ dnorm(0,0.0001)
# env ~ dnorm(0,0.0001)
#
# # Posterior predictive simulations
# for (i in 1:nobs) {
# observedResponseSim[i]~dpois(lambda[i])
# }
#
# }"
#
# jagsModel <- jags.model(file= textConnection(modelCode), data=Data, n.chains = 3)
# para.names <- c("intercept","env", "lambda", "observedResponseSim")
# Samples <- coda.samples(jagsModel, variable.names = para.names, n.iter = 5000)
#
# x = BayesianTools::getSample(Samples)
#
# colnames(x) # problem: all the variables are in one array - this is better in STAN, where this is a list - have to extract the right columns by hand
# posteriorPredDistr = x[,3:202] # this is the uncertainty of the mean prediction (lambda)
# posteriorPredSim = x[,203:402] # these are the simulations
#
# sim = createDHARMa(simulatedResponse = t(posteriorPredSim), observedResponse = dat$observedResponse, fittedPredictedResponse = apply(posteriorPredDistr, 2, median), integerResponse = T)
# plot(sim)

## ----eval=F-------------------------------------------------------------------
# # Posterior predictive simulations
# for (i in 1:nobs) {
# observedResponseSim[i]~dpois(lambda[i])
# }

## ----eval = F-----------------------------------------------------------------
# for(i in 1:nobs){
# observedResponse[i] ~ dpois(lambda[i]) # poisson error distribution
# lambda[i] <- exp(eta[i]) # inverse link function
# eta[i] <- intercept + env*Environment1[i] + RE[group[i]] # linear predictor
# }
#
# for(j in 1:nGroups){
# RE[j] ~ dnorm(0,tauRE)
# }

## ----eval=F-------------------------------------------------------------------
# for(j in 1:nGroups){
# RESim[j] ~ dnorm(0,tauRE)
# }
#
# for (i in 1:nobs) {
# observedResponseSim[i] ~ dpois(lambdaSim[i])
# lambdaSim[i] <- exp(etaSim[i])
# etaSim[i] <- intercept + env*Environment1[i] + RESim[group[i]]
# }

0 comments on commit eec3394

Please sign in to comment.