[R] Help with R Fitting an inverse Gamma
kmammasis
mammasis82 at hotmail.com
Fri Oct 5 10:17:57 CEST 2012
Hi and thanks for your replies. I have changed the name of the input data to
something other than "data" to avoid confusion with the function data(),
however the problem still persists. I get the same error. I have found it
easier to upload the file in the following location:
http://www.sendspace.com/file/euv6qy <http://www.sendspace.com/file/euv6qy>
After importing the csv file in R I use the following code:
# Required packages
library(MCMCpack)
V=my.csv.data$V1
hist(V)
# log-likelihood
ll = function(par){
if(par[1]>0 & par[2]>0 & par[3]<min(V)) return( -sum(log(dinvgamma(V-
par[3],par[1],par[2]))) )
else return(Inf)
}
# MLE
mle = optim(c(0.05,.022,.0sessionInfo()2),ll)
params = mle$par
# Fit
hist(Vdput()
,probability=T,ylim=c(0,2.5))
points(seq(2,4.5,0.001),dinvgamma(seq(2,4.5,0.001)-params[3],params[1],params[2]),type="l",col="red")
Thank you once more.
BR,
Konstantinos
--
View this message in context: http://r.789695.n4.nabble.com/Help-with-R-Fitting-an-inverse-Gamma-tp4644984p4645128.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list