Skip to content

Commit

Permalink
version 0.9-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Brandt authored and gaborcsardi committed Jul 21, 2014
1 parent 741f6c0 commit 3dc9d02
Show file tree
Hide file tree
Showing 22 changed files with 938 additions and 344 deletions.
12 changes: 5 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: MSBVAR
Version: 0.9-0
Date: 2014-05-12
Version: 0.9-1
Date: 2014-07-21
Title: Markov-Switching, Bayesian, Vector Autoregression Models
Authors@R: c(person("Patrick", "Brandt", role=c("aut", "cre"),
email="pbrandt@utdallas.edu"),
Expand All @@ -23,10 +23,8 @@ License_is_FOSS: yes
License_restricts_use: no
SystemRequirements: gcc (>= 4.0)
NeedsCompilation: yes
Repository: CRAN
Packaged: 2014-06-02 02:25:42 UTC; pbrandt
Packaged: 2014-07-25 14:13:56 UTC; pbrandt
Author: Patrick Brandt [aut, cre],
W. Ryan Davis [cre]
X-CRAN-Comment: Archived on 2014-05-16 as C++ errors were not
corrected.
Date/Publication: 2014-06-02 07:44:50
Repository: CRAN
Date/Publication: 2014-07-25 16:29:00
77 changes: 0 additions & 77 deletions INDEX

This file was deleted.

37 changes: 20 additions & 17 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
263b03fca1747f78c6f7dc74e8d028b3 *COPYING
8e279e84b02b6f771d066ce426319a70 *DESCRIPTION
37df0a1f27597d59af4c19b347589af4 *INDEX
dd4248ad89e250ba3bb27217be7044d0 *DESCRIPTION
da698cafd7de018ee86094fa42d59499 *LICENSE
909528054badf5cea9f0609e931f062f *NAMESPACE
c43895aaf282336d59d1a5e1b46b6e85 *R/SS.R
e80eaad95ea6a341bc5b2b33a7dbb598 *NAMESPACE
30b712208e1d2d8d9b1f1bb5378d247b *R/SS.R
6d830eb1c07d910ae9fd6bec2c3748ac *R/SZ.prior.evaluation.R
93bb693d9896ccaf7d68bd431776d725 *R/bingen.R
d844243c146376d17129bf894ba3fd99 *R/cf.forecasts.R
Expand All @@ -12,26 +11,28 @@ c480d7798b5bab4103618f3c82042fbf *R/decay.spec.R
91d1778127103971fbae84c9ddfa4856 *R/dirichlet.R
30db62f077faeed7b480eb248a8c29b8 *R/forc.ecdf.R
0eba252744538902df7af9f427252bbf *R/forecast.R
d9db5d2eca20190b28ae793f5da25563 *R/gibbs.A0.R
70f8ad30016286a21a96919cbfb00abe *R/gibbs.msbvar.R
811115d191a61af1a5f6400dd6bb8b4a *R/gibbs.A0.R
40eb16465764907458f83517417a4f31 *R/gibbs.msbvar.R
7cf1c881872485b37ae08f4d8625a321 *R/granger.test.R
3dcb767f666147574a7dd09a10841aca *R/hidden.R
1be48552bed217f2c7b6c8d7fc1595a8 *R/hidden.R
4c754dd77a3dd2a96f0532138b3aeb45 *R/initialize.msbvar.R
af5deb7ee2caa863984bede78820c522 *R/irf.R
8468b4cb294cd04193515124aa0cf265 *R/mae.R
1fabe264b50d3cded3179ea4d14804a4 *R/mc.irf.R
3668d8fa15a5df0a1234820b86431cf2 *R/mc.irf.R
09675c7ee0f39f1c2e5152bdd26bc7f9 *R/mcmc.szbsvar.R
3e32eeac91cd18d07b621ab5606f578a *R/mountains.R
82e5d1317601337375c7e3e652341051 *R/msbvar.R
1d5d739c8575a1ad2b7656153c55571d *R/msbvar.R
583f907c6c69033f3382a00b0ac6108f *R/msvar.R
2976e679c48d46b686e6f93277e4ea06 *R/normalize.svar.R
bb677b8d84a41b26def6c36e27110148 *R/null.space.R
16120dcf9957d20718b5374601bb5d16 *R/plot.forecast.R
8b0536a3bad9cdecf33cd42916b43bb2 *R/plot.gibbs.A0.R
f61285887884ff9e61c5fcb9d96da4eb *R/plotregimeid.R
c528064d373f6671c0557e06ddf00f46 *R/plot.ms.irf.R
263cf65697ff2dd90a660463e5ea175c *R/plotregimeid.R
9d4c38af081fbd0f34d37fed4be136e6 *R/posterior.fit.MSBVAR.R
07ccf06a4b8e6995e02aee5b92acce2f *R/posterior.fit.R
6e0bffc1d2d1ebed9b9aafceeef18798 *R/reduced.form.var.R
d7eb836b589ce1eab63e43cfeda83782 *R/regimeSummary.R
51f8d87f4547500a49dea1248f009f60 *R/restmtx.R
4e02924a00e721cc1f753907c1c742b4 *R/rmse.R
ca28dc276af51dde8145ce7a6ab2a14e *R/rmultnorm.R
Expand All @@ -40,11 +41,11 @@ d2aa833f0d112a15558e0a324899aa77 *R/sanity.R
fada5ea7f491930c01e6103d356fdb4d *R/simulateMSAR.R
3a9cee55de864ffe9776addeceddb5ba *R/simulateMSVAR.R
6c0e86eb252e2f26c48fefa9c775e24b *R/summary.forecast.R
4c3689e4afc1788219f4ce2349b33545 *R/szbsvar.R
5ffef7a45de64a3a0dd9226ac138fb80 *R/szbsvar.R
76ecb015e69c8071658d4c972dc737f8 *R/szbvar.R
e2cfb2b344eb82c74b8cf367f999c032 *R/var.lag.specification.R
19d6422ac7f6fdb0a2d33e248d66158e *R/zzz.R
0651f94cacc35e391013ee3361a8b267 *README
218d9b8099acc09307ed3af30f9d531f *R/zzz.R
6ce69e2f14a7bc6a382761e5e08d823c *README
82d0f588881aa6321cf0218103fa54cd *data/BCFdata.RData
45ebcc7201eeafe51b0985e09799210f *data/HamiltonGDP.RData
9eedc964b21323db8dcfbd911a7bf012 *data/IsraelPalestineConflict.RData
Expand All @@ -58,7 +59,7 @@ e708ce7cb97f0d7ce37fd2ba0c5fa3cc *man/SS.ffbs.Rd
1697e966d2b28c2a80de3a88906bdc5a *man/decay.spec.Rd
fdaa840ce053b290d8587d709234b26e *man/dfev.Rd
971581274c80f77629c45515b229f721 *man/forc.ecdf.Rd
1d4c4aa437541c528c693f2a7298eab3 *man/forecast.Rd
0a13dbdc42a6771e1ea8faea28453fe3 *man/forecast.Rd
b94312c008bcab96caaeb06cb06c8666 *man/gibbs.A0.Rd
19bd7c3d61788dcaca813405c52f0386 *man/gibbs.msbvar.Rd
c97250ae9a947b0ae73f98a9e45a56c4 *man/granger.test.Rd
Expand All @@ -68,7 +69,7 @@ fcd8e0374ec1de289c267dcceebc669e *man/irf.Rd
73d0c18ba584aa338167ac789e1df5ef *man/ldwishart.Rd
bccc6efada6ad5f7d1944304f6850439 *man/list.print.Rd
65ff31a99b95d794acbced10f821976a *man/mae.Rd
3000245eeacf379140d958d0b5de1f7e *man/mc.irf.Rd
220a3ce937f2cfaf5513f75ef09a89e4 *man/mc.irf.Rd
7d68622ff0c8bc50aef9b9e1b3900700 *man/mcmc.szbsvar.Rd
f0cc2a97c2e47c1160abb7b8f16b658e *man/mean.SS.Rd
4ba5287cbd637226351d07de0c288505 *man/mountains.Rd
Expand All @@ -80,13 +81,15 @@ ce252d133b4b3845d26ab37f5ef18f9e *man/plot.forc.ecdf.Rd
f79be7d0e8e94efc32feffc2e4029dba *man/plot.forecast.Rd
8582cd96e1608167db251344593fef72 *man/plot.gibbs.A0.Rd
7d683eec86c465ed15235fb0f3590a1d *man/plot.irf.Rd
b93b80e588b3fdb9e21c79edae3e8037 *man/plot.mc.irf.Rd
9c6888a45e024e1aba3e79933ee29aeb *man/plot.mc.irf.Rd
a09c22657ae3930a1871d31f6c989b86 *man/plot.ms.irf.Rd
099bc9e2e98c47f1d75e30a8590a7f0d *man/plotregimeid.Rd
afe286db0d4802894339a5664498748f *man/posterior.fit.Rd
723e006934f01bc565803d3c171ae6c4 *man/print.dfev.Rd
d5ddafccc70f8ed4e5586cb1cfb822a4 *man/print.posterior.fit.Rd
ffa73bfd30cea1455e06126ffe19e39d *man/rdirichlet.Rd
0dda3c0f8910e63b58d7f4d9d0085b12 *man/reduced.form.var.Rd
74c101d884c41e4b85341824619b1c7b *man/regimeSummary.Rd
21680523257e53ed0546fb7ad12cb62a *man/restmtx.Rd
d554a8c02ff94b6718f70b1e78be527c *man/rmse.Rd
c992dc3e8781eb4109d70e722c0bbb06 *man/rmultnorm.Rd
Expand All @@ -95,7 +98,7 @@ c992dc3e8781eb4109d70e722c0bbb06 *man/rmultnorm.Rd
e81375e32cdf0aabe93580ac55410d81 *man/simulateMSVAR.Rd
11e4c5302be19f002b4b795bf8e4c19a *man/summary.Rd
1a66c55b5bfd146d0f66e02bdc152634 *man/summary.forecast.Rd
3902add185fb398f52bcf4ff3eebb732 *man/szbsvar.Rd
d02a56fffa5209670bfb960a0f7bfef3 *man/szbsvar.Rd
704935c7d8d0372113c77ef93d9ee48a *man/szbvar.Rd
bbc1ef586b1699763943f166bdcffd55 *man/uc.forecast.Rd
67107b4b3c8e42814ed55c6b8682860e *man/var.lag.specification.Rd
Expand Down
5 changes: 3 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export(
plot.gibbs.A0,
plot.irf,
plot.mc.irf,
plot.ms.irf,
plot.forecast,
plot.forc.ecdf,
plotregimeid,
Expand All @@ -62,7 +63,8 @@ export(
initialize.msbvar,
simulateMSVAR,
simulateMSAR,
msvar
msvar,
regimeSummary
)

# Declare S3 methods for printing and summaries
Expand Down Expand Up @@ -97,4 +99,3 @@ S3method(plot, forecast.VAR)
S3method(sum, SS)
S3method(mean, SS)
S3method(plot, SS)

8 changes: 6 additions & 2 deletions R/SS.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ mean.SS <- function(x, ...){
plot.SS <- function(x, ylab="State Probabilities", ...)
{
tmp <- mean.SS(x)
plot(ts(tmp), plot.type="single", col=1:ncol(tmp),
shift <- x$p/attr(x, "freq")
plot(ts(tmp,
start=attr(x, "start")+shift,
end=attr(x, "end"), frequency=attr(x, "freq")),
### deltat=attr(x, "freq")),
plot.type="single", col=1:ncol(tmp),
ylim=c(0,1), ylab=ylab, ...)
abline(h=0.5, lty=2, ...)
}
Expand Down Expand Up @@ -132,4 +137,3 @@ plot.SS <- function(x, ylab="State Probabilities", ...)
## ss <- generate.states(fp, Q)
## return(ss)
## }

5 changes: 4 additions & 1 deletion R/gibbs.A0.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
as.integer(thin), as.integer(method),
gibbs.setup.bsvar(varobj)$UT)

# Memory cleanup
gc(); gc();

# Set classing
class(tmp2) <- c("gibbs.A0")
return(tmp2)
}


# Converts the A0 object into something that coda can understand.
"A02mcmc" <- function(x)
{
return(mcmc(matrix(x$A0.posterior$A0,
Expand All @@ -33,4 +37,3 @@
byrow=T),
thin=x$thin))
}

5 changes: 5 additions & 0 deletions R/gibbs.msbvar.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# managable chunks.
# 20120113 : Replaced filtering-sampler steps for the state space with
# compiled Fortran code.
# 20140609 : Added gc() calls for some improved memory usage


####################################################################
Expand Down Expand Up @@ -502,6 +503,8 @@ gibbs.msbvar <- function(x, N1=1000, N2=1000,

# End of burnin loop!

gc(); gc()

# Declare the storage for the return objects
ss.storage <- vector("list", N2)
transition.storage <- array(NA, c(h,h,N2))
Expand Down Expand Up @@ -600,6 +603,8 @@ gibbs.msbvar <- function(x, N1=1000, N2=1000,
if(j%%1000==0) cat("Final iteration : ", j, "\n")
}

gc(); gc()

# Now make an output object and provide classing
class(ss.storage) <- c("SS")

Expand Down
30 changes: 29 additions & 1 deletion R/hidden.R
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,35 @@ function(capT,m,ncoef,num.exog,nu,H0,S0,Y,X,hstar1,Sh,u, Bh,Sh1)
return(Wout)
}

############################################
# MSBVAR model helper functions
############################################

# Get the long run regime probabilities from transition matrix P

steady.Q <- function(P)
{ M <- dim(P)[1]
if (M<3)
{
eta <- solve(rbind(cbind(1 - P[1,1], P[2,1]), rep(1,2)))%*%matrix(c(0,1))
}
else
{
eta <- solve(rbind(cbind(diag(M-1) - t(P)[1:(M-1),1:(M-1)],
t(P)[1:(M-1),M]),
rep(1,M)))%*%matrix(c(rep(0,M-1),1))

}
# Find the steady state if there are negative values -- that is
# iterate a bit!
while(cumprod(eta)[M]<0)
{
eta <- t(P)%*%eta
}
return(eta)
}




## # ONE STEP Function to draw 1 A0 from the posterior of a structural
Expand Down Expand Up @@ -537,4 +566,3 @@ function(capT,m,ncoef,num.exog,nu,H0,S0,Y,X,hstar1,Sh,u, Bh,Sh1)
## return(list(A0gbs=A0gbs, W=Wout))

## }

0 comments on commit 3dc9d02

Please sign in to comment.