Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何估计R中分位数回归的分位数?_R_Quantile Regression - Fatal编程技术网

如何估计R中分位数回归的分位数?

如何估计R中分位数回归的分位数?,r,quantile-regression,R,Quantile Regression,我需要使用Sim和Zhou(2015)提出的分位数对分位数(QQ)方法估计一个模型[Sim,N.,Zhou,H.,2015。石油价格,美国股票收益率及其分位数之间的相关性。银行与金融杂志55,1-8] 我有两个变量,X和Y,代表增长率。我估计了分位数回归,但没能估计出QQ回归。尝试使用两个包:quantreg和quantreg.nonpar ## Data preparation data <- read.csv("data.csv", header = TRUE) data [, 2:3

我需要使用Sim和Zhou(2015)提出的分位数对分位数(QQ)方法估计一个模型[Sim,N.,Zhou,H.,2015。石油价格,美国股票收益率及其分位数之间的相关性。银行与金融杂志55,1-8]

我有两个变量,X和Y,代表增长率。我估计了分位数回归,但没能估计出QQ回归。尝试使用两个包:quantreg和quantreg.nonpar

## Data preparation
data <- read.csv("data.csv", header = TRUE)
data [, 2:3] <- log(data [, 2:3])
# Calclating growth rates
Y <- diff(data[,"Y"])/data[-nrow(data), "Y"] 
X <- diff(data[,"X"])/data[-nrow(data), "X"]
data.growth = cbind(Y, X)

## Quantile Regression =======================================
require("quantreg")
fit.rq <- rq(Y ~ X, tau = c(.1, .2, .3, .4, .5, .6, .7, .8, .9))
# Khmaladze test
kt <- KhmaladzeTest(formula = y ~ x, taus = -1)
KhmaladzeFormat(kt, 0.05)
#Goodness of fit
gof.rq <- GOFTest(fit.rq, alpha = 0.05, B = 1000, seed = 123)
gof.rq
# Transformation models
fit.rqt <- tsrq(Y ~ X, tsf = "ao", symm = FALSE, dbounded = FALSE, 
           conditional = FALSE, tau = c(.1, .2, .3, .4, .5, .6, .7,.8, .9))
fit.rqt; summary (fit.rqt)

# Non parametric
require (quantreg.nonpar)
form.par <- Y ~ X
basis.bsp <- create.bspline.basis(breaks = quantile(X, c(0:10)/10))
n=length (Y)
B <- 500 #500 simulations for the pivotal and Gaussian methods
B.boot <- 100 #00 repetitions for the weighted and gradient bootstrap methods
taus <-  c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
print.taus <- c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
alpha <- 0.05

data.growth = as.data.frame(data.growth)

piv.bsp <- npqr(formula = form.par, data = data.growth, basis = basis.bsp, var = "X", taus = taus, nderivs = 1, average = 1, B = B, alpha = alpha, process="none", rearrange=FALSE, uniform=TRUE, se="conditional", printOutput=TRUE, method="fn") # doesn`t work..

gaus.bsp <- update(piv.bsp, process = "gaussian", printOutput = FALSE)
wboot.bsp <- update(gaus.bsp, process = "wbootstrap", B = B.boot)
gboot.bsp <- update(wboot.bsp, process = "gbootstrap")

# QQR - don`t know... ======================================
数据准备 数据