# Beta-Regression and AIC (model selection)

#### Amanda_UK

##### New Member
Hello, dear fellow R users,

I am using beta regression because I am trying to predict percentages (response and dropout rates) of surveys.

My aim is now to come up with a final model (I have many different variables and want to reduce them to a final model). I wanted to do that by using the "stepAIC" function.

Unforunately, I get the following error message when I try to do the latter:

Error in UseMethod("extractAIC") :
no applicable method for 'extractAIC' applied to an object of class "betareg"

Can anyone explain what this means?

My R code was:

Code:
libary (MASS)
model_with_all_possible_variables <- betareg()
stepAIC(model_with_all_possible_variables)
--> Result: Error Message

Can someone offer me some advice as to how to find the best final model, please? I'd be really beyond grateful. I am aware that the lrt test can be used for beta regression, but I was wondering whether there is a way to use the stepAIC-approach (or some other method)? How would you guys go about it?

Best,

Amanda

#### TheEcologist

##### Global Moderator
Hello, dear fellow R users,

I am using beta regression because I am trying to predict percentages (response and dropout rates) of surveys.

My aim is now to come up with a final model (I have many different variables and want to reduce them to a final model). I wanted to do that by using the "stepAIC" function.

Unforunately, I get the following error message when I try to do the latter:

Error in UseMethod("extractAIC") :
no applicable method for 'extractAIC' applied to an object of class "betareg"
It appears that the people who created the "betareg" function and class did not supply a corresponding extactAIC method for their class.
You will need to calculate it yourself. Luckily that is easy: https://en.wikipedia.org/wiki/Akaike_information_criterion

All you need to find is the log-likelihood and the number of fitted parameters.. Do you know how to find that with betareg?

TE

#### Amanda_UK

##### New Member
Hi!
Thank you SO much for your response. I really appreciate it so much.
I'd be really, really grateful if you could briefly explain how to find and do it.

#### Amanda_UK

##### New Member
I just figured out that one can actually calculate the AIC measure for betareg-models in R with the usual code:

Code:
AIC(model)
I.e. I could calculate the AIC values for various different models and simply compare them to each other and select the one with the highest AIC value.
However....I have quite a few variables...i.e. there are many potential models that I would have to compare. I'm therefore not sure what to do.

Can someone PLEASE help me out. I would appreciate it endlessly, endlessly.

#### Dason

##### Ambassador to the humans
What exactly is your question?

#### Amanda_UK

##### New Member
My question is:
What method should I use to select a final model when I am using beta regression?

In the meantime, I have found the gamlss package which provides an AIC function for beta regressions. Unfortunately I get an error message.

So my new, additional question is how to make this function work.

I used the following code:

Code:
model <- betareg(y ~ x1 + x2 + ...., data = conference_surveys)
stepGAIC(model,direction="backward", additive=TRUE)
This is the resulting error message:

Error in match.arg(model) : 'arg' should be one of “mean”, “precision”

I don't understand the meaning of this error message at all, but really feel that this code would be the right solution. I.e. we are really close to making this work. Any help would be really, really appreciated.

#### tj7

##### New Member
It appears that the people who created the "betareg" function and class did not supply a corresponding extactAIC method for their class.
You will need to calculate it yourself. Luckily that is easy: https://en.wikipedia.org/wiki/Akaike_information_criterion

All you need to find is the log-likelihood and the number of fitted parameters.. Do you know how to find that with betareg?

TE
Can you share a code for this in R? I created models by leaving one variable at a time. So i have models equal to number of variables.But I am facing convergence error.
Warning message:
In betareg.fit(X, Y, Z, weights, offset, link, link.phi, type, control) :
optimization failed to converge