Skip to content
Back to formatted view

Raw Message

Message-ID: <1349425077630-4645128.post@n4.nabble.com>
Date: 2012-10-05T08:17:57Z
From: kmammasis
Subject: Help with R Fitting an inverse Gamma
In-Reply-To: <CAAmySGM=xmbVqtWMp1Em9i6P+9zkky2MLq5a3fTfx3aJ2_SNZw@mail.gmail.com>

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.