I am trying to calculate leverage and cooks distance for the model that I developed using nlme
, but I'm getting the error saying
Error in cooks.distance.lme(model) : not implemented for "nlme" objects"
What are the ways to calculate Cook's distance in nlme
?
formula = log_Lobs ~ log(150*((1 + ((150/Lt_1)^(1/exp(p))-1)*exp(-exp(k)*td/365))^(-exp(p))))
model <- do.call(nlme,
list(formula,
fixed = c(p ~ 1, k ~ 1 + season2),
random = k ~ 1 | id,
data = data_select,
start = list(fixed = c(p, k)),
na.action = na.exclude,
control=list(maxIter=1e6, msMaxIter = 1e6, msVerbose = TRUE)
))
#Calculate leverage
lev<-hat(model.matrix(model))
Error in x$terms %||% attr(x, "terms") %||% stop("no terms component nor attribute") : no terms component nor attribute
#Calculate Cook's Distance
cd<-cooks.distance(model)
Error in cooks.distance.lme(model) : not implemented for "nlme" objects