#------------------------------------------------------------------------------------------# # Comandos: # fit.model = ajuste # attach(dados) # source("diag_cook_nbin.txt") #------------------------------------------------------------------------------------------# X = model.matrix(fit.model) n = nrow(X) p = ncol(X) fi = fit.model$theta w = fi*fitted(fit.model)/(fi + fitted(fit.model)) W = diag(w) H = solve(t(X)%*%W%*%X) H = sqrt(W)%*%X%*%H%*%t(X)%*%sqrt(W) h = diag(H) ts = resid(fit.model,type="pearson")/sqrt(1-h) di = (h/(1-h))*(ts^2) # # Reta de corte com 3 desvios padrao plot(di,xlab="Indice", ylab="Distancia de Cook", pch=16,cex=2,cex.axis=1.5,cex.lab=1.5) cut = mean(di) + 3*sd(di) abline(cut,0,lty=2,lwd=2) # Comando a ser acionaod sendo n o numero de pontos a serem destacados # identify(di,n=1,cex=2) #------------------------------------------------------------------------------------------#