Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00a522d
commit c298412
Showing
10 changed files
with
285 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
Package: nardl | ||
Type: Package | ||
Title: Nonlinear Cointegrating Autoregressive Distributed Lag Model | ||
Version: 0.1.1 | ||
Version: 0.1.2 | ||
Author: Taha Zaghdoudi | ||
Maintainer: Taha Zaghdoudi <zedtaha@gmail.com> | ||
Description: Computes the nonlinear cointegrating autoregressive distributed lag model with p lags of the dependent variables and q lags of independent variables proposed by (Shin, Yu & Greenwood-Nimmo, 2014 <doi:10.1007/978-1-4899-8008-3_9>). | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 5.0.1 | ||
RoxygenNote: 6.0.1 | ||
Imports: stats, methods, car, strucchange, tseries, lmtest, matlab, | ||
qpcR, Formula | ||
Formula | ||
NeedsCompilation: no | ||
Packaged: 2018-01-25 14:50:50 UTC; Asus | ||
Packaged: 2018-02-06 21:14:33 UTC; Asus | ||
Repository: CRAN | ||
Date/Publication: 2018-01-25 14:57:20 UTC | ||
Date/Publication: 2018-02-06 21:20:15 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
3afb4e83abd5c80a613313251132d223 *DESCRIPTION | ||
fe5b8572e04da4e55e2a9d9df02cc596 *NAMESPACE | ||
2c69fe347cd3053a6b7d86bca7f9f3a4 *DESCRIPTION | ||
08a4f7ad70b8402391e9752ada5c1c50 *NAMESPACE | ||
a542e51873be0d571257f2a1ae3b6392 *R/boundstest.R | ||
bdbbb2612552e5905e49396ddadcf527 *R/nardl.R | ||
6287375fbd4b4702de78d72b44fdb8de *R/dynmplier.R | ||
95c066f550272fc9ead141b7cdfa2613 *R/nardl.R | ||
24ac6af7df6fc51a6d99fd56ae211f9e *data/fod.rda | ||
50e218f11e587ea051f5d57cbf5262b3 *man/Nardl-package.Rd | ||
8f2959858f1eb6c82be0272d5a10dd50 *man/fod.Rd | ||
8893631ade3e2c057de71f848bb7cbe6 *man/nardl.Rd | ||
b29ed5d13fc62c5443decc406d7ee371 *man/summary.nardl.Rd | ||
06471780c719f63c1f35be020cf073f4 *man/Nardl-package.Rd | ||
c19c63e806b59f5e85ccb3da6c4304d7 *man/fod.Rd | ||
706457849f766b5c8bb69aebfa398880 *man/nardl.Rd | ||
e3ea5b8cf02555b40b471d12593c0d9d *man/plotmplier.Rd | ||
86199bdd050825292351ac3c77630bcc *man/summary.nardl.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
mplier<-function(alpha,beta,varphi,vpi,l,h,k){ | ||
# k number of independent variables | ||
# h is the horizon over which multipliers will be computed | ||
# l max(p,q) | ||
vphi<-matlab::zeros(1,l) | ||
vphi[1] = 1 + alpha + varphi[1] | ||
i=2 | ||
while(i<=l){ | ||
vphi[i] = varphi[i] - varphi[i-1] | ||
i=i+1 | ||
} | ||
|
||
vphi[l] = -varphi[l-1] | ||
|
||
mtheta = matlab::zeros(l+1,k) | ||
mtheta[1,] = vpi[1] | ||
mtheta[2:3,] = vpi[2] - vpi[1] + beta | ||
i=3 | ||
while(i<=l+1){ | ||
mtheta[i,] = vpi[i] - vpi[i-1] | ||
i=i+1 | ||
} | ||
mtheta[l+1,] = -vpi[l] | ||
mpsi =matlab::zeros(h,k) | ||
#mpsi<-NULL | ||
mpsi[1,] = mtheta[1,] | ||
i=1 | ||
while(i<=l){ | ||
mpsi[i+1,] = vphi[1:i]%*%mpsi[i:1,] + mtheta[i+1,] | ||
|
||
i=i+1 | ||
} | ||
|
||
i=l+1 | ||
mps<-vector('list',length(mpsi)) | ||
while(i<=h-1){ | ||
mps[[i+1]]<-t(vphi)%*%mpsi[i:i-l+1] | ||
#mpsi<-c(mpsi[i+1],t(vphi)%*%mpsi[i-l+1:i]) | ||
i=i+1 | ||
} | ||
mps<-matrix(do.call(rbind,mps)[1:h,]) | ||
cm<-apply(mps, 2, cumsum) | ||
return(cm) | ||
} | ||
|
||
#'Dynamic multiplier plot | ||
#' | ||
#'@param model the fitted model | ||
#'@param np the selected number of lags | ||
#'@param k number of decomposed independent variables | ||
#'@param h is the horizon over which multipliers will be computed | ||
#'@importFrom stats lm AIC BIC as.formula model.frame model.matrix model.response na.omit sd update vcov embed resid coef | ||
#'@importFrom graphics abline legend lines par plot | ||
#'@import matlab | ||
#'@examples | ||
#' | ||
#' ############################ | ||
#' # Dynamic multipliers plot | ||
#' ############################ | ||
#' # Load data | ||
#'data(fod) | ||
#' reg<-nardl(food~inf,p=4,q=4,fod,ic="aic",maxlags = FALSE,graph = TRUE) | ||
#' plotmplier(reg,reg$np,1,10) | ||
#' | ||
#'@export | ||
plotmplier<-function(model,np,k,h){ | ||
|
||
if(np<=1) stop("number of lags must be > 1 ") | ||
#positive | ||
alpha<-as.matrix(coef(model$fit)[2:2]) | ||
betap<-as.matrix(coef(model$fit))[3:3] | ||
betan<-as.matrix(coef(model$fit))[4:4] | ||
varphi<-as.matrix(coef(model$fit)[5:(4+np)]) | ||
vpip<-as.matrix(coef(model$fit)[(5+np):((4+np)+np)]) | ||
vpin<-as.matrix(coef(model$fit)[((5+np)+np):(((4+np)+np)+np)]) | ||
mpp<-mplier(alpha,betap,varphi,vpip,np,h,k) | ||
mpn<-mplier(alpha,betan,varphi,vpin,np,h,k) | ||
x = seqa(0,1,(h+1)) | ||
yp<-cbind(matlab::zeros(1,1),t(mpp)) | ||
yn = cbind(matlab::zeros(1,1),t(mpn)) | ||
dmp<-mpp-mpn | ||
yrange<-range(yp,yn,(yp-yn)) | ||
par(mar = c(5,4,4,8)) | ||
plot(x,yp,main="Dynamic multiplier",type = "l",ylim =yrange ,xlab ="", | ||
ylab = "", col="red") | ||
lines(x,yn,col="blue") | ||
lines(x,(yp-yn),lty=2,col="darkgreen") | ||
abline(h=0) | ||
legend(par("usr")[2],par("usr")[4], | ||
xpd = TRUE , | ||
bty = "n", | ||
c(names(coef(model$fit)[3:3]),names(coef(model$fit)[4:4]),"Difference"), | ||
lty = c(1, 1, 2), | ||
cex=0.6, | ||
col=c("blue","red","darkgreen")) | ||
|
||
|
||
|
||
} |
Oops, something went wrong.