Here is a part of mydata:
The raw data is very big, so I upload a part of it with 20 rows.
x <- [7.6,2.2,1.1,4.7,8.6,7.5,7.5,29.9,5.0,3.0,2.4,1.5,14.9,3.9,3.7,3.2,5.0,1.7,2.9,2.3]
Here is function description
- power law:
y=A*x^-(u)
- exponential:
y=B*exp^(-βx)
Now, I want to use MLE(Maximum likelihood method) to get u
for power law, and β
for exponential distribution.
#set likelihood function of power law
pl <- function(u){-n*log(u-1)-n*(u-1)*log(min(x))+u*sum(log(x))}
#set likelihood function of exponential distribution
ex <- function(β){-n*log(β)+β*sum(x)}
Are these functions right?
Using mle2() to get the parameters:
#get the parameter u of power law
s1 <- mle2(pl,start = list(u=2),data = list(x))
summary(s1)
#get the parameter lamda of exponential distribution
s2 <- mle2(ex,start = list(β=2),data = list(x))
summary(s2)
Now here are two questions:
how to determine which one is the best to fit the model
Using confint() could get the 95% CI, how do I get the Rsquared and AIC(Akaike weigths) of both model?
- After I get which one is best to fit the data, How do I draw the fitted graph above the raw data?
I use R.3.2.2 in windows 7.