# Optimization with R

#### Rina990

##### New Member
I need to calculate maximum likelihood estimates of λ,α,κ for generalized gamma distribution in R and I do not know how to do it. Can anyone help me with this ?

#### Rina990

##### New Member
I m afraid not. I have some data about the time spent in a hospital for those who have undergone surgery for 5 succesive days (data are not available for all 5 days since some have left for example the second day). So I m wondering whether I have to calculate it someway by hand and implement a fuction in R or there is something like a bult-in function in R like fit.GenGamma but I don't know how to use it.

#### Rina990

##### New Member
I dont think I can solve the problem

#### GretaGarbo

##### Human
Then try with a simpler model, like a gamma model or a normal distribution model (that are special cases of the gneralized gamma disribution).

Or is the problem something else? What is the difficulty?

#### Rina990

##### New Member
I have to solve it via the generalized distribution. Maybe I should use the function optim in R, however, I don't know how to include data with time and missing values for some of the obsarvation days. I tried a different function like fit.GenGamma which is included in the package Temporal but when I try to run it R cannot find that function.

#### GretaGarbo

##### Human
Tell us about the data and the problem you are facing.

Now there seems to be more problem than just estimation. What causes the missing values?

There is no law that forces you to use a generalized gamma distribution. Statisttically speaking, if a simpler model fits well, then it is good enough.

Maybe a boss suggested you to use that distribution. But bosses are not always correct.

#### hlsmith

##### Not a robit
Our is this an assignment for a course with the requirement or reference in the instructions? Providing data details and a toy set would be highly beneficial!