3
quantreg
패키지에서 penalized quantile regression을 수행 할 수 있습니다. 통계적으로 의미가 있다고 여겨지는 변수를 선택하는 것은 "쉽다". 그러나 계수에 대한 제한을 적용하는 것을 고려할 때 : 즉, 엄격히 양수/음수가되도록 (그렇지 않으면 0이 될 수 있습니다.) 어떻게 완료되었는지를 파악할 수 없었습니다. 내가 지금까지 가지고있는 코드는 다음과 같다 :quantile regression의 계수에 양/음의 제한 적용
quant<-c(0.4,0.5,0.6)
for (t in 400:600){ #the first 400 rows are the trainset, the remaining the test set. In each iteration
x=X[1:399,] #we increase the trainset by 1row and use it to predict for the next.
y=Y[1:399]
for (i in 1:quant) {
eq=rqss(y~x,method="lasso",tau=quant[i],lambda=lambdas) #find the significant variable though a Lasso quantile.
s=summary(eq)
findsigPV=s$coef[2:28,4] #select the stat. significant coefficient/variable
selectedPV=findsigPV<=0.05
if (sum(selectedPV)==0){
SelectedPV=rank(findsigPV)==1
}
newx=as.matrix(subset(X[1:t,],select=which(selectedPV))) #new matrix with the selected variable
eq=rq(y~newx[1:(t-1),],tau=quant[i]) #applies the new q. regression with the selected coeff from the lasso
pr[t-400+1,i]=c(1,newx[t,])%*%eq$coef #saves the forecast
}
}
나는이 문제가 매우 분명하다는 것을 두려워한다. 나는 ifelse(eq$coef<0,0,eq$coef)
을 사용하는 것을 고려했지만, 이상적인 해결책이 아닌 몇 가지 변수가 양수 또는 음수로 제한되어 있다고 가정합니다. 어떤 아이디어?
EDIT : 내가 포함하는 것을 잊어 버렸습니다. 각 반복마다 이전 반복과 다른 변수가 선택됩니다.