-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from florianhartig/0.2.0.3
0.2.0.3
- Loading branch information
Showing
35 changed files
with
432 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Submission Checklist | ||
|
||
|
||
|
||
|
||
|
||
|
||
https://cran.r-project.org/web/checks/check_results_DHARMa.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,50 @@ | ||
library(spaMM) | ||
|
||
data("Loaloa") ## from spaMM package | ||
loafit <- corrHLfit(cbind(npos,ntot-npos)~maxNDVI1+seNDVI | ||
fittedModel <- corrHLfit(cbind(npos,ntot-npos)~maxNDVI1+seNDVI | ||
+Matern(1|longitude+latitude), | ||
data=Loaloa[1:30,],family=binomial(), | ||
init.corrHLfit=list(Nugget=0.1),ranFix=list(nu=0.5)) | ||
|
||
testModel(fittedModel) | ||
|
||
######################## | ||
|
||
fittedModel = loafit | ||
|
||
family(fittedModel) | ||
class(fittedModel)[1] | ||
nobs(fittedModel) | ||
getResponse(fittedModel) | ||
|
||
getResponse.HLfit <- function(object, ...){ | ||
response(object, ...) | ||
} | ||
DHARMa:::getFixedEffects(fittedModel) | ||
|
||
simulate.HLfit(fittedModel, nsim = 2) | ||
predict.HLfit(fittedModel) | ||
coef(fittedModel) | ||
ranef(fittedModel) | ||
fixef(fittedModel) | ||
res = simulateResiduals(fittedModel) | ||
plot(res) | ||
|
||
DHARMa:::getFixedEffects(fittedModel) | ||
testData = createData(sampleSize = 10000, overdispersion = 0.0, randomEffectVariance = 1, family = poisson()) | ||
|
||
fittedModel <- HLfit(observedResponse ~ Environment1 + (1|group) , family = "poisson", data = testData) | ||
res = simulateResiduals(fittedModel) | ||
plot(res) | ||
|
||
coef(fittedModel) | ||
fixef(fittedModel) | ||
fittedModel <- glmer(observedResponse ~ Environment1 + (1|group) , family = "poisson", data = testData) | ||
summary(fittedModel) | ||
res = simulateResiduals(fittedModel, re.form = ~0) | ||
plot(res) | ||
|
||
|
||
|
||
testData = createData(sampleSize = 200, overdispersion = 0.0, randomEffectVariance = 1, family = poisson()) | ||
fittedModel <- HLfit(observedResponse ~ Environment1 + (1|group) , family = "poisson", data = testData) | ||
res = simulateResiduals(fittedModel) | ||
res = simulateResiduals(fittedModel, refit = T) | ||
plot(res) | ||
testUniformity(res)$p.value < 0.001 | ||
|
||
|
||
|
||
testData = createData(sampleSize = 200, overdispersion = 0, randomEffectVariance = 0, family = binomial(), binomialTrials = 20) | ||
fittedModel <- HLfit(cbind(observedResponse1,observedResponse0) ~ Environment1 + (1|group) , family = "binomial", data = testData) | ||
res = simulateResiduals(fittedModel) | ||
plot(res) | ||
testUniformity(res)$p.value < 0.001 | ||
|
||
|
||
testData = createData(sampleSize = 200, fixedEffects = c(1,0), overdispersion = 0, randomEffectVariance = 0, family = binomial()) | ||
fittedModel <- HLfit(observedResponse ~ Environment1 + (1|group) , family = "binomial", data = testData) | ||
res = simulateResiduals(fittedModel) | ||
plot(res) | ||
testUniformity(res)$p.value < 0.001 | ||
|
||
|
||
######################## | ||
|
||
|
||
simsCond = simulate(nsim=250, loafit, type="residual") # I think that this is what I call a conditional simulat, i.e. simulations are conditinal on the fitted REs | ||
simsUncond = simulate(nsim=250, loafit, type="marginal") # I think that this is what I call a unconditional simulation, i.e. random effects and glm distribution are re-siulated? | ||
testResiduals(res) | ||
|
||
createDHARMa(simulatedResponse = sims, observedResponse = loafit$y, | ||
fittedPredictedResponse = predict(loafit, re.form=~0)[,1L], integer = T) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
Package: DHARMa | ||
Title: Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models | ||
Version: 0.2.0 | ||
Date: 2018-06-06 | ||
Version: 0.2.1 | ||
Date: 2019-01-14 | ||
Authors@R: c(person("Florian", "Hartig", email = "[email protected]", role = c("aut", "cre"), comment = "Theoretical Ecology, University of Regensburg, Regensburg, Germany")) | ||
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 (generalized) linear mixed models from 'lme4' | ||
(classes 'lmerMod', 'glmerMod') and 'glmmTMB', generalized additive models ('gam' from 'mgcv'), | ||
'glm' (including 'negbin' from 'MASS', but excluding quasi-distributions) and 'lm' model | ||
(classes 'lmerMod', 'glmerMod'), 'glmmTMB' and 'spaMM', generalized additive models ('gam' from | ||
'mgcv'), 'glm' (including 'negbin' from 'MASS', but excluding quasi-distributions) and 'lm' model | ||
classes. Moreover, externally created simulations, e.g. posterior predictive simulations | ||
from Bayesian software such as 'JAGS', 'STAN', or 'BUGS' can be processed as well. | ||
The resulting residuals are standardized to values between 0 and 1 and can be interpreted | ||
|
@@ -32,7 +32,8 @@ Imports: | |
MASS, | ||
lme4, | ||
mgcv, | ||
glmmTMB (>= 0.2.1) | ||
glmmTMB (>= 0.2.1), | ||
spaMM (>= 2.6.0) | ||
Suggests: | ||
knitr, | ||
testthat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.