2
$\begingroup$

I recently fitted a beta distributed GLM using R (and the betareg package). as you can see the model is a reasonably decent fit, however there are a few outliers. i would like to run the model again with the outliers excluded to make sure they aren't effecting the result, but i'm not sure how to determine exactly which individuals they are in my dataset. Is there some way i can do this in R?enter image description here

$\endgroup$

1 Answer 1

3
$\begingroup$

Sort of an OT programming question, but pretty straightforward to answer. Basically, you need to find the indices of the residuals that correspond to the observations with large residuals. Example below is from the help file for betareg

library(betareg)
?betareg
data("GasolineYield", package = "betareg")
data("FoodExpenditure", package = "betareg")
gy <- betareg(yield ~ batch + temp, data = GasolineYield)
summary(gy)
hist(gy$residuals)
absres <- abs(gy$residuals) #Absolute value of the residual.  You can do any transformation of the residuals you find appropriate.
q <- quantile(absres, probs = .95) #The 95th quantile of this distribution
GasolineYield[which(absres>q),]#the observations that lead to these residuals
newdata <- GasolineYield[which(absres<q),]

You can then go and refit your model with the new data.

$\endgroup$
1
  • $\begingroup$ thanks very much, this is exactly what i was looking for. $\endgroup$
    – Thomas
    Apr 29, 2016 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.