#-----------------------------------------------------------------------# # Comandos: # > fit.model <- ajuste # > attach(dados) # > source("diag_resid_gama") #-----------------------------------------------------------------------# 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) library(MASS) fi <- gamma.shape(fit.model)$alpha ts <- resid(fit.model,type="pearson")*sqrt(fi/(1-h)) td <- resid(fit.model,type="deviance")*sqrt(fi/(1-h)) di <- (h/(1-h))*(ts^2) par(mfrow=c(1,1)) # plot(fitted(fit.model),td,xlab="Valor Ajustado", ylab="Componente do Desvio", pch=16, cex=2, cex.axis=1.5, cex.lab=1.5) #-----------------------------------------------------------------------#