Comments (3)
from glmmadaptive.
Hi Dimitris,
for historical reasons, I'm still carrying around 2 versions of calculating everything in DHARMa,
- where quantile residuals are created by comparing observed vs. simulated data (default)
- where the models are re-fit to the simulated data, and residuals or other properties of the model are compared
The original motivation for this was the idea that option 2 would be more reliable for biased estimators. In practice, I have found few advantages of the refit, but for the moment I'm keeping the option.
More generally though, the refit is important for parametric bootstrap and all that.
from glmmadaptive.
Hi Florian,
I have written a short refit()
function that seems to do the trick - see below:
# simulate some data
set.seed(123L)
n <- 500
K <- 15
t.max <- 25
betas <- c(-2.13, -0.25, 0.24, -0.05)
D <- matrix(0, 2, 2)
D[1:2, 1:2] <- c(0.48, -0.08, -0.08, 0.18)
times <- c(replicate(n, c(0, sort(runif(K-1, 0, t.max)))))
group <- sample(rep(0:1, each = n/2))
DF <- data.frame(year = times, group = factor(rep(group, each = K)))
X <- model.matrix(~ group * year, data = DF)
Z <- model.matrix(~ year, data = DF)
b <- cbind(rnorm(n, sd = sqrt(D[1, 1])), rnorm(n, sd = sqrt(D[2, 2])))
id <- rep(1:n, each = K)
eta.y <- as.vector(X %*% betas + rowSums(Z * b[id, ]))
DF$y <- rbinom(n * K, 10, plogis(eta.y))
DF$fails <- 10 - DF$y
DF$id <- factor(id)
################################################################
################################################################
fm <- mixed_model(fixed = cbind(y, fails) ~ year * group,
random = ~ 1 | id, data = DF,
family = binomial())
refit_MixMod <- function (object, newresp = NULL) {
if (is.null(newresp)) return(object)
if (!is.data.frame(newresp)) stop("'newresp' must be a data.frame.")
newdata <- object$data
respVars <- all.vars(update.formula(formula(object), . ~ 0))
newdata[respVars] <- newresp[respVars]
update(object, data = newdata)
}
fm
refit_MixMod(fm, DF)
from glmmadaptive.
Related Issues (20)
- Behaviour of weights in GLMMadaptive HOT 2
- emmeans functions in two-part models: only gives output for "main" model HOT 2
- Possibility to evaluate marginal log-likelihood HOT 2
- Error in chol.default(X[[i]], ...) HOT 1
- Random intercept only for zero-inflated portion, not count portion HOT 1
- Documentation contains dead links HOT 1
- May I know how to get the effect size of a two-part mixed effects model? HOT 4
- emmeans produces strange (wrong) estimates from beta regression after mixed_model HOT 1
- Adding "sandwich" argument to mixed_model HOT 1
- Error: No glance method for objects of class MixMod HOT 6
- Issue with data prep for backward formulation HOT 4
- A problem with the censored.normal() family? HOT 2
- emmeans support doesn't return the link HOT 4
- Predict function for hurdle.lognormal response
- hurdle.lognormal() needs to trigger error message when zi_fixed is omitted HOT 1
- Confusion about the values returned by vcov(MixMod) HOT 4
- More than one random effect? HOT 2
- predict(type = 'subject_specific') not working in model with not positive definite Hessian matrix HOT 3
- "Error in eigen(Y, symmetric = TRUE): infinite or missing values in 'x'" HOT 1
- A binomial model with log link function doesn't display summary HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glmmadaptive.