0

I tried the following codes:

library(quantreg) # to load the package
library(foreign)  # to load the package

.Fortran("rqfn", PACKAGE = "quantreg")

but I get the following error:

Error in .Fortran("rqfn", PACKAGE = "quantreg") : 
"rqfn" not available for .Fortran() for package "quantreg"

I have installed Rtools. But it does not solve the problem. I also checked the issues concerning system paths (as in this site: https://github.com/stan-dev/rstan/wiki/Install-Rtools-for-Windows), but there is no problem about that. Could anyone give me a hand? Thank you very much.

Sheng Bi
  • 149
  • 4
  • 12
  • Have you looked carefully at the source code to see whether that subroutine is still actually used? Is it possible that it has been replaced by other/newer versions with different names? – joran Jan 17 '18 at 04:40
  • Hello,Joran, thank you very much for your help. this "rqfn" function is still in use, as from the package's github page: https://github.com/cran/quantreg/blob/master/src/rqfn.f , however, when I was checking the local directory where this quantreg is installed, I could not find this file! – Sheng Bi Jan 17 '18 at 05:21
  • The function `rqfn`is not registered, see https://github.com/cran/quantreg/blob/master/src/init.c#L49. Can you use `rqfnb` or `rqfnc`? – Ralf Stubner Jan 17 '18 at 07:07
  • Hello, thank you very much Ralf. I have tried `rqfnb` and `rqfnc`, but the same error message appears in R. – Sheng Bi Jan 17 '18 at 07:11
  • 1
    This is odd. On Linux I also get error messages, but those are like `Incorrect number of arguments (0), expecting 13 for 'rqfnb'`. So it looks usable in principle when supplied with the right number of arguments. – Ralf Stubner Jan 17 '18 at 07:30
  • Thank you... This is really weird.. For me, I always get the same error message. I am so confused. – Sheng Bi Jan 17 '18 at 08:46
  • On my Windows7, using `.Fortran("rqfnb", PACKAGE = "quantreg")` or `.Fortran("rqfnc", PACKAGE = "quantreg")` I get `Incorrect number of arguments (0), expecting 13 for 'rqfnb'` – Marco Sandri Jan 17 '18 at 14:21
  • Just because the source file exists doesn't mean it's still being used. The fact that it isn't registered suggests to me that `rqfn.f` may be legacy code. As others have observed, the `rqfnb` and `rqfnc` versions appear to be callable for me as well. – joran Jan 17 '18 at 15:45
  • @ShengBi Is the `quantreg` package correctly installed on your system? Do R functions like `rq.fit.fnb` work? – Ralf Stubner Jan 17 '18 at 18:56
  • @Marco Sandri Thank you very much for your reply. Indeed, for my Win 10, I now arrive at the same message as yours. So the problem is on `rqfn`. – Sheng Bi Jan 18 '18 at 10:04
  • @joran, Thank you very much Joran. Exactly, that is what I have found. Unfortunately, I really need `rqfn` for my study.. `rqfnb` and `rqfnc` could not replace its function.. – Sheng Bi Jan 18 '18 at 10:07
  • @Ralf Stubner Thank you very much for your help Stubner! I actually tried a lot of versions of `quantreg`, from the most up-to-date one to to the most ancient... – Sheng Bi Jan 18 '18 at 10:09

1 Answers1

1

You can build your own library:

  • Download rqfn.f and rqfnb.f. The latter is needed for stepy method.
  • Call R CMD SHLIB rqfn.f rqfnb.f
  • use the function like this:

    data(stackloss)
    x <- stack.x
    y <- stack.loss
    n <- length(y)
    p <- ncol(x)
    dyn.load(paste0("rqfn", .Platform$dynlib.ext))
    
    .Fortran("rqfn",
         as.integer(n),
         as.integer(p),
         a = as.double(t(as.matrix(x))),
         c = as.double(y),
         rhs = double(p),
         d = double(n),
         beta = as.double(0.99995),
         eps = as.double(1e-6),
         tau = as.double(0.5),
         wn = double(10 * n),
         wp = double((p + 3) * p),
         aa = double(p * p),
         it.count = integer(2),
         info = integer(1))
    
Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
  • Thank you Stubner.... I am really impressed.... To be honest, I do not think I understand how it works and why it is so... but that is really really nice.. and Thank you very much for your constant concern on my problem.. – Sheng Bi Jan 18 '18 at 12:47