Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
florianhartig committed Jun 26, 2024
1 parent e4265e3 commit 76f9159
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
6 changes: 5 additions & 1 deletion Code/DHARMaPackageSupport/phylolm/phylolm.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ summary(fit)
coef(fit)
vcov(fit)

fit = DHARMa::simulateResiduals(fit, plot = T)
DHARMa:::checkModel(fit, stop = F)

res = DHARMa::simulateResiduals(fit, plot = T)

fitBoot = phylolm:::update(fit, boot = nsim, save = T)

phylolm:::up

# LM

Expand Down
33 changes: 18 additions & 15 deletions DHARMa/R/compatibility.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ checkModel <- function(fittedModel, stop = F){
if(!(class(fittedModel)[1] %in% getPossibleModels())){
if(stop == FALSE) warning("DHARMa: fittedModel not in class of supported models. Absolutely no guarantee that this will work!")
else stop("DHARMa: fittedModel not in class of supported models")

}

# if(hasNA(fittedModel)) message("It seems there were NA values in the data used for fitting the model. This can create problems if you supply additional data to DHARMa functions. See ?checkModel for details")
Expand All @@ -58,7 +59,7 @@ checkModel <- function(fittedModel, stop = F){
#' returns a list of supported model classes
#'
#' @keywords internal
getPossibleModels<-function()c("lm", "glm", "negbin", "lmerMod", "lmerModLmerTest", "glmerMod", "gam", "bam", "glmmTMB", "HLfit", "MixMod")
getPossibleModels<-function()c("lm", "glm", "negbin", "lmerMod", "lmerModLmerTest", "glmerMod", "gam", "bam", "glmmTMB", "HLfit", "MixMod", "phylolm", "phyloglm")


weightsWarning = "Model was fit with prior weights. These will be ignored in the simulation. See ?getSimulations for details"
Expand Down Expand Up @@ -229,6 +230,7 @@ getFamily <- function (object, ...) {
UseMethod("getFamily", object)
}

# nObs

# default -----------------------------------------------------------------

Expand Down Expand Up @@ -706,7 +708,8 @@ getObservedResponse.phylolm <- function (object, ...){
#' @export
getSimulations.phylolm <- function(object, nsim = 1, type = c("normal", "refit"), ...){
type <- match.arg(type)
fitBoot = update(fit, boot = nsim, save = T)

fitBoot = update(object, boot = nsim, save = T)
out = fitBoot$bootdata

if(type == "normal"){
Expand All @@ -721,28 +724,19 @@ getSimulations.phylolm <- function(object, nsim = 1, type = c("normal", "refit")
#' @rdname getFitted
#' @export
getFitted.phylolm <- function (object,...){
fit$fitted.values
return(object$fitted.values)
}


####### sjSDM #########




#' @rdname getFamily
#' @export
getFamily.phylolm <- function (object,...){
out = list()
# out$family = object$method
out$family = "integer-valued" # all families of phyloglm are integer-valued
out$family = "gaussian"
return(out)
}





#' @rdname getObservedResponse
#' @export
getObservedResponse.phyloglm <- function (object, ...){
Expand All @@ -755,7 +749,8 @@ getObservedResponse.phyloglm <- function (object, ...){
#' @export
getSimulations.phyloglm <- function(object, nsim = 1, type = c("normal", "refit"), ...){
type <- match.arg(type)
fitBoot = update(fit, boot = nsim, save = T)

fitBoot = update(object, boot = nsim, save = T)
out = fitBoot$bootdata

if(type == "normal"){
Expand All @@ -770,7 +765,7 @@ getSimulations.phyloglm <- function(object, nsim = 1, type = c("normal", "refit"
#' @rdname getFitted
#' @export
getFitted.phyloglm <- function (object,...){
fit$fitted.values
return(object$fitted.values)
}


Expand All @@ -785,3 +780,11 @@ getFamily.phyloglm <- function (object,...){
}


#' @rdname getFamily
#' @export
getFamily.phyloglm <- function (object,...){
out = list()
# out$family = object$method
out$family = "integer-valued" # all families of phyloglm are integer-valued
return(out)
}
2 changes: 2 additions & 0 deletions DHARMa/man/getFamily.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions DHARMa/man/testPhylogeneticAutocorrelation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76f9159

Please sign in to comment.