Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing Fortran referenced code from R

Tags:

r

edit

fortran

I would like to be able to edit the Fortran code that is referred to in the fGarch package.

More specifically I would like to edit the available conditional distributions that can be used by fGarch::garchFit, i.e. including the stable distribution and the generalised hyperbolic distribution.

So having looked into the garchFit() function, I have delved (deepish) into the code, and .aparchLLH.internal() is referred to from the garchFit() function and there is a line in there that refers to Fortran written code.

The specific line that I am referring to is the following bit of code:

    fit <- .Fortran("garchllh", N = as.integer(N), Y = as.double(.series$x), 
        Z = as.double(.series$z), H = as.double(.series$h), 
        NF = as.integer(NF), X = as.double(params), DPARM = as.double(DPARM), 
        MDIST = as.integer(MDIST), MYPAR = as.integer(MYPAR), 
        F = as.double(0), PACKAGE = "fGarch")

I believe that the Fortran function garchllh is what I would like to edit, but do not know how to go about editing it so that I can introduce new distributions into the garchFit() function.

N.B. Just as a note, I do not have much experience in Fortran code, but would like to have a look at it to see if it can be edited and altered to fit for my purpose, so any help on the Fortran editing of code section would be much appreciated...

like image 260
h.l.m Avatar asked May 07 '26 01:05

h.l.m


1 Answers

As mentioned in comments, you need to download the source -- a good place would be to start with install.packages("fGarch",type="source") and see that everything compiles properly. Then, look at the package source -- seems like you would need to do a pretty straightforward adjustment to dist.f, and probably add more changes to various places where MDIST is set -- start with grep MDIST *.R in the R directory of the extracted source. After you're done and tested, you could also talk to the package maintainers -- perhaps they would include your additions in the next version :)

like image 123
laxxy Avatar answered May 09 '26 15:05

laxxy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!