Neuman Co
2013-May-09 08:27 UTC
[R] Fit a standardized generalized hyperbolic distribution to my data?
Hi, I want to fit a standardized generalized hyperbolic distribution to my data, I am using the dsgh command of the fBasics package and the optim command. I tried the following: ---------------------------------------------------------------------------------------------------------------------------- startvalue<-c(1,0.5,1) loglikstandghyp <-function(zetapar,rhopar,lambdapar){ if(par>0) return(-sum(log(dsgh(mydata,zeta=zetapar,rho=rhopar,lambda=lambdapar)))) else return(Inf) } optim(startvalue, fn=loglikstandghyp, method="BFGS") ----------------------------------------------------------------------------------------------------------------------------- the problem is, that I get the following error message (in german): Fehler in if (delta <= 0) stop("delta must be greater than zero") : Fehlender Wert, wo TRUE/FALSE n?tig ist Now my question is, where is my mistake? Thanks a lot for your help! -- Neumann, Conrad
Enrico Schumann
2013-May-13 07:39 UTC
[R] Fit a standardized generalized hyperbolic distribution to my data?
On Thu, 09 May 2013, Neuman Co <neumancohu at gmail.com> writes:> Hi, > I want to fit a standardized generalized hyperbolic distribution to my > data, I am using the dsgh command of the fBasics package and the optim > command. > > I tried the following: > > ---------------------------------------------------------------------------------------------------------------------------- > startvalue<-c(1,0.5,1) > loglikstandghyp <-function(zetapar,rhopar,lambdapar){ > if(par>0) return(-sum(log(dsgh(mydata,zeta=zetapar,rho=rhopar,lambda=lambdapar)))) > else return(Inf) > } > > optim(startvalue, fn=loglikstandghyp, method="BFGS") > ----------------------------------------------------------------------------------------------------------------------------- > > the problem is, that I get the following error message (in german): > > Fehler in if (delta <= 0) stop("delta must be greater than zero") : > Fehlender Wert, wo TRUE/FALSE n?tig ist > > Now my question is, where is my mistake?Please provide a reproducible example, as the posting guide asks you to. But "Fehlender Wert, wo TRUE/FALSE n?tig ist" means that "delta <= 0" does not evaluate to TRUE or FALSE, but NA.> > Thanks a lot for your help! > > > -- > Neumann, Conrad >-- Enrico Schumann Lucerne, Switzerland http://enricoschumann.net