#------------------------------------------------------------------------------------------# # Comandos: # fit.model = ajuste # attach(dados) # source("diag_cook_ninv.txt") #------------------------------------------------------------------------------------------# X = model.matrix(fit.model) n = nrow(X) p = ncol(X) w = fit.model$weights W = diag(w) H = solve(t(X)%*%W%*%X) H = sqrt(W)%*%X%*%H%*%t(X)%*%sqrt(W) h = diag(H) soma = resid(fit.model, type="pearson") soma = sum(soma^2) fi = (n-p)/soma ts = resid(fit.model,type="pearson")*sqrt(fi/(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 ponots a serem destacados # identify(di, n=1,cex=2) #------------------------------------------------------------------------------------------#