Dear all,

I am trying to use the nonlinear quantile regression which involves copula
functions. Following the Frank copula example provided in the "quantreg"
vignette I try do do the same using the Normal (Gaussian) copula. The
problem is that the "nlrq" algorithm stops by giving the following error:

"Error in numericDeriv(form[[3]], names(ind), env) :
  Missing value or an infinity produced when evaluating the model
In addition: Warning message:
In sqrt(1 - rho^2) : NaNs produced
Error in nlrq.calc(m, ctrl, trace) : optim unable to find valid step size"

I have to say that rarely (e.g. 1% of the times) the code below works, but
gives me really wrong estimations for some quantiles.

I suspect the convergence problem is related to the correlation parameter
"rho". Is there any way I can put "lower" and "upper" parameter bounds in
"nlrq" e.g. like in "nls"? Well..., by looking the ?nlrq it seems this is
not possible, but I hope I am wrong :).

Some example code:
library(quantreg)
n <- 1000 # sample size
df <- 3 # degrees of freedom for the marginal distribution
rho <- 0.5 # Normal copula parameter
u <- runif(n)
x <- sort(rt(n,df))
v <- pnorm(rho*qnorm(pt(x,df))+sqrt(1-rho^2)*qnorm(u))
y <- qnorm(v)

# below I assume I know Fx is t-distributed with known df.
plot(x, y, pch = ".", cex = 3,xlim=c(-4,4),ylim=c(-4,4),main="Normal copula
pth quantile curves")
us <- seq(0.1,0.9,0.1)
for (i in 1:length(us)) {
  vq <- pnorm(rho*qnorm(pt(x,df))+sqrt(1-rho^2)*qnorm(us[i]))
  lines(x, qt(vq,df),lty=ltys[i],lwd=3,col="blue")
}

Dat <- NULL
Dat$x <- x
Dat$y <- y
deltasN <- matrix(0, length(us),3)
# here is my non-linear quantile model
NormalModel <- function(x,rho, mu,sigma,df,tau){
  z <- qt(pnorm(rho*qnorm(pt(x,df))+sqrt(1-rho^2)*qnorm(tau)),df)
  mu + sigma * z
}
for (i in 1:length(us)) {
  tau = us[i]
  fit <- nlrq(y ~ NormalModel(x,rho, mu,sigma,df=3,tau = tau), data = Dat,
tau = tau,
              start = list(rho =0.5,mu = 0, sigma = 1),
              trace = TRUE)
  lines(x, predict(fit, newdata = x), lty = 2,col = "red")
  deltasN[i, ] <- coef(fit)
}
deltasN

I am running R(3.03) on Mac OS 10.9 and  quantreg(5.05)

Thank you!

Francesco

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to