├── OldVersions └── v2dot0 │ ├── ExportFig │ ├── .ignore │ │ ├── ghostscript.txt │ │ └── gs_font_path.txt │ ├── license.txt │ └── pdf2eps.m │ ├── Auxiliary │ ├── nanmax.m │ ├── nanmean.m │ ├── nanmin.m │ ├── nansem.m │ ├── nanstd.m │ ├── nansum.m │ ├── nanvar.m │ ├── nanmedian.m │ ├── nanmovavg.m │ ├── clearex.m │ ├── trimr.m │ ├── tdis_inv.m │ ├── tdis_prb.m │ ├── beta_pdf.m │ ├── fdis_prb.m │ ├── beta_inv.m │ ├── ws2struct.m │ └── winsor.m │ ├── README.txt │ ├── Utils │ ├── vec.m │ ├── rows.m │ ├── cols.m │ ├── NaN2Num.m │ ├── Num2NaN.m │ ├── cell2num.m │ ├── roundnum2cell.m │ ├── xlsclear.m │ ├── TabPrint.m │ ├── XoX.m │ ├── CommonSample.m │ └── TreatData.m │ ├── Figure │ ├── BarPlot.m │ ├── LegOption.m │ ├── SaveFigure.m │ ├── NumTotFigures.m │ ├── Date2Num.m │ ├── FigSize.m │ ├── FigFontOption.m │ ├── PlotLineOption.m │ ├── FigFont.m │ ├── DatesCount.m │ └── DatesCreate.m │ ├── VAR │ ├── OrthNorm.m │ ├── VARmakelags.m │ ├── L.m │ ├── VARoption.m │ ├── VARdrawpost.m │ ├── VARmakexy.m │ ├── VARhdplot.m │ └── SRhdplot.m │ └── Stats │ ├── StarVariable.m │ ├── MovCorr.m │ ├── MovCorrCent.m │ ├── CorrTable.m │ ├── MovAvgCent.m │ ├── MovAvg.m │ ├── MovSum.m │ └── MovStd.m ├── v3dot0 ├── ExportFig │ ├── .gitignore │ ├── print2eps.m │ ├── resources │ │ └── project │ │ │ ├── Root.type.Files │ │ │ ├── LICENSE.type.File.xml │ │ │ ├── .gitignore.type.File.xml │ │ │ ├── README.md.type.File.xml │ │ │ ├── ImageSelection.class.type.File.xml │ │ │ ├── ImageSelection.java.type.File.xml │ │ │ ├── copyfig.m.type.File.xml │ │ │ ├── eps2pdf.m.type.File.xml │ │ │ ├── export_fig.m.type.File.xml │ │ │ ├── fix_lines.m.type.File.xml │ │ │ ├── im2gif.m.type.File.xml │ │ │ ├── pdf2eps.m.type.File.xml │ │ │ ├── pdftops.m.type.File.xml │ │ │ ├── print2eps.m.type.File.xml │ │ │ ├── using_hg2.m.type.File.xml │ │ │ ├── append_pdfs.m.type.File.xml │ │ │ ├── crop_borders.m.type.File.xml │ │ │ ├── ghostscript.m.type.File.xml │ │ │ ├── isolate_axes.m.type.File.xml │ │ │ ├── print2array.m.type.File.xml │ │ │ ├── user_string.m.type.File.xml │ │ │ └── read_write_entire_textfile.m.type.File.xml │ │ │ ├── Project.xml │ │ │ ├── ProjectData.type.Info.xml │ │ │ ├── uuid-cc21a9b0-026d-4b70-9821-3eb23d2abf81.xml │ │ │ ├── Root.type.ProjectPath │ │ │ └── a533e478-c90b-4a1f-a45b-f8877af57bee.type.Reference.xml │ │ │ ├── Root.type.Categories │ │ │ ├── FileClassCategory.type.Category │ │ │ │ ├── none.type.Label.xml │ │ │ │ ├── other.type.Label.xml │ │ │ │ ├── test.type.Label.xml │ │ │ │ ├── derived.type.Label.xml │ │ │ │ ├── design.type.Label.xml │ │ │ │ ├── artifact.type.Label.xml │ │ │ │ └── convenience.type.Label.xml │ │ │ └── FileClassCategory.type.Category.xml │ │ │ └── Extensions.type.Root │ │ │ └── DependencyAnalysis.type.Extension │ │ │ └── ExternalFiles.type.Extension.xml │ ├── ImageSelection.java │ ├── ImageSelection.class │ ├── Export_fig.prj │ ├── read_write_entire_textfile.m │ ├── using_hg2.m │ ├── LICENSE │ ├── pdf2eps.m │ ├── copyfig.m │ └── hyperlink.m ├── VAR │ ├── VARlag.m │ ├── OrthNorm.m │ ├── VARmakelags.m │ ├── L.m │ ├── VARdrawpost_backup.m │ ├── VARdrawpost.m │ └── VARmakexy.m ├── Auxiliary │ ├── nanmax.m │ ├── nanmean.m │ ├── nanmin.m │ ├── nansem.m │ ├── nanstd.m │ ├── nansum.m │ ├── nanvar.m │ ├── nanmedian.m │ ├── nanmovavg.m │ ├── clearex.m │ ├── seqa.m │ ├── trimr.m │ ├── tdis_inv.m │ ├── tdis_prb.m │ ├── ptrend.m │ ├── beta_pdf.m │ ├── fdis_prb.m │ ├── tdiff.m │ ├── beta_inv.m │ ├── ws2struct.m │ ├── winsor.m │ ├── lag.m │ └── roundn.m ├── Replic │ ├── BQ1989 │ │ ├── IR_1.pdf │ │ ├── IR_2.pdf │ │ ├── BQ1989_Data.xlsx │ │ ├── BQ1989_Paper.pdf │ │ └── BQ_Replication.pdf │ ├── SW2001 │ │ ├── IR_1.pdf │ │ ├── IR_2.pdf │ │ ├── IR_3.pdf │ │ ├── VD.pdf │ │ ├── SW2001_Data.xlsx │ │ └── SW2001_Paper.pdf │ ├── GK2015 │ │ ├── GK2015_Data.xlsx │ │ ├── GK2015_Paper.pdf │ │ └── GK_Replication.pdf │ └── Uhlig2005 │ │ ├── Uhlig2005_Data.xlsx │ │ ├── Uhlig2005_Paper.pdf │ │ └── Uhligh_Replication.pdf ├── Primer │ ├── graphics │ │ ├── iv_.pdf │ │ ├── BQ_DATA.pdf │ │ ├── BQ_IR_1.pdf │ │ ├── BQ_IR_2.pdf │ │ ├── GK_DATA.pdf │ │ ├── GK_IR_1.pdf │ │ ├── GK_IR_2.pdf │ │ ├── GK_IR_3.pdf │ │ ├── GK_IR_4.pdf │ │ ├── SW_DATA.pdf │ │ ├── SW_HD_1.pdf │ │ ├── SW_HD_2.pdf │ │ ├── SW_HD_3.pdf │ │ ├── SW_IR_1.pdf │ │ ├── SW_IR_2.pdf │ │ ├── SW_IR_3.pdf │ │ ├── SW_VD.pdf │ │ ├── BIV_DATA.pdf │ │ ├── longCum_.pdf │ │ ├── signAll_.pdf │ │ ├── sign_IR_1.pdf │ │ ├── sign_IR_2.pdf │ │ ├── GK_alt_IR_1.pdf │ │ ├── Uhlig_DATA.pdf │ │ ├── iv_sign_IR_1.pdf │ │ ├── iv_sign_IR_2.pdf │ │ ├── BQ_Replication.pdf │ │ ├── Uhlig_Replication.pdf │ │ ├── Uhlig_Replication_1rot.pdf │ │ ├── Uhlig_Replication_2rot.pdf │ │ └── Uhlig_Replication_500rot.pdf │ ├── _old │ │ ├── graphics │ │ │ ├── iv_.pdf │ │ │ ├── BQ_DATA.pdf │ │ │ ├── BQ_IR_1.pdf │ │ │ ├── BQ_IR_2.pdf │ │ │ ├── GK_DATA.pdf │ │ │ ├── GK_IR_1.pdf │ │ │ ├── GK_IR_2.pdf │ │ │ ├── GK_IR_3.pdf │ │ │ ├── GK_IR_4.pdf │ │ │ ├── SW_DATA.pdf │ │ │ ├── SW_HD_1.pdf │ │ │ ├── SW_HD_2.pdf │ │ │ ├── SW_HD_3.pdf │ │ │ ├── SW_IR_1.pdf │ │ │ ├── SW_IR_2.pdf │ │ │ ├── SW_IR_3.pdf │ │ │ ├── SW_VD.pdf │ │ │ ├── BIV_DATA.pdf │ │ │ ├── longCum_.pdf │ │ │ ├── signAll_.pdf │ │ │ ├── sign_IR_1.pdf │ │ │ ├── sign_IR_2.pdf │ │ │ ├── GK_alt_IR_1.pdf │ │ │ ├── Uhlig_DATA.pdf │ │ │ ├── iv_sign_IR_1.pdf │ │ │ ├── iv_sign_IR_2.pdf │ │ │ ├── BQ_Replication.pdf │ │ │ ├── Uhlig_Replication.pdf │ │ │ ├── Uhlig_Replication_1rot.pdf │ │ │ ├── Uhlig_Replication_2rot.pdf │ │ │ └── Uhlig_Replication_500rot.pdf │ │ └── data │ │ │ ├── BQ1989_Data.xlsx │ │ │ ├── CS2020_Data.xlsx │ │ │ ├── GK2015_Data.xlsx │ │ │ ├── SW2001_Data.xlsx │ │ │ ├── Simple_Data.xlsx │ │ │ ├── Simple_Data_2.xlsx │ │ │ └── Uhlig2005_Data.xlsx │ ├── data │ │ ├── BQ1989_Data.xlsx │ │ ├── CS2020_Data.xlsx │ │ ├── GK2015_Data.xlsx │ │ ├── SW2001_Data.xlsx │ │ ├── Simple_Data.xlsx │ │ ├── Simple_Data_2.xlsx │ │ └── Uhlig2005_Data.xlsx │ └── .gitignore ├── Utils │ ├── getqr.m │ ├── rows.m │ ├── cols.m │ ├── columns.m │ ├── NoSpace.m │ ├── NaN2Num.m │ ├── Num2NaN.m │ ├── cell2num.m │ ├── vec.m │ ├── roundnum2cell.m │ ├── TabPrint.m │ ├── XoX.m │ ├── datatreat.m │ └── CommonSample.m ├── Figure │ ├── PlotSwatheOption.m │ ├── FigFont.m │ ├── NumTotFigures.m │ ├── BarPlot.m │ ├── LegOption.m │ ├── AreaPlot.m │ ├── SaveFigure.m │ ├── cmap.m │ ├── FigSize.m │ ├── PlotLineOption.m │ ├── Date2Cell.m │ └── Date2Num.m └── Stats │ ├── censor.m │ ├── MovCorr.m │ ├── MovCorrCent.m │ ├── MovAvgCent.m │ ├── MovAvg.m │ ├── MovStd.m │ ├── MovSum.m │ ├── CorrTable.m │ └── CorrTableUnbalanced.m ├── VAR_Primer_Slides.pdf └── .gitignore /OldVersions/v2dot0/ExportFig/.ignore/ghostscript.txt: -------------------------------------------------------------------------------- 1 | /usr/local/bin/gs -------------------------------------------------------------------------------- /OldVersions/v2dot0/ExportFig/.ignore/gs_font_path.txt: -------------------------------------------------------------------------------- 1 | C:\Windows\Fonts -------------------------------------------------------------------------------- /v3dot0/ExportFig/.gitignore: -------------------------------------------------------------------------------- 1 | /.ignore 2 | .DS_store 3 | *.txt 4 | *.asv 5 | *~ 6 | *.mex* 7 | -------------------------------------------------------------------------------- /v3dot0/VAR/VARlag.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/VAR/VARlag.m -------------------------------------------------------------------------------- /VAR_Primer_Slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/VAR_Primer_Slides.pdf -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanmax.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nanmax.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanmean.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nanmean.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanmin.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nanmin.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nansem.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nansem.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanstd.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nanstd.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nansum.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nansum.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanvar.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nanvar.m -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanmedian.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Auxiliary/nanmedian.m -------------------------------------------------------------------------------- /v3dot0/ExportFig/print2eps.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/ExportFig/print2eps.m -------------------------------------------------------------------------------- /v3dot0/Replic/BQ1989/IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/BQ1989/IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/BQ1989/IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/BQ1989/IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/SW2001/IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/SW2001/IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/SW2001/IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/SW2001/IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/SW2001/IR_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/SW2001/IR_3.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/SW2001/VD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/SW2001/VD.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/iv_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/iv_.pdf -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/LICENSE.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/BQ_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/BQ_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/BQ_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/BQ_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/BQ_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/BQ_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/GK_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/GK_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/GK_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/GK_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/GK_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/GK_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/GK_IR_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/GK_IR_3.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/GK_IR_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/GK_IR_4.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_HD_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_HD_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_HD_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_HD_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_HD_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_HD_3.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_IR_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_IR_3.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/SW_VD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/SW_VD.pdf -------------------------------------------------------------------------------- /v3dot0/ExportFig/ImageSelection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/ExportFig/ImageSelection.java -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/.gitignore.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/README.md.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/iv_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/iv_.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/data/BQ1989_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/BQ1989_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/data/CS2020_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/CS2020_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/data/GK2015_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/GK2015_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/data/SW2001_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/SW2001_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/data/Simple_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/Simple_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/BIV_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/BIV_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/longCum_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/longCum_.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/signAll_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/signAll_.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/sign_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/sign_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/sign_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/sign_IR_2.pdf -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanmax.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nanmax.m -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanmean.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nanmean.m -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanmin.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nanmin.m -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nansem.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nansem.m -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanstd.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nanstd.m -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nansum.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nansum.m -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanvar.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nanvar.m -------------------------------------------------------------------------------- /v3dot0/ExportFig/ImageSelection.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/ExportFig/ImageSelection.class -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/ProjectData.type.Info.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/uuid-cc21a9b0-026d-4b70-9821-3eb23d2abf81.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/BQ_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/BQ_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/BQ_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/BQ_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/BQ_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/BQ_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/GK_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/GK_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/GK_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/GK_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/GK_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/GK_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/GK_IR_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/GK_IR_3.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/GK_IR_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/GK_IR_4.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_HD_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_HD_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_HD_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_HD_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_HD_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_HD_3.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_IR_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_IR_3.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/SW_VD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/SW_VD.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/data/Simple_Data_2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/Simple_Data_2.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/data/Uhlig2005_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/data/Uhlig2005_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/GK_alt_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/GK_alt_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/Uhlig_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/Uhlig_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/iv_sign_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/iv_sign_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/iv_sign_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/iv_sign_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/BQ1989/BQ1989_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/BQ1989/BQ1989_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Replic/BQ1989/BQ1989_Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/BQ1989/BQ1989_Paper.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/BQ1989/BQ_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/BQ1989/BQ_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/GK2015/GK2015_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/GK2015/GK2015_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Replic/GK2015/GK2015_Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/GK2015/GK2015_Paper.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/GK2015/GK_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/GK2015/GK_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/SW2001/SW2001_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/SW2001/SW2001_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Replic/SW2001/SW2001_Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/SW2001/SW2001_Paper.pdf -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanmedian.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/OldVersions/v2dot0/Auxiliary/nanmedian.m -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/ImageSelection.class.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/ImageSelection.java.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/Primer/.gitignore: -------------------------------------------------------------------------------- 1 | *.tex 2 | *.nav 3 | *.bib 4 | *.out 5 | *.snm 6 | *.gz 7 | *.toc 8 | *.vrb 9 | *.aux 10 | *.log 11 | -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/BQ1989_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/BQ1989_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/CS2020_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/CS2020_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/GK2015_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/GK2015_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/SW2001_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/SW2001_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/Simple_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/Simple_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/BIV_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/BIV_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/longCum_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/longCum_.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/signAll_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/signAll_.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/sign_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/sign_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/sign_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/sign_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/BQ_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/BQ_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/Simple_Data_2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/Simple_Data_2.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/data/Uhlig2005_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/data/Uhlig2005_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/GK_alt_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/GK_alt_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/Uhlig_DATA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/Uhlig_DATA.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/iv_sign_IR_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/iv_sign_IR_1.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/iv_sign_IR_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/iv_sign_IR_2.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/Uhlig_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/Uhlig_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/Uhlig2005/Uhlig2005_Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/Uhlig2005/Uhlig2005_Data.xlsx -------------------------------------------------------------------------------- /v3dot0/Replic/Uhlig2005/Uhlig2005_Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/Uhlig2005/Uhlig2005_Paper.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/BQ_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/BQ_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Replic/Uhlig2005/Uhligh_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Replic/Uhlig2005/Uhligh_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/Uhlig_Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/Uhlig_Replication.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/Uhlig_Replication_1rot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/Uhlig_Replication_1rot.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/Uhlig_Replication_2rot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/Uhlig_Replication_2rot.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/graphics/Uhlig_Replication_500rot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/graphics/Uhlig_Replication_500rot.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/Uhlig_Replication_1rot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/Uhlig_Replication_1rot.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/Uhlig_Replication_2rot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/Uhlig_Replication_2rot.pdf -------------------------------------------------------------------------------- /v3dot0/Primer/_old/graphics/Uhlig_Replication_500rot.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambropo/VAR-Toolbox/HEAD/v3dot0/Primer/_old/graphics/Uhlig_Replication_500rot.pdf -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.ProjectPath/a533e478-c90b-4a1f-a45b-f8877af57bee.type.Reference.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/none.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/other.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/test.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/derived.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/design.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/artifact.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category/convenience.type.Label.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Categories/FileClassCategory.type.Category.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/Export_fig.prj: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/copyfig.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/eps2pdf.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/export_fig.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/fix_lines.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/im2gif.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/pdf2eps.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/pdftops.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/print2eps.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/using_hg2.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/append_pdfs.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/crop_borders.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/ghostscript.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/isolate_axes.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/print2array.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/user_string.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Root.type.Files/read_write_entire_textfile.m.type.File.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sty 3 | *.tex 4 | *.nav 5 | *.bib 6 | *.out 7 | *.snm 8 | *.gz 9 | *.toc 10 | *.vrb 11 | *.aux 12 | *.log 13 | *.bbl 14 | *.blg 15 | wink.png 16 | *temp.pdf 17 | beamer* 18 | aux/* 19 | v3dot0/_bin/* 20 | v3dot0/fromDynare/* 21 | v3dot1/* 22 | v3dot2/* 23 | v3dot3/* 24 | 25 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/nanmovavg.m: -------------------------------------------------------------------------------- 1 | function y=nanmovavg(x,n) 2 | 3 | aux_x=x; 4 | [aux_NumObs aux_NumVar]=size(x); 5 | window=n; 6 | 7 | for j=1:aux_NumVar 8 | for i=1:window-1 9 | y(i,j)=NaN; 10 | end 11 | for i=window:aux_NumObs 12 | y(i,j)=mean(y(i-window+1:i,j)); 13 | end 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/nanmovavg.m: -------------------------------------------------------------------------------- 1 | function y=nanmovavg(x,n) 2 | 3 | aux_x=x; 4 | [aux_NumObs aux_NumVar]=size(x); 5 | window=n; 6 | 7 | for j=1:aux_NumVar 8 | for i=1:window-1 9 | y(i,j)=NaN; 10 | end 11 | for i=window:aux_NumObs 12 | y(i,j)=mean(y(i-window+1:i,j)); 13 | end 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/README.txt: -------------------------------------------------------------------------------- 1 | These codes are for explanatory purposes and may contain bugs or errors. 2 | 3 | If you find any bugs or want to give me comments and suggestions you can email me at: 4 | ambrogio.cesabianchi@gmail.com 5 | 6 | If you happen to use these codes for research papers can you please quote as follows: 7 | Ambrogio Cesa-Bianchi, 2015. "VAR Toolbox", sites.google.com/site/ambropo/". -------------------------------------------------------------------------------- /v3dot0/ExportFig/resources/project/Extensions.type.Root/DependencyAnalysis.type.Extension/ExternalFiles.type.Extension.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/vec.m: -------------------------------------------------------------------------------- 1 | function out = vec(X) 2 | % ======================================================================= 3 | % Vectorize the matrix X 4 | % ======================================================================= 5 | % out = vec(X) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - X: [r x c] matrix 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - out: [r*c x 1] matrix 12 | % ======================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogio.cesabianchi@gmail.com 15 | 16 | [r,c] = size(X); 17 | out = reshape(X,r*c,1); -------------------------------------------------------------------------------- /v3dot0/Auxiliary/clearex.m: -------------------------------------------------------------------------------- 1 | function clearex(varargin) 2 | %% This function clear all workspace 3 | % except for one or more selected variable 4 | % 5 | % File created on Feb 15th 2008 6 | % 7 | % Last modified: Feb 15th 2008 8 | % 9 | % Author: Arnaud Laurent 10 | % 11 | % Inputs: name of variables to keep (e.g. 'a','b','c') 12 | % Note: It is possible to use wildcard (e.g. 'a*') 13 | 14 | a = evalin('base','who'); 15 | var = cell(size(varargin)); 16 | for i=1:nargin 17 | var{i}=varargin{i}; 18 | end 19 | assignin('base','ClEaRGsJioU',var); 20 | var = evalin('base','who(ClEaRGsJioU{:})'); 21 | clearvar = a(~ismember(a,var)); 22 | assignin('base','ClEaRGsJioU',clearvar); 23 | evalin('base','clear(ClEaRGsJioU{:},''ClEaRGsJioU'')') 24 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/clearex.m: -------------------------------------------------------------------------------- 1 | function clearex(varargin) 2 | %% This function clear all workspace 3 | % except for one or more selected variable 4 | % 5 | % File created on Feb 15th 2008 6 | % 7 | % Last modified: Feb 15th 2008 8 | % 9 | % Author: Arnaud Laurent 10 | % 11 | % Inputs: name of variables to keep (e.g. 'a','b','c') 12 | % Note: It is possible to use wildcard (e.g. 'a*') 13 | 14 | a = evalin('base','who'); 15 | var = cell(size(varargin)); 16 | for i=1:nargin 17 | var{i}=varargin{i}; 18 | end 19 | assignin('base','ClEaRGsJioU',var); 20 | var = evalin('base','who(ClEaRGsJioU{:})'); 21 | clearvar = a(~ismember(a,var)); 22 | assignin('base','ClEaRGsJioU',clearvar); 23 | evalin('base','clear(ClEaRGsJioU{:},''ClEaRGsJioU'')') 24 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/rows.m: -------------------------------------------------------------------------------- 1 | function r = rows(DATA) 2 | % ======================================================================= 3 | % Returns number of rows in a matrix 4 | % ======================================================================= 5 | % r = rows(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: input matrix (nobs X nvars) 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - r: number of rows in DATA 12 | % ========================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogiocesabianchi@gmail.com 15 | %------------------------------------------------------------------------- 16 | 17 | [r,~] = size(DATA); 18 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/cols.m: -------------------------------------------------------------------------------- 1 | function c = cols(DATA) 2 | % ======================================================================= 3 | % Returns number of columns in a matrix 4 | % ======================================================================= 5 | % c = cols(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: input matrix (nobs X nvars) 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - r: number of columns in DATA 12 | % ========================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogiocesabianchi@gmail.com 15 | %------------------------------------------------------------------------- 16 | 17 | [~,c] = size(DATA); 18 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/seqa.m: -------------------------------------------------------------------------------- 1 | function seq=seqa(a,b,c); 2 | % PURPOSE: produce a sequence of values 3 | % ----------------------------------------------------- 4 | % USAGE: y = seqa(a,b,c) 5 | % where a = initial value in sequence 6 | % b = increment 7 | % c = number of values in the sequence 8 | % ----------------------------------------------------- 9 | % RETURNS: a sequence, (a:b:(a+b*(c-1)))' in MATLAB notation 10 | % ----------------------------------------------------- 11 | % NOTE: a Gauss compatability function 12 | % ----------------------------------------------------- 13 | 14 | % written by: 15 | % James P. LeSage, Dept of Economics 16 | % University of Toledo 17 | % 2801 W. Bancroft St, 18 | % Toledo, OH 43606 19 | % jpl@jpl.econ.utoledo.edu 20 | 21 | % seqa Gauss eqivalent of seqa(a,b,c) 22 | seq=(a:b:(a+b*(c-1)))'; 23 | return; 24 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/BarPlot.m: -------------------------------------------------------------------------------- 1 | function H = BarPlot(X) 2 | % ======================================================================= 3 | % Creates a bar graph with positive data values stacked on the positive 4 | % quadrant and negative data values stacked on the negative quadrant 5 | % ======================================================================= 6 | % H = BarPlot(X) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - X: data to plot [nobs x nvars] 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - H: handle to graph 13 | % ======================================================================= 14 | % Ambrogio Cesa Bianchi, March 2015 15 | % ambrogio.cesabianchi@gmail.com 16 | 17 | H(1,:) = bar((X).*(X>0),'stacked'); 18 | hold on; 19 | H(2,:) = bar((X).*(X<0),'stacked'); 20 | -------------------------------------------------------------------------------- /v3dot0/Utils/getqr.m: -------------------------------------------------------------------------------- 1 | function out = getqr(a) 2 | % ======================================================================= 3 | % QR factorization of a matrix a. 4 | % ======================================================================= 5 | % out = getqr(a) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - a: Matrix to factorize 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - out: factorized matrix such that out*out'=I 12 | % ======================================================================= 13 | % VAR Toolbox 3.0 14 | % Ambrogio Cesa-Bianchi 15 | % ambrogiocesabianchi@gmail.com 16 | % December 2021 17 | % ----------------------------------------------------------------------- 18 | 19 | [q,r]=qr(a); 20 | for i=1:size(q,1) 21 | if r(i,i)<0 22 | q(:,i)=-q(:,i); 23 | end 24 | end 25 | out=q; 26 | end -------------------------------------------------------------------------------- /v3dot0/Auxiliary/trimr.m: -------------------------------------------------------------------------------- 1 | function z = trimr(x,n1,n2) 2 | % PURPOSE: return a matrix (or vector) x stripped of the specified rows. 3 | % ----------------------------------------------------- 4 | % USAGE: z = trimr(x,n1,n2) 5 | % where: x = input matrix (or vector) (n x k) 6 | % n1 = first n1 rows to strip 7 | % n2 = last n2 rows to strip 8 | % NOTE: modeled after Gauss trimr function 9 | % ----------------------------------------------------- 10 | % RETURNS: z = x(n1+1:n-n2,:) 11 | % ----------------------------------------------------- 12 | 13 | % written by: 14 | % James P. LeSage, Dept of Economics 15 | % University of Toledo 16 | % 2801 W. Bancroft St, 17 | % Toledo, OH 43606 18 | % jpl@jpl.econ.utoledo.edu 19 | 20 | [n junk] = size(x); 21 | if (n1+n2) >= n; 22 | error('Attempting to trim too much in trimr'); 23 | end; 24 | h1 = n1+1; 25 | h2 = n-n2; 26 | z = x(h1:h2,:); 27 | 28 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/trimr.m: -------------------------------------------------------------------------------- 1 | function z = trimr(x,n1,n2) 2 | % PURPOSE: return a matrix (or vector) x stripped of the specified rows. 3 | % ----------------------------------------------------- 4 | % USAGE: z = trimr(x,n1,n2) 5 | % where: x = input matrix (or vector) (n x k) 6 | % n1 = first n1 rows to strip 7 | % n2 = last n2 rows to strip 8 | % NOTE: modeled after Gauss trimr function 9 | % ----------------------------------------------------- 10 | % RETURNS: z = x(n1+1:n-n2,:) 11 | % ----------------------------------------------------- 12 | 13 | % written by: 14 | % James P. LeSage, Dept of Economics 15 | % University of Toledo 16 | % 2801 W. Bancroft St, 17 | % Toledo, OH 43606 18 | % jpl@jpl.econ.utoledo.edu 19 | 20 | [n junk] = size(x); 21 | if (n1+n2) >= n; 22 | error('Attempting to trim too much in trimr'); 23 | end; 24 | h1 = n1+1; 25 | h2 = n-n2; 26 | z = x(h1:h2,:); 27 | 28 | -------------------------------------------------------------------------------- /v3dot0/Utils/rows.m: -------------------------------------------------------------------------------- 1 | function r = rows(DATA) 2 | % ======================================================================= 3 | % Returns number of rows in a matrix 4 | % ======================================================================= 5 | % r = rows(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: input matrix (nobs X nvars) 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - r: number of rows in DATA 12 | % ----------------------------------------------------------------------- 13 | % EXAMPLE 14 | % x = rand(20,1); 15 | % OUT = raws(x) 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | [r,~] = size(DATA); 24 | -------------------------------------------------------------------------------- /v3dot0/Utils/cols.m: -------------------------------------------------------------------------------- 1 | function c = cols(DATA) 2 | % ======================================================================= 3 | % Returns number of columns in a matrix 4 | % ======================================================================= 5 | % c = cols(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: input matrix (nobs X nvars) 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - r: number of columns in DATA 12 | % ----------------------------------------------------------------------- 13 | % EXAMPLE 14 | % x = rand(20,1); 15 | % OUT = cols(x) 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | [~,c] = size(DATA); 24 | -------------------------------------------------------------------------------- /v3dot0/Utils/columns.m: -------------------------------------------------------------------------------- 1 | function c = cols(DATA) 2 | % ======================================================================= 3 | % Returns number of columns in a matrix 4 | % ======================================================================= 5 | % c = cols(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: input matrix (nobs X nvars) 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - r: number of columns in DATA 12 | % ----------------------------------------------------------------------- 13 | % EXAMPLE 14 | % x = rand(20,1); 15 | % OUT = cols(x) 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | [~,c] = size(DATA); 24 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/tdis_inv.m: -------------------------------------------------------------------------------- 1 | function x = tdis_inv (p, a) 2 | % PURPOSE: returns the inverse (quantile) at x of the t(n) distribution 3 | %--------------------------------------------------- 4 | % USAGE: x = tdis_inv(p,n) 5 | % where: p = a vector of probabilities 6 | % n = a scalar dof parameter 7 | %--------------------------------------------------- 8 | % RETURNS: 9 | % a vector of tinv at each element of x of the t(n) distribution 10 | % -------------------------------------------------- 11 | % SEE ALSO: tdis_cdf, tdis_rnd, tdis_pdf, tdis_prb 12 | %--------------------------------------------------- 13 | 14 | % Anders Holtsberg, 18-11-93 15 | % Copyright (c) Anders Holtsberg 16 | 17 | 18 | if (nargin ~= 2) 19 | error ('Wrong # of arguments to tdis_inv'); 20 | end 21 | 22 | s = p<0.5; 23 | p = p + (1-2*p).*s; 24 | p = 1-(2*(1-p)); 25 | x = beta_inv(p,1/2,a/2); 26 | x = x.*a./((1-x)); 27 | x = (1-2*s).*sqrt(x); 28 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/tdis_inv.m: -------------------------------------------------------------------------------- 1 | function x = tdis_inv (p, a) 2 | % PURPOSE: returns the inverse (quantile) at x of the t(n) distribution 3 | %--------------------------------------------------- 4 | % USAGE: x = tdis_inv(p,n) 5 | % where: p = a vector of probabilities 6 | % n = a scalar dof parameter 7 | %--------------------------------------------------- 8 | % RETURNS: 9 | % a vector of tinv at each element of x of the t(n) distribution 10 | % -------------------------------------------------- 11 | % SEE ALSO: tdis_cdf, tdis_rnd, tdis_pdf, tdis_prb 12 | %--------------------------------------------------- 13 | 14 | % Anders Holtsberg, 18-11-93 15 | % Copyright (c) Anders Holtsberg 16 | 17 | 18 | if (nargin ~= 2) 19 | error ('Wrong # of arguments to tdis_inv'); 20 | end 21 | 22 | s = p<0.5; 23 | p = p + (1-2*p).*s; 24 | p = 1-(2*(1-p)); 25 | x = beta_inv(p,1/2,a/2); 26 | x = x.*a./((1-x)); 27 | x = (1-2*s).*sqrt(x); 28 | -------------------------------------------------------------------------------- /v3dot0/Utils/NoSpace.m: -------------------------------------------------------------------------------- 1 | function out = NoSpace(str) 2 | % ======================================================================= 3 | % Removes spaces from a string 4 | % ======================================================================= 5 | % out = NoSpace(str) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - str : string 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - out : string with no spaces 12 | % ----------------------------------------------------------------------- 13 | % EXAMPLE 14 | % x = 'this is a string with spaces'; 15 | % out = NoSpace(x) 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | out = str(~isspace(str)); -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/LegOption.m: -------------------------------------------------------------------------------- 1 | function opt = LegOption 2 | % ======================================================================= 3 | % Optional inputs for SubLegendOption 4 | % ======================================================================= 5 | % - opt.hsize = default 0.01, horizontal size of the box of the 6 | % legend 7 | % - opt.vsize = default 0.01, vertical position of the box of 8 | % the legend (0=bottom, 0.5=middle) 9 | % - opt.handle = default [], no handle specified 10 | % - opt.interpreter = default 'Tex', 11 | % - opt.direction = default 0, horizontal legend 12 | % ========================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogio.cesabianchi@gmail.com 15 | 16 | opt.hsize = 0.01; 17 | opt.vsize = 0.01; 18 | opt.handle = []; 19 | opt.interpreter = 'Tex'; 20 | opt.direction = 1; -------------------------------------------------------------------------------- /v3dot0/VAR/OrthNorm.m: -------------------------------------------------------------------------------- 1 | function out = OrthNorm(n) 2 | % ======================================================================= 3 | % Compute a [n x n] random orthonormal matrix 4 | % ======================================================================= 5 | % out = OrthNorm(n) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - n: size of the matrix 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - out: [n x n] random orthonormal matrix 12 | % ======================================================================= 13 | % VAR Toolbox 3.0 14 | % Ambrogio Cesa-Bianchi 15 | % ambrogiocesabianchi@gmail.com 16 | % March 2012. Updated Febraury 2021 17 | % ----------------------------------------------------------------------- 18 | 19 | a = randn(n); 20 | [q,r]=qr(a); 21 | for i=1:size(q,1) 22 | if r(i,i)<0 23 | q(:,i)=-q(:,i); 24 | end 25 | end 26 | out=q; 27 | end 28 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/NaN2Num.m: -------------------------------------------------------------------------------- 1 | function OUT = NaN2Num(DATA) 2 | % ======================================================================= 3 | % Substitute NaN values with 123456789 4 | % ======================================================================= 5 | % OUT = Num2NaN(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUTS 8 | % - DATA: a (m x n) matrix with NaNs 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - OUT: a (m x n) matrix with 123456789 instead of NaNs 12 | % ========================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogiocesabianchi@gmail.com 15 | %------------------------------------------------------------------------- 16 | 17 | OUT=DATA; 18 | for i=1:size(DATA,1) 19 | for j=1:size(DATA,2) 20 | if isnan(DATA(i,j)) == 1 21 | OUT(i,j) = 123456789; 22 | end 23 | end 24 | end 25 | 26 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/Num2NaN.m: -------------------------------------------------------------------------------- 1 | function OUT = Num2NaN(DATA) 2 | % ======================================================================= 3 | % Substitute 123456789 values with NaN 4 | % ======================================================================= 5 | % OUT = Num2NaN(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: a (m x n) matrix with some 123456789 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - OUT: a (m x n) matrix with NaN in place of 123456789 12 | % ========================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogiocesabianchi@gmail.com 15 | %------------------------------------------------------------------------- 16 | 17 | OUT=DATA; 18 | for i=1:size(DATA,1) 19 | for j=1:size(DATA,2) 20 | if DATA(i,j) == 123456789 21 | OUT(i,j) = NaN; 22 | end 23 | end 24 | end 25 | 26 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/SaveFigure.m: -------------------------------------------------------------------------------- 1 | function SaveFigure(path,quality) 2 | % ======================================================================= 3 | % Saves figure to specified path 4 | % ======================================================================= 5 | % SaveFig(path,quality) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - path: path wehere to save the file 9 | % ----------------------------------------------------------------------- 10 | % OPTIONAL INPUT 11 | % - quality: 0 standard, 1 high quality [dflt=0] 12 | % ======================================================================= 13 | % Ambrogio Cesa Bianchi, April 2015 14 | % ambrogio.cesabianchi@gmail.com 15 | 16 | if ~exist('quality','var') 17 | quality=0; 18 | end 19 | 20 | if quality 21 | set(gcf, 'Color', 'w'); 22 | export_fig(path,'-pdf','-png','-painters') 23 | else 24 | print('-dpng','-r100',path) 25 | print('-deps','-r100',path) 26 | print('-dpdf','-r100',path) 27 | end -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/OrthNorm.m: -------------------------------------------------------------------------------- 1 | function out = OrthNorm(n) 2 | % ======================================================================= 3 | % Compute a [n x n] random orthonormal matrix 4 | % ======================================================================= 5 | % out = OrthNorm(n) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - n: size of the matrix 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - out: [n x n] random orthonormal matrix 12 | % ======================================================================= 13 | % Ambrogio Cesa Bianchi, March 2015 14 | % ambrogio.cesabianchi@gmail.com 15 | 16 | % [n x n] matrix of N(0,1) random variables 17 | X = randn(n,n); 18 | 19 | % QR decomposition of X 20 | [Q, ~] = qr(X); 21 | 22 | % Check precision 23 | if sum(sum(Q*Q'))> n + 1.0e-5 24 | error('Q*transpose(Q) is not equal to identity') 25 | end 26 | 27 | % Random orthonormal matrix such that Q*Q'=I 28 | out = Q; -------------------------------------------------------------------------------- /v3dot0/Figure/PlotSwatheOption.m: -------------------------------------------------------------------------------- 1 | function SwatheOpt = PlotSwatheOption 2 | % ======================================================================= 3 | % Optional inputs for PlotSwathe 4 | % ======================================================================= 5 | % SwatheOpt = PlotSwatheOption 6 | % ======================================================================= 7 | % VAR Toolbox 3.0 8 | % Ambrogio Cesa-Bianchi 9 | % ambrogiocesabianchi@gmail.com 10 | % March 2015. Updated November 2020 11 | % ----------------------------------------------------------------------- 12 | 13 | %% INITIALIZE VARIABLES 14 | %color = bone(8); 15 | SwatheOpt.swathecol = [138, 178, 212]./255; % color(6,:); 16 | SwatheOpt.linecol = [13, 54, 84]./255; % color(1,:); 17 | SwatheOpt.do_dates = 0; 18 | SwatheOpt.frequency = 'q'; 19 | SwatheOpt.swatheonly = 0; 20 | SwatheOpt.linewidth = 2; 21 | SwatheOpt.marker = 'none'; 22 | SwatheOpt.transp = 0; % Allow for transparency when plotting multiple swathes 23 | SwatheOpt.alpha = 1; % Sets alpha for transparent swathes. Default is 1 24 | 25 | -------------------------------------------------------------------------------- /v3dot0/Figure/FigFont.m: -------------------------------------------------------------------------------- 1 | function FigFont(fsize) 2 | % ======================================================================= 3 | % Set font in a figure to desired font size 4 | % ======================================================================= 5 | % FigFont(fsize) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - fsize : size of font (double) 9 | % ----------------------------------------------------------------------- 10 | % EXAMPLE 11 | % plot(1:10); title('A line plot') 12 | % FigFont(16) 13 | % ======================================================================= 14 | % VAR Toolbox 3.0 15 | % Ambrogio Cesa-Bianchi 16 | % ambrogiocesabianchi@gmail.com 17 | % March 2015. Updated November 2020 18 | % ----------------------------------------------------------------------- 19 | 20 | 21 | 22 | %% CHECK INPUT 23 | if ~exist('fsize','var') 24 | error('Please enter a font size'); 25 | end 26 | 27 | 28 | %% SET FONT STYLE 29 | % AXES 30 | aux = findobj(gcf,'Type','axes'); 31 | set(aux,'Fontsize',fsize,'FontWeight','Light','FontName','Helvetica'); 32 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/read_write_entire_textfile.m: -------------------------------------------------------------------------------- 1 | %READ_WRITE_ENTIRE_TEXTFILE Read or write a whole text file to/from memory 2 | % 3 | % Read or write an entire text file to/from memory, without leaving the 4 | % file open if an error occurs. 5 | % 6 | % Reading: 7 | % fstrm = read_write_entire_textfile(fname) 8 | % Writing: 9 | % read_write_entire_textfile(fname, fstrm) 10 | % 11 | %IN: 12 | % fname - Pathname of text file to be read in. 13 | % fstrm - String to be written to the file, including carriage returns. 14 | % 15 | %OUT: 16 | % fstrm - String read from the file. If an fstrm input is given the 17 | % output is the same as that input. 18 | 19 | function fstrm = read_write_entire_textfile(fname, fstrm) 20 | modes = {'rt', 'wt'}; 21 | writing = nargin > 1; 22 | fh = fopen(fname, modes{1+writing}); 23 | if fh == -1 24 | error('Unable to open file %s.', fname); 25 | end 26 | try 27 | if writing 28 | fwrite(fh, fstrm, 'char*1'); 29 | else 30 | fstrm = fread(fh, '*char')'; 31 | end 32 | catch ex 33 | fclose(fh); 34 | rethrow(ex); 35 | end 36 | fclose(fh); 37 | end 38 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/NumTotFigures.m: -------------------------------------------------------------------------------- 1 | function nfigures = NumTotFigures(row,col,nvar) 2 | % ======================================================================= 3 | % Determine the number of figures for a given number of subplots, rows and 4 | % columns 5 | % ======================================================================= 6 | % nfigures = NumTotFigures(row,col,nvar) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - row: number of rows of the subplot 10 | % - col: number of columns of the subplot 11 | % - nvar: number of variables 12 | % ----------------------------------------------------------------------- 13 | % OUTPUT 14 | % - nfigures: number of charts per subplot 15 | % ========================================================================= 16 | % Ambrogio Cesa Bianchi, March 2015 17 | % ambrogio.cesabianchi@gmail.com 18 | 19 | NumGraphXPage = row*col; 20 | 21 | p = floor(nvar./NumGraphXPage); 22 | q = (nvar./NumGraphXPage); 23 | 24 | if NumGraphXPage>=nvar 25 | nfigures=1; 26 | elseif p==q 27 | nfigures=p; 28 | else 29 | nfigures=p+1; 30 | end 31 | clear p q -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/Date2Num.m: -------------------------------------------------------------------------------- 1 | function OUT = Date2Num(DATA) 2 | % ======================================================================= 3 | % Substitute cell dates 1989Q4 with numeric dates 1989.75. Only for 4 | % quarterly data. 5 | % ======================================================================= 6 | % OUT = Date2Num(DATA) 7 | % ----------------------------------------------------------------------- 8 | % INPUTS 9 | % - DATA: a (T x 1) vector with dates in cell format 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - OUT: a (T x 1) vector with dates in numeric format 13 | % ========================================================================= 14 | % Ambrogio Cesa Bianchi, March 2015 15 | % ambrogiocesabianchi@gmail.com 16 | %------------------------------------------------------------------------- 17 | 18 | OUT = nan(size(DATA,1),size(DATA,2)); 19 | for i=1:size(DATA,1) 20 | for j=1:size(DATA,2) 21 | aux = DATA{i,j}; 22 | year = str2double(aux(1:4)); 23 | quarter = str2double(aux(6)); 24 | OUT(i,j) = year + quarter/4 -0.25; 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/VARmakelags.m: -------------------------------------------------------------------------------- 1 | function OUT = VARmakelags(DATA,lag) 2 | % ======================================================================= 3 | % Builds a matrix with lagged values of DATA, i.e. if DATA = [x1 x2], 4 | % VARmakelags(DATA,1) yields OUT = [x1 x2 x1(-1) x2(-1)] 5 | % ======================================================================= 6 | % OUT = VARmakelags(DATA,lag) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA: matrix containing the original data 10 | % - lag: lag order 11 | % ----------------------------------------------------------------------- 12 | % OUTPUT 13 | % OUT: matrix of lagged values 14 | % ======================================================================= 15 | % Ambrogio Cesa Bianchi, March 2015 16 | % ambrogio.cesabianchi@gmail.com 17 | 18 | % Get dimesion of DATA 19 | [nobs, ~]= size(DATA); 20 | 21 | % Create the lagged matrix 22 | OUT = []; 23 | for jj=0:lag-1 24 | OUT = [DATA(jj+1:nobs-lag+jj,:), OUT]; 25 | end 26 | 27 | % Finally, save the non-lagged values... 28 | aux = DATA(lag+1:end,:); 29 | 30 | %... and append to the lagged matrix 31 | OUT = [aux OUT]; -------------------------------------------------------------------------------- /v3dot0/Auxiliary/tdis_prb.m: -------------------------------------------------------------------------------- 1 | function y = tdis_prb(x,n) 2 | % PURPOSE: calculates t-probabilities for elements in x-vector 3 | %--------------------------------------------------- 4 | % USAGE: y = tdis_prb(x,n) 5 | % where: x = vector containing computed t-values 6 | % n = degrees of freedom parameter 7 | %--------------------------------------------------- 8 | % RETURNS: 9 | % y = a vector of marginal probability levels 10 | % -------------------------------------------------- 11 | % SEE ALSO: fdis_prb(), chis_prb 12 | %--------------------------------------------------- 13 | 14 | % written by: 15 | % James P. LeSage, Dept of Economics 16 | % University of Toledo 17 | % 2801 W. Bancroft St, 18 | % Toledo, OH 43606 19 | % jpl@jpl.econ.utoledo.edu 20 | 21 | 22 | if nargin ~= 2; error('Wrong # of arguments to tdis_prb'); end; 23 | if n <=0; error('dof is negative or zero in tdis_prb'); end; 24 | 25 | x2 = n./(n+x.^2); 26 | one = find(x2 >= 1); 27 | if length(one) > 0 28 | x2(one,1) = 1-1e-12; 29 | end; 30 | zip = find(x2 <= 0); 31 | if length(zip) > 0 32 | x2(zip,1) = 1e-12; 33 | end; 34 | 35 | tmp = 1.0 - 0.5*betainc(x2,0.5*n,0.5); 36 | y = 2*(1-tmp); 37 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/tdis_prb.m: -------------------------------------------------------------------------------- 1 | function y = tdis_prb(x,n) 2 | % PURPOSE: calculates t-probabilities for elements in x-vector 3 | %--------------------------------------------------- 4 | % USAGE: y = tdis_prb(x,n) 5 | % where: x = vector containing computed t-values 6 | % n = degrees of freedom parameter 7 | %--------------------------------------------------- 8 | % RETURNS: 9 | % y = a vector of marginal probability levels 10 | % -------------------------------------------------- 11 | % SEE ALSO: fdis_prb(), chis_prb 12 | %--------------------------------------------------- 13 | 14 | % written by: 15 | % James P. LeSage, Dept of Economics 16 | % University of Toledo 17 | % 2801 W. Bancroft St, 18 | % Toledo, OH 43606 19 | % jpl@jpl.econ.utoledo.edu 20 | 21 | 22 | if nargin ~= 2; error('Wrong # of arguments to tdis_prb'); end; 23 | if n <=0; error('dof is negative or zero in tdis_prb'); end; 24 | 25 | x2 = n./(n+x.^2); 26 | one = find(x2 >= 1); 27 | if length(one) > 0 28 | x2(one,1) = 1-1e-12; 29 | end; 30 | zip = find(x2 <= 0); 31 | if length(zip) > 0 32 | x2(zip,1) = 1e-12; 33 | end; 34 | 35 | tmp = 1.0 - 0.5*betainc(x2,0.5*n,0.5); 36 | y = 2*(1-tmp); 37 | -------------------------------------------------------------------------------- /v3dot0/Utils/NaN2Num.m: -------------------------------------------------------------------------------- 1 | function OUT = NaN2Num(DATA) 2 | % ======================================================================= 3 | % Substitute NaN values with 123456789 4 | % ======================================================================= 5 | % OUT = Num2NaN(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: a (m x n) matrix with NaNs 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - OUT: a (m x n) matrix with 123456789 instead of NaNs 12 | % ----------------------------------------------------------------------- 13 | % EXAMPLE 14 | % x = [NaN 2; NaN 4; 5 6; 7 8; 9 10]; 15 | % OUT = NaN2Num(x) 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | OUT=DATA; 24 | for i=1:size(DATA,1) 25 | for j=1:size(DATA,2) 26 | if isnan(DATA(i,j)) == 1 27 | OUT(i,j) = 123456789; 28 | end 29 | end 30 | end 31 | 32 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/ptrend.m: -------------------------------------------------------------------------------- 1 | function xmat = ptrend(p,nobs) 2 | % PURPOSE: produce an explanatory variables matrix 3 | % containing a polynomial time-trend 4 | % ---------------------------------------------------- 5 | % USAGE: xmat = ptrend(p,nobs); 6 | % where: p = order of the time-trend polynomial 7 | % p < 0, xmat = iota (nobs x 1) vector of ones 8 | % p = 1, xmat = time trend 9 | % p > 1, xmat = higher order polynomial in time 10 | % nobs = size of the matrix 11 | % ---------------------------------------------------- 12 | % RETURNS: xmat = matrix containing polynomial trend model data set 13 | % ---------------------------------------------------- 14 | 15 | % written by: 16 | % James P. LeSage, Dept of Economics 17 | % University of Toledo 18 | % 2801 W. Bancroft St, 19 | % Toledo, OH 43606 20 | % jlesage@spatia-econometrics.com 21 | 22 | 23 | u = ones(nobs,1) ; 24 | if p > 0 25 | timep = zeros(nobs,p) ; 26 | t = 1:nobs; 27 | t = (t')/nobs; 28 | m = 1 ; 29 | while (m <= p) 30 | timep(:,m) = t.^m ; 31 | m = m + 1 ; 32 | end; 33 | xmat = [u timep]; 34 | else, 35 | xmat = u ; 36 | end; 37 | -------------------------------------------------------------------------------- /v3dot0/Utils/Num2NaN.m: -------------------------------------------------------------------------------- 1 | function OUT = Num2NaN(DATA) 2 | % ======================================================================= 3 | % Substitute 123456789 values with NaN 4 | % ======================================================================= 5 | % OUT = Num2NaN(DATA) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA: a (m x n) matrix with some 123456789 9 | % ----------------------------------------------------------------------- 10 | % OUTPUT 11 | % - OUT: a (m x n) matrix with NaN in place of 123456789 12 | % ----------------------------------------------------------------------- 13 | % EXAMPLE 14 | % x = [123456789 2; 123456789 4; 5 6; 7 8; 9 10]; 15 | % OUT = Num2NaN(x) 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | OUT=DATA; 24 | for i=1:size(DATA,1) 25 | for j=1:size(DATA,2) 26 | if DATA(i,j) == 123456789 27 | OUT(i,j) = NaN; 28 | end 29 | end 30 | end 31 | 32 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/StarVariable.m: -------------------------------------------------------------------------------- 1 | function OUT = StarVariable(DATA) 2 | % Computes foreign variables as in the GVAR with equal weights 3 | % ======================================================================= 4 | % [OUT, wgts] = xstar(DATA) 5 | % ----------------------------------------------------------------------- 6 | % INPUTS 7 | % - DATA: an (T x N) matrix of time series 8 | %-------------------------------------------------------------------------- 9 | % OUTPUT 10 | % - OUT: (T x N) matrix of xstar time series 11 | % ======================================================================= 12 | % Ambrogio Cesa Bianchi, March 2015 13 | % ambrogio.cesabianchi@gmail.com 14 | 15 | 16 | [nobs, nvar] = size(DATA); 17 | OUT = nan(nobs, nvar); 18 | w = ones(1,nvar)./nvar; 19 | 20 | for ii=1:nvar 21 | % Create a logical vector to exclude variable ii 22 | select = ones(1,nvar); select(ii)=0; select = logical(select); 23 | % Remove variable ii from DATA 24 | data = DATA(:,select); 25 | % Remove weight/flow ii from w 26 | weights = w(select); 27 | % Compute xstar variable for cuntry ii 28 | OUT(:,ii) = CrossWeightAverage(data,weights); 29 | end 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/beta_pdf.m: -------------------------------------------------------------------------------- 1 | function pdf = beta_pdf(x, a, b) 2 | % PURPOSE: pdf of the beta(a,b) distribution 3 | %-------------------------------------------------------------- 4 | % USAGE: pdf = beta_pdf(x,a,b) 5 | % where: x = vector of components 6 | % a = beta distribution parameter, a = scalar 7 | % b = beta distribution parameter b = scalar 8 | % NOTE: mean[(beta(a,b)] = a/(a+b), variance = ab/((a+b)*(a+b)*(a+b+1)) 9 | %-------------------------------------------------------------- 10 | % RETURNS: pdf at each element of x of the beta(a,b) distribution 11 | %-------------------------------------------------------------- 12 | % SEE ALSO: beta_d, beta_pdf, beta_inv, beta_rnd 13 | %-------------------------------------------------------------- 14 | 15 | % Anders Holtsberg, 18-11-93 16 | % Copyright (c) Anders Holtsberg 17 | % documentation modified by LeSage to 18 | % match the format of the econometrics toolbox 19 | 20 | 21 | if (nargin ~=3) 22 | error('Wrong # of arguments to beta_pdf'); 23 | end 24 | 25 | if any(any((a<=0)|(b<=0))) 26 | error('Parameter a or b is nonpositive'); 27 | end 28 | 29 | I = find((x<0)|(x>1)); 30 | 31 | pdf = x.^(a-1) .* (1-x).^(b-1) ./ beta(a,b); 32 | pdf(I) = 0*I; 33 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/using_hg2.m: -------------------------------------------------------------------------------- 1 | %USING_HG2 Determine if the HG2 graphics engine is used 2 | % 3 | % tf = using_hg2(fig) 4 | % 5 | %IN: 6 | % fig - handle to the figure in question. 7 | % 8 | %OUT: 9 | % tf - boolean indicating whether the HG2 graphics engine is being used 10 | % (true) or not (false). 11 | 12 | % 19/06/2015 - Suppress warning in R2015b; cache result for improved performance 13 | % 06/06/2016 - Fixed issue #156 (bad return value in R2016b) 14 | 15 | function tf = using_hg2(fig) 16 | persistent tf_cached 17 | if isempty(tf_cached) 18 | try 19 | if nargin < 1, fig = figure('visible','off'); end 20 | oldWarn = warning('off','MATLAB:graphicsversion:GraphicsVersionRemoval'); 21 | try 22 | % This generates a [supressed] warning in R2015b: 23 | tf = ~graphicsversion(fig, 'handlegraphics'); 24 | catch 25 | tf = ~verLessThan('matlab','8.4'); % =R2014b 26 | end 27 | warning(oldWarn); 28 | catch 29 | tf = false; 30 | end 31 | if nargin < 1, delete(fig); end 32 | tf_cached = tf; 33 | else 34 | tf = tf_cached; 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /v3dot0/Figure/NumTotFigures.m: -------------------------------------------------------------------------------- 1 | function nfigures = NumTotFigures(row,col,nvar) 2 | % ======================================================================= 3 | % Determine the number of figures for a given number of subplots, rows 4 | % and columns 5 | % ======================================================================= 6 | % nfigures = NumTotFigures(row,col,nvar) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - row: number of rows of the subplot 10 | % - col: number of columns of the subplot 11 | % - nvar: number of variables 12 | % ----------------------------------------------------------------------- 13 | % OUTPUT 14 | % - nfigures: number of charts per subplot 15 | % ======================================================================= 16 | % VAR Toolbox 3.0 17 | % Ambrogio Cesa-Bianchi 18 | % ambrogiocesabianchi@gmail.com 19 | % March 2015. Updated November 2020 20 | % ----------------------------------------------------------------------- 21 | 22 | NumGraphXPage = row*col; 23 | 24 | p = floor(nvar./NumGraphXPage); 25 | q = (nvar./NumGraphXPage); 26 | 27 | if NumGraphXPage>=nvar 28 | nfigures=1; 29 | elseif p==q 30 | nfigures=p; 31 | else 32 | nfigures=p+1; 33 | end 34 | clear p q -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/beta_pdf.m: -------------------------------------------------------------------------------- 1 | function pdf = beta_pdf(x, a, b) 2 | % PURPOSE: pdf of the beta(a,b) distribution 3 | %-------------------------------------------------------------- 4 | % USAGE: pdf = beta_pdf(x,a,b) 5 | % where: x = vector of components 6 | % a = beta distribution parameter, a = scalar 7 | % b = beta distribution parameter b = scalar 8 | % NOTE: mean[(beta(a,b)] = a/(a+b), variance = ab/((a+b)*(a+b)*(a+b+1)) 9 | %-------------------------------------------------------------- 10 | % RETURNS: pdf at each element of x of the beta(a,b) distribution 11 | %-------------------------------------------------------------- 12 | % SEE ALSO: beta_d, beta_pdf, beta_inv, beta_rnd 13 | %-------------------------------------------------------------- 14 | 15 | % Anders Holtsberg, 18-11-93 16 | % Copyright (c) Anders Holtsberg 17 | % documentation modified by LeSage to 18 | % match the format of the econometrics toolbox 19 | 20 | 21 | if (nargin ~=3) 22 | error('Wrong # of arguments to beta_pdf'); 23 | end 24 | 25 | if any(any((a<=0)|(b<=0))) 26 | error('Parameter a or b is nonpositive'); 27 | end 28 | 29 | I = find((x<0)|(x>1)); 30 | 31 | pdf = x.^(a-1) .* (1-x).^(b-1) ./ beta(a,b); 32 | pdf(I) = 0*I; 33 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/fdis_prb.m: -------------------------------------------------------------------------------- 1 | function y = fdis_prb( x, m, n) 2 | % PURPOSE: computes f-distribution probabilities 3 | %--------------------------------------------------- 4 | % USAGE: y = fdis_prb(x,m,n) 5 | % INPUTS: x = calculated f-statistic 6 | % m = numerator dof 7 | % n = denominator dof 8 | %--------------------------------------------------- 9 | % RETURNS: 10 | % y = a marginal probability level 11 | % -------------------------------------------------- 12 | % SEE ALSO: fdis_d, tdis_prb(), chis_prb() 13 | %--------------------------------------------------- 14 | 15 | % written by: 16 | % James P. LeSage, Dept of Economics 17 | % University of Toledo 18 | % 2801 W. Bancroft St, 19 | % Toledo, OH 43606 20 | % jlesage@spatial-econometrics.com 21 | 22 | if nargin ~= 3 23 | error('Wrong # of arguments to fdis_prb'); 24 | end; 25 | 26 | [np junk] = size(x); 27 | y = zeros(np,1); 28 | 29 | for i=1:np; 30 | if (x(i) < 0 || m <= 0 || n <= 0) 31 | error('negative or zero dof in fdis_prb'); 32 | else 33 | %y(i,1) = betai(.5*n,.5*m,n/(n+m*x(i,1))); 34 | tst = n/(n+m*x(i,1)); 35 | if tst == 0 36 | tst = tst + 0.0001; 37 | elseif tst == 1 38 | tst = tst - 0.0001; 39 | end; 40 | y(i,1) = betainc(tst,.5*n,.5*m); 41 | end; 42 | end; -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/fdis_prb.m: -------------------------------------------------------------------------------- 1 | function y = fdis_prb( x, m, n) 2 | % PURPOSE: computes f-distribution probabilities 3 | %--------------------------------------------------- 4 | % USAGE: y = fdis_prb(x,m,n) 5 | % INPUTS: x = calculated f-statistic 6 | % m = numerator dof 7 | % n = denominator dof 8 | %--------------------------------------------------- 9 | % RETURNS: 10 | % y = a marginal probability level 11 | % -------------------------------------------------- 12 | % SEE ALSO: fdis_d, tdis_prb(), chis_prb() 13 | %--------------------------------------------------- 14 | 15 | % written by: 16 | % James P. LeSage, Dept of Economics 17 | % University of Toledo 18 | % 2801 W. Bancroft St, 19 | % Toledo, OH 43606 20 | % jlesage@spatial-econometrics.com 21 | 22 | if nargin ~= 3 23 | error('Wrong # of arguments to fdis_prb'); 24 | end; 25 | 26 | [np junk] = size(x); 27 | y = zeros(np,1); 28 | 29 | for i=1:np; 30 | if (x(i) < 0 || m <= 0 || n <= 0) 31 | error('negative or zero dof in fdis_prb'); 32 | else 33 | %y(i,1) = betai(.5*n,.5*m,n/(n+m*x(i,1))); 34 | tst = n/(n+m*x(i,1)); 35 | if tst == 0 36 | tst = tst + 0.0001; 37 | elseif tst == 1 38 | tst = tst - 0.0001; 39 | end; 40 | y(i,1) = betainc(tst,.5*n,.5*m); 41 | end; 42 | end; -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/cell2num.m: -------------------------------------------------------------------------------- 1 | function OUT = cell2num(datacell) 2 | % ======================================================================= 3 | % Convert a cell array (of numbers) into a double array. If the cell arrqay 4 | % does not include a number returns NaN 5 | % ======================================================================= 6 | % OUT = cell2num(datacell) 7 | % ----------------------------------------------------------------------- 8 | % INPUTS 9 | % - datacell: a (m x n) cell array with numbers 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - OUT: a (m x n) matrix with numbers 13 | % ========================================================================= 14 | % Ambrogio Cesa Bianchi, March 2015 15 | % ambrogiocesabianchi@gmail.com 16 | %------------------------------------------------------------------------- 17 | 18 | if ~iscell(datacell) 19 | error('Input has to be a cell array') 20 | end 21 | 22 | % Initialize 23 | OUT = zeros(size(datacell)); 24 | 25 | % Convert 26 | for c=1:size(datacell,2) 27 | for r=1:size(datacell,1) 28 | if isnumeric(datacell{r,c}) 29 | OUT(r,c)=datacell{r,c}; 30 | else 31 | OUT(r,c)=NaN; 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/roundnum2cell.m: -------------------------------------------------------------------------------- 1 | function OUT = roundnum2cell(DATA,approx) 2 | % ========================================================================= 3 | % Trasform numerical matrix in cell wih approx decimal digits 4 | % ========================================================================= 5 | % OUT = roundnum2cell(DATA,approx) 6 | % ------------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA = a (n x m) matrix of numbers 9 | %-------------------------------------------------------------------------- 10 | % OPTIONAL INPUT 11 | % - approx = number of decimal digits. Default = 2 12 | %-------------------------------------------------------------------------- 13 | % OUTPUT 14 | % - OUT = a cell matrix with desired number of decimal digits 15 | % ========================================================================= 16 | % Ambrogio Cesa Bianchi, July 2013 17 | % ambrogio.cesabianchi@gmail.com 18 | 19 | % Preliminaries 20 | if ~exist('approx','var') 21 | approx = 2; 22 | end 23 | 24 | % Preallocate 25 | OUT = cell(size(DATA)); 26 | 27 | % Create cell matrix 28 | for i=1:numel(DATA) 29 | XX = DATA(i); 30 | YY = roundn(XX,-approx); % Approx. the number 31 | ZZ = sprintf(['%0.' num2str(approx) 'f'], YY); % Convert it to string 32 | OUT{i} = ZZ; 33 | end 34 | 35 | -------------------------------------------------------------------------------- /v3dot0/Stats/censor.m: -------------------------------------------------------------------------------- 1 | function OUT = censor(X,pct) 2 | % ======================================================================= 3 | % Censor the values of a matrix (RxC) column by column, by replacing with 4 | % NaNs where the data is above 100-pct and below pct 5 | % ======================================================================= 6 | % OUT = censor(X,pct) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - X : matrix of data [double] 10 | % - pct : percentile to be censored on each side [double] 11 | % ----------------------------------------------------------------------- 12 | % OUTPUT 13 | % - OUT : matrix [double] 14 | % ----------------------------------------------------------------------- 15 | % EXAMPLE 16 | % X = rand(50,2); 17 | % OUT = censor(X,5) 18 | % ======================================================================= 19 | % VAR Toolbox 3.0 20 | % Ambrogio Cesa-Bianchi 21 | % ambrogiocesabianchi@gmail.com 22 | % March 2015. Updated November 2020 23 | % ----------------------------------------------------------------------- 24 | 25 | [row, col] = size(X); 26 | OUT = nan(row,col); 27 | % Loop column by column 28 | for ii=1:col 29 | x = X(:,ii); 30 | upp = prctile(x,100-pct); 31 | low = prctile(x,pct); 32 | x(x>upp) = NaN; 33 | x(x0),'stacked'); 26 | for ii=1:size(H,2) 27 | H(1,ii).FaceColor = cmap(ii); 28 | H(1,ii).EdgeColor = H(1,ii).FaceColor; 29 | end 30 | hold on; 31 | H(2,:) = bar((X).*(X<0),'stacked'); 32 | for ii=1:size(H,2) 33 | H(2,ii).FaceColor = H(1,ii).FaceColor; 34 | H(2,ii).EdgeColor = H(2,ii).FaceColor; 35 | end 36 | -------------------------------------------------------------------------------- /v3dot0/Figure/LegOption.m: -------------------------------------------------------------------------------- 1 | function opt = LegOption 2 | % ======================================================================= 3 | % Creates structure of inputs for LegPlot or LegSubplot 4 | % ======================================================================= 5 | % opt = LegOption 6 | % ----------------------------------------------------------------------- 7 | % OUTPUT 8 | % - opt.hsize : default 0.01, horizontal size of the box of the legend 9 | % - opt.vsize : default 0.01, vertical position of the box of the legend 10 | % (0=bottom, 0.5=middle) 11 | % - opt.handle : default [], no handle specified 12 | % - opt.interpreter : default 'Tex', otherwise chamge to 'none' 13 | % - opt.direction : default 1, horizontal legend 14 | % ----------------------------------------------------------------------- 15 | % EXAMPLE 16 | % plot(1:10); 17 | % opt = LegOption; opt.interpreter = 'Tex'; opt.hsize = 0.4 18 | % legpos = LegPlot({'Plot of \alpha'},opt) 19 | % ======================================================================= 20 | % VAR Toolbox 3.0 21 | % Ambrogio Cesa-Bianchi 22 | % ambrogiocesabianchi@gmail.com 23 | % March 2015. Updated November 2020 24 | % ----------------------------------------------------------------------- 25 | 26 | opt.hsize = 0.01; 27 | opt.vsize = 0.01; 28 | opt.handle = []; 29 | opt.interpreter = 'Tex'; 30 | opt.direction = 1; -------------------------------------------------------------------------------- /OldVersions/v2dot0/ExportFig/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Oliver Woodford 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /v3dot0/Figure/AreaPlot.m: -------------------------------------------------------------------------------- 1 | function H = AreaPlot(X) 2 | % ======================================================================= 3 | % Creates an area graph with positive data values stacked on the positive 4 | % quadrant and negative data values stacked on the negative quadrant 5 | % ======================================================================= 6 | % H = AreaPlot(X) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - X: data to plot [nobs x nvars] 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - H: handle to graph 13 | % ----------------------------------------------------------------------- 14 | % EXAMPLE 15 | % X = randn(20,2); 16 | % H = AreaPlot(X) 17 | % ======================================================================= 18 | % VAR Toolbox 3.0 19 | % Ambrogio Cesa-Bianchi 20 | % ambrogiocesabianchi@gmail.com 21 | % March 2015. Updated November 2020 22 | % ----------------------------------------------------------------------- 23 | 24 | 25 | 26 | H(1,:) = area((X).*(X>0),'LineStyle','none'); 27 | for ii=1:size(H,2) 28 | H(1,ii).FaceColor = cmap(ii); 29 | H(1,ii).EdgeColor = H(1,ii).FaceColor; 30 | end 31 | hold on; 32 | H(2,:) = area((X).*(X<0),'LineStyle','none'); 33 | for ii=1:size(H,2) 34 | H(2,ii).FaceColor = H(1,ii).FaceColor; 35 | H(2,ii).EdgeColor = H(2,ii).FaceColor; 36 | end 37 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/MovCorrCent.m: -------------------------------------------------------------------------------- 1 | function OUT = MovCorrCent(X, window, i) 2 | % ======================================================================= 3 | % Computes correlation between X_{i} and X_j for all j different 4 | % of i, from windowdowSize to the number of observations. The 5 | % first windowdowSize rows are NaN. 6 | % ======================================================================= 7 | % OUT = MovCorr(X, windowdowSize, i) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - X: panel time series T observations x N variables 11 | % - windowdow: size of the moving windowdow 12 | % - i: the variable X_i against which correlations should be returned 13 | % ----------------------------------------------------------------------- 14 | % OUTPUT 15 | % - OUT: matrix with moving correlation T observations x N-1 16 | % variables. The first windowdowSize-1 rows are NaN. 17 | % ======================================================================= 18 | % EXAMPLE 19 | % X = rand(100,5); 20 | % OUT = MovCorrCent(X,10,1) 21 | % ======================================================================= 22 | % Ambrogio Cesa Bianchi, March 2015 23 | 24 | [nobs,nvars] = size(X); 25 | OUT = nan(nobs,nvars-1); 26 | 27 | for tt = window+1:nobs-window 28 | C = corrcoef(X(tt-window:tt+window, :)); 29 | idx = setdiff(1:nvars, i); 30 | OUT(tt, :) = C(i, idx); 31 | end 32 | 33 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/FigFontOption.m: -------------------------------------------------------------------------------- 1 | function opt = FigFontOption(fsize) 2 | % ======================================================================= 3 | % Inputs for FigFont 4 | % ======================================================================= 5 | % OPTIONAL INPUT 6 | % - fsize: size of the font [default 12] 7 | % ========================================================================= 8 | % Ambrogio Cesa Bianchi, March 2015 9 | % ambrogio.cesabianchi@gmail.com 10 | 11 | 12 | %% CHECK INPUT 13 | % ======================================================================= 14 | if ~exist('fsize','var') 15 | fsize = 12; 16 | end 17 | 18 | %% SET OPTIONS 19 | % ======================================================================= 20 | opt.fsize = fsize; 21 | 22 | opt.axes_size = opt.fsize; 23 | opt.axes_weight = 'light'; 24 | opt.axes_name = 'Helvetica'; 25 | 26 | opt.title_size = opt.fsize; 27 | opt.title_weight = 'light'; 28 | opt.title_name = 'Helvetica'; 29 | 30 | opt.suptitle_size = opt.fsize+2; 31 | opt.suptitle_weight = 'light'; 32 | opt.suptitle_name = 'Helvetica'; 33 | 34 | opt.legend_size = opt.fsize; 35 | opt.legend_weight = 'light'; 36 | opt.legend_name = 'Helvetica'; 37 | 38 | opt.ylabel_size = opt.fsize; 39 | opt.ylabel_weight = 'light'; 40 | opt.ylabel_name = 'Helvetica'; 41 | 42 | opt.xlabel_size = opt.fsize; 43 | opt.xlabel_weight = 'light'; 44 | opt.xlabel_name = 'Helvetica'; -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/xlsclear.m: -------------------------------------------------------------------------------- 1 | function xlsclear(filename,sheet) 2 | % ======================================================================= 3 | % Clears the content of a spreadsheet 4 | % ======================================================================= 5 | % xlsclear(filename,sheet) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - filename: name of the excel file, eg File.xlsx (char) 9 | % - sheet: name of the worksheet to clear (char) 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - out: [r*c x 1] matrix 13 | % ======================================================================= 14 | % Ambrogio Cesa Bianchi, March 2015 15 | % ambrogio.cesabianchi@gmail.com 16 | 17 | % Name of the excel file 18 | filename = [pwd '\' filename]; 19 | 20 | % Retrieve sheet names 21 | [~, sheetNames] = xlsfinfo(filename); 22 | 23 | % Open Excel as a COM Automation server 24 | Excel = actxserver('Excel.Application'); 25 | 26 | % Open Excel workbook 27 | Workbook = Excel.Workbooks.Open(filename); 28 | 29 | % Clear the content of the sheets 30 | for ii=1:length(sheet) 31 | index = strcmp(sheet(ii),sheetNames); 32 | cellfun(@(x) Excel.ActiveWorkBook.Sheets.Item(x).Cells.Clear, sheetNames(index)); 33 | end 34 | 35 | % Save/close/quit/delete 36 | Workbook.Save; 37 | Excel.Workbook.Close; 38 | invoke(Excel, 'Quit'); 39 | delete(Excel) 40 | -------------------------------------------------------------------------------- /v3dot0/Utils/vec.m: -------------------------------------------------------------------------------- 1 | function out = vec(X,dim) 2 | % ======================================================================= 3 | % Vectorize the matrix X 4 | % ======================================================================= 5 | % out = vec(X) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - X: (TxN) matrix 9 | % ----------------------------------------------------------------------- 10 | % OPTIONAL INPUT 11 | % - dim: dimension over which to vectorize [dflt 1]. Set to 2 to get a 12 | % row vector 13 | % ----------------------------------------------------------------------- 14 | % OUTPUT 15 | % - out: [r*c x 1] matrix 16 | % ----------------------------------------------------------------------- 17 | % EXAMPLE 18 | % x = [1 2; 3 4; 5 6; 7 8; 9 10]; 19 | % out = vec(x,1) 20 | % ======================================================================= 21 | % VAR Toolbox 3.0 22 | % Ambrogio Cesa-Bianchi 23 | % ambrogiocesabianchi@gmail.com 24 | % March 2012. Updated November 2020 25 | % ----------------------------------------------------------------------- 26 | 27 | % Check inputs 28 | if ~exist('dim','var') 29 | dim = 1; 30 | end 31 | 32 | % Size of input 33 | [r,c] = size(X); 34 | 35 | % Vectorize 36 | if dim==1 37 | out = reshape(X,r*c,1); 38 | elseif dim==2 39 | out = reshape(X,1,r*c); 40 | else 41 | error('input "dim" has wrong value') 42 | end 43 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/tdiff.m: -------------------------------------------------------------------------------- 1 | function dmat = tdiff(x,k) 2 | % PURPOSE: produce matrix differences 3 | % ----------------------------------------- 4 | % USAGE: dmat = tdiff(x,k) 5 | % where: x = input matrix (or vector) of length nobs 6 | % k = lagged difference order 7 | % ----------------------------------------- 8 | % NOTE: uses trimr() and lag() 9 | % ----------------------------------------- 10 | % RETURNS: dmat = matrix or vector, differenced by k-periods 11 | % e.g. x(t) - x(t-k), of length nobs, 12 | % (first k observations are zero) 13 | % ----------------------------------------- 14 | % SEE ALSO: trimr() modeled after Gauss trimr function 15 | % ----------------------------------------- 16 | 17 | % written by: 18 | % James P. LeSage, Dept of Economics 19 | % University of Toledo 20 | % 2801 W. Bancroft St, 21 | % Toledo, OH 43606 22 | % jpl@jpl.econ.utoledo.edu 23 | 24 | % error checking on inputs 25 | if (nargin ~= 2) 26 | error('Wrong # of arguments to tdiff'); 27 | end; 28 | 29 | [nobs nvar] = size(x); 30 | 31 | if ( k == 0) 32 | dmat = x; 33 | 34 | elseif k ==1 35 | dmat = zeros(nobs,nvar); 36 | dmat(2:nobs,:) = x(2:nobs,:)-x(1:nobs-1,:); 37 | else 38 | 39 | % modified by Jushan Bai 40 | % NYU 41 | dmat =zeros(nobs,nvar); 42 | dmat(k+1:nobs,:) = x(k+1:nobs,:)-x(1:nobs-k,:); 43 | 44 | % tmp = x - lag(x,1); 45 | % for ndiff = 2:k; 46 | % tmp = tmp - lag(tmp,1); 47 | % end; 48 | % dmat = tmp; 49 | end; 50 | 51 | -------------------------------------------------------------------------------- /v3dot0/Figure/SaveFigure.m: -------------------------------------------------------------------------------- 1 | function SaveFigure(path,quality,type) 2 | % ======================================================================= 3 | % Saves figure to specified path 4 | % ======================================================================= 5 | % SaveFig(path,quality) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - path: path wehere to save the file [char] 9 | % ----------------------------------------------------------------------- 10 | % OPTIONAL INPUT 11 | % - quality: 0 standard, 1 Ghostscript, 2 exportgraphics [dflt=0] [double] 12 | % - type: pdf, png, eps [dflt=pdf] [char] 13 | % ======================================================================= 14 | % VAR Toolbox 3.0 15 | % Ambrogio Cesa-Bianchi 16 | % ambrogiocesabianchi@gmail.com 17 | % March 2015. Updated Feb 2024 18 | % ----------------------------------------------------------------------- 19 | 20 | % Check inputs 21 | if ~exist('quality','var') 22 | quality=0; 23 | end 24 | if ~exist('type','var') 25 | type='pdf'; 26 | end 27 | 28 | % File type 29 | if quality==0 30 | print(['-d' type],'-r100',path) 31 | print(['-d' type],'-r100',path) 32 | print(['-d' type],'-r100',path) 33 | elseif quality==1 % option for Ghostscript 34 | set(gcf, 'Color', 'w'); 35 | export_fig(path,['-' type],'-painters') 36 | elseif quality==2 % option for new matlab function exportgraphics 37 | exportgraphics(gcf,[path '.pdf']) 38 | end -------------------------------------------------------------------------------- /v3dot0/Auxiliary/beta_inv.m: -------------------------------------------------------------------------------- 1 | function x = beta_inv(p, a, b) 2 | % PURPOSE: inverse of the cdf (quantile) of the beta(a,b) distribution 3 | %-------------------------------------------------------------- 4 | % USAGE: x = beta_inv(p,a,b) 5 | % where: p = vector of probabilities 6 | % a = beta distribution parameter, a = scalar 7 | % b = beta distribution parameter b = scalar 8 | % NOTE: mean [beta(a,b)] = a/(a+b), variance = ab/((a+b)*(a+b)*(a+b+1)) 9 | %-------------------------------------------------------------- 10 | % RETURNS: x at each element of p for the beta(a,b) distribution 11 | %-------------------------------------------------------------- 12 | % SEE ALSO: beta_d, beta_pdf, beta_inv, beta_rnd 13 | %-------------------------------------------------------------- 14 | 15 | % Anders Holtsberg, 18-11-93 16 | % Copyright (c) Anders Holtsberg 17 | % documentation modified by LeSage to 18 | % match the format of the econometrics toolbox 19 | 20 | if (nargin ~= 3) 21 | error('Wrong # of arguments to beta_inv'); 22 | end 23 | 24 | if any(any((a<=0)|(b<=0))) 25 | error('beta_inv parameter a or b is nonpositive'); 26 | end 27 | if any(any(abs(2*p-1)>1)) 28 | error('beta_inv: A probability should be 0<=p<=1'); 29 | end 30 | 31 | x = a ./ (a+b); 32 | dx = 1; 33 | while any(any(abs(dx)>256*eps*max(x,1))) 34 | dx = (betainc(x,a,b) - p) ./ beta_pdf(x,a,b); 35 | x = x - dx; 36 | x = x + (dx - x) / 2 .* (x<0); 37 | end 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/ws2struct.m: -------------------------------------------------------------------------------- 1 | %This Script saves all the variables from the current workspace into a 2 | %single structure array. 3 | %Author: Andres Gonzalez 4 | %Year:2012 5 | %Version:0.2 6 | 7 | %######################################################################### 8 | %Summary: 9 | %This function allows to save all the variables from the 'caller' workspace into a struct array 10 | %Description: 11 | %Sometimes you need to save the variables from your base workspace, but using "save" function will have them all stored individually so if you reload them into a new workspace it could be a mess, and some variables could be overwritten. 12 | %With this function, you can save all of them into a struct array, and so they'll be nicely packaged and ready to be saved to a .mat file that, when reloaded, will be easy to identify. 13 | %Tags: 14 | %save, struct, base, workspace, structure array 15 | 16 | %Example: 17 | % a='LALALA' 18 | % b=[1:12:258] 19 | % c={'cell1', 'cell2', 'cell3'} 20 | % d=768 21 | % e=true(3) 22 | % theworkspace=ws2struct(); 23 | % theworkspace = 24 | % 25 | % a: 'LALALA' 26 | % b: [1x22 double] 27 | % c: {'cell1' 'cell2' 'cell3'} 28 | % d: 768 29 | % e: [3x3 logical] 30 | 31 | function WStruct=ws2struct() 32 | 33 | WSVARS = evalin('caller', 'who'); 34 | for wscon=1:size(WSVARS,1) 35 | thisvar=evalin('caller', WSVARS{wscon}); 36 | THEWORKSPACE.(WSVARS{wscon})=thisvar; 37 | end 38 | 39 | WStruct=THEWORKSPACE; 40 | 41 | 42 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/beta_inv.m: -------------------------------------------------------------------------------- 1 | function x = beta_inv(p, a, b) 2 | % PURPOSE: inverse of the cdf (quantile) of the beta(a,b) distribution 3 | %-------------------------------------------------------------- 4 | % USAGE: x = beta_inv(p,a,b) 5 | % where: p = vector of probabilities 6 | % a = beta distribution parameter, a = scalar 7 | % b = beta distribution parameter b = scalar 8 | % NOTE: mean [beta(a,b)] = a/(a+b), variance = ab/((a+b)*(a+b)*(a+b+1)) 9 | %-------------------------------------------------------------- 10 | % RETURNS: x at each element of p for the beta(a,b) distribution 11 | %-------------------------------------------------------------- 12 | % SEE ALSO: beta_d, beta_pdf, beta_inv, beta_rnd 13 | %-------------------------------------------------------------- 14 | 15 | % Anders Holtsberg, 18-11-93 16 | % Copyright (c) Anders Holtsberg 17 | % documentation modified by LeSage to 18 | % match the format of the econometrics toolbox 19 | 20 | if (nargin ~= 3) 21 | error('Wrong # of arguments to beta_inv'); 22 | end 23 | 24 | if any(any((a<=0)|(b<=0))) 25 | error('beta_inv parameter a or b is nonpositive'); 26 | end 27 | if any(any(abs(2*p-1)>1)) 28 | error('beta_inv: A probability should be 0<=p<=1'); 29 | end 30 | 31 | x = a ./ (a+b); 32 | dx = 1; 33 | while any(any(abs(dx)>256*eps*max(x,1))) 34 | dx = (betainc(x,a,b) - p) ./ beta_pdf(x,a,b); 35 | x = x - dx; 36 | x = x + (dx - x) / 2 .* (x<0); 37 | end 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/ws2struct.m: -------------------------------------------------------------------------------- 1 | %This Script saves all the variables from the current workspace into a 2 | %single structure array. 3 | %Author: Andres Gonzalez 4 | %Year:2012 5 | %Version:0.2 6 | 7 | %######################################################################### 8 | %Summary: 9 | %This function allows to save all the variables from the 'caller' workspace into a struct array 10 | %Description: 11 | %Sometimes you need to save the variables from your base workspace, but using "save" function will have them all stored individually so if you reload them into a new workspace it could be a mess, and some variables could be overwritten. 12 | %With this function, you can save all of them into a struct array, and so they'll be nicely packaged and ready to be saved to a .mat file that, when reloaded, will be easy to identify. 13 | %Tags: 14 | %save, struct, base, workspace, structure array 15 | 16 | %Example: 17 | % a='LALALA' 18 | % b=[1:12:258] 19 | % c={'cell1', 'cell2', 'cell3'} 20 | % d=768 21 | % e=true(3) 22 | % theworkspace=ws2struct(); 23 | % theworkspace = 24 | % 25 | % a: 'LALALA' 26 | % b: [1x22 double] 27 | % c: {'cell1' 'cell2' 'cell3'} 28 | % d: 768 29 | % e: [3x3 logical] 30 | 31 | function WStruct=ws2struct() 32 | 33 | WSVARS = evalin('caller', 'who'); 34 | for wscon=1:size(WSVARS,1) 35 | thisvar=evalin('caller', WSVARS{wscon}); 36 | THEWORKSPACE.(WSVARS{wscon})=thisvar; 37 | end 38 | 39 | WStruct=THEWORKSPACE; 40 | 41 | 42 | -------------------------------------------------------------------------------- /v3dot0/VAR/VARmakelags.m: -------------------------------------------------------------------------------- 1 | function OUT = VARmakelags(DATA,lag) 2 | % ======================================================================= 3 | % Builds a matrix with lagged values of DATA, i.e. if DATA = [x1 x2], 4 | % VARmakelags(DATA,1) yields OUT = [x1 x2 x1(-1) x2(-1)]. Serves as an 5 | % input to VARmakexy 6 | % ======================================================================= 7 | % OUT = VARmakelags(DATA,lag) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - DATA: matrix containing the original data 11 | % - lag: lag order 12 | % ----------------------------------------------------------------------- 13 | % OUTPUT 14 | % - OUT: matrix of lagged values 15 | % ----------------------------------------------------------------------- 16 | % EXAMPLE 17 | % x = [1 2; 3 4; 5 6; 7 8; 9 10]; 18 | % OUT = VARmakelags(x,2) 19 | % ======================================================================= 20 | % VAR Toolbox 3.0 21 | % Ambrogio Cesa-Bianchi 22 | % ambrogiocesabianchi@gmail.com 23 | % March 2012. Updated November 2020 24 | % ----------------------------------------------------------------------- 25 | 26 | % Get dimesion of DATA 27 | [nobs, ~]= size(DATA); 28 | 29 | % Create the lagged matrix 30 | OUT = []; 31 | for jj=0:lag-1 32 | OUT = [DATA(jj+1:nobs-lag+jj,:), OUT]; 33 | end 34 | 35 | % Finally, save the non-lagged values... 36 | aux = DATA(lag+1:end,:); 37 | 38 | %... and append to the lagged matrix 39 | OUT = [aux OUT]; -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/L.m: -------------------------------------------------------------------------------- 1 | function OUT = L(X,nlag) 2 | % ======================================================================= 3 | % Creates a matrix (or vector) of lagged values (the first obs are NaN) 4 | % ======================================================================= 5 | % OUT = L(X,nlag) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - X: input matrix (nobs X nvars) 9 | % - nlag: order of lags (-1 is lag ---- +1 is lead) 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - OUT: lagged matrix (nobs X nvars), the first obs are NaN 13 | % ----------------------------------------------------------------------- 14 | % NOTES 15 | % - If nlag = 0, the original series is returned 16 | % ========================================================================= 17 | % Ambrogio Cesa Bianchi, March 2015 18 | % ambrogiocesabianchi@gmail.com 19 | 20 | % Notes: this script is based on lag.m script by James P. LeSage 21 | 22 | init = NaN; 23 | switch(nargin) 24 | case 1 25 | error('Missing input: number of lags'); 26 | case 2 27 | if nlag > 0 % this is lead 28 | zt = ones(nlag,cols(X))*init; 29 | OUT = [trimr(X,nlag,0); zt]; 30 | elseif nlag < 0 % this is lag 31 | zt = ones(abs(nlag),cols(X))*init; 32 | OUT = [ zt; trimr(X,0,abs(nlag))]; 33 | else 34 | OUT = X; 35 | end 36 | otherwise 37 | error('Too many inputs for function L'); 38 | end 39 | 40 | 41 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/CorrTable.m: -------------------------------------------------------------------------------- 1 | function out = CorrTable(x,vnames) 2 | % ======================================================================= 3 | % Computes the correlation matrix of a matrix of time series with titles 4 | % ======================================================================= 5 | % out = CorrTable(x,vnames) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - x: T obs (rows) x N series (columns) 9 | % - vnames: cell array with vnames of the N series 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - out: table of correlation matrix with titles 13 | % ======================================================================= 14 | % Ambrogio Cesa Bianchi, March 2015 15 | 16 | 17 | % vnames must be a row vector 18 | if size(vnames,1)>1 19 | vnames = vnames'; 20 | end 21 | 22 | % Compute correlation 23 | y = corrcoef(x); 24 | [r, ~] = size(y); 25 | 26 | % Place NaNs on the uuper triangular 27 | y(find(triu(y))) = NaN; 28 | jj = 1; 29 | for ii=1:r 30 | y(ii,jj) = 1; 31 | jj = jj +1; 32 | end 33 | 34 | % Save position of NaNs 35 | nans = isnan(y); 36 | 37 | % Transform table into cell array 38 | table = num2cell(y); 39 | 40 | % Substitue NaNs with - 41 | table(nans) = {'--'}; 42 | 43 | % Add vnames on top 44 | table = [vnames ; table]; 45 | 46 | % Add vnames on the left 47 | aux = [{''} vnames]'; 48 | out = [aux table]; 49 | 50 | % Print using mprint 51 | info.cvnames = char(vnames); 52 | info.rvnames = char([{' '} vnames]); 53 | mprint(y,info) -------------------------------------------------------------------------------- /v3dot0/Auxiliary/winsor.m: -------------------------------------------------------------------------------- 1 | function[y,varargout] = winsor(x,p) 2 | % WINSOR Winsorize a vector 3 | % INPUTS : x - n*1 data vector 4 | % p - 2*1 vector of cut-off percentiles (left, right) 5 | % OUTPUTS : y - winsorized x, n*1 vector 6 | % i - (optional) n*1 value-replaced-indicator vector 7 | % NOTES : Let p1 = prctile(x,p(1)), p2 = prctile(x,p(2)). (Note 8 | % that PRCTILE ignores NaN values). Then 9 | % if x(i) < p1, y(i) = min(x(j) | x(j) >= p1) 10 | % if x(i) > p2, y(i) = max(x(j) | x(j) <= p2) 11 | % EXAMPLE : x = rand(10,1), y = winsor(x,[10 90]) 12 | % AUTHOR : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 4/15/07 13 | 14 | if ~isvector(x) 15 | error('Input argument "x" must be a vector') 16 | end 17 | if nargin < 2 18 | error('Input argument "p" is undefined') 19 | end 20 | if ~isvector(p) 21 | error('Input argument "p" must be a vector') 22 | end 23 | if length(p) ~= 2 24 | error('Input argument "p" must be a 2*1 vector') 25 | end 26 | if p(1) < 0 || p(1) > 100 27 | error('Left cut-off percentile is out of [0,100] range') 28 | end 29 | if p(2) < 0 || p(2) > 100 30 | error('Right cut-off percentile is out of [0,100] range') 31 | end 32 | if p(1) > p(2) 33 | error('Left cut-off percentile exceeds right cut-off percentile') 34 | end 35 | p = prctile(x,p); 36 | i1 = x < p(1); v1 = min(x(~i1)); 37 | i2 = x > p(2); v2 = max(x(~i2)); 38 | y = x; 39 | y(i1) = v1; 40 | y(i2) = v2; 41 | if nargout > 1 42 | varargout(1) = {i1 | i2}; 43 | end -------------------------------------------------------------------------------- /v3dot0/Figure/cmap.m: -------------------------------------------------------------------------------- 1 | function out = cmap(n) 2 | % ======================================================================= 3 | % Returns a 1x3 row vector for RGB colors corrending to the n^th element 4 | % of the following list: 5 | % - 1 blue 6 | % - 2 yellow 7 | % - 3 purple 8 | % - 4 light blues 9 | % - 5 red 10 | % - 6 green 11 | % - 7 dark red 12 | % ======================================================================= 13 | % cmap(n) 14 | % ----------------------------------------------------------------------- 15 | % OPTIONAL INPUT 16 | % - n: number of color in the sequence 17 | % ----------------------------------------------------------------------- 18 | % OUTPUT 19 | % - out: 3x1 vector or RGB color 20 | % ----------------------------------------------------------------------- 21 | % EXAMPLE 22 | % out = cmap(1); 23 | % ======================================================================= 24 | % VAR Toolbox 3.0 25 | % Ambrogio Cesa-Bianchi 26 | % ambrogiocesabianchi@gmail.com 27 | % March 2015. Updated November 2020 28 | % ----------------------------------------------------------------------- 29 | 30 | 31 | colors = [... 32 | 0.000,0.447,0.741 ; % 1 blue 33 | 0.929,0.694,0.125 ; % 2 yellow 34 | 0.494,0.184,0.556 ; % 3 purple 35 | 0.301,0.745,0.933 ; % 4 light blues 36 | 0.850,0.325,0.098 ; % 5 red 37 | 0.466,0.674,0.188 ; % 6 green 38 | 0.635,0.078,0.184 ; % 7 dark red 39 | 0/255,48/255,143/255; % 8 air force 40 | 209/255,96/255,1/255; % 9 orange 41 | parula]; 42 | out = colors(n,:); 43 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/MovAvgCent.m: -------------------------------------------------------------------------------- 1 | function OUT = MovAvgCent(DATA,window) 2 | % ======================================================================= 3 | % Moving average of the matrix DATA (TxN). The moving average is 4 | % compute over the interval [t-window,t+window] and it is computed down 5 | % each column. 6 | % ======================================================================= 7 | % OUT = MovAvg(DATA,window) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % DATA: T observations DATA window variables 11 | % window: window of the moving average 12 | %------------------------------------------------------------------------ 13 | % OUPUT 14 | % OUT: T observations DATA window variables matrix (the first windows-1 15 | % obseravations are NaN) 16 | % ======================================================================= 17 | % Ambrogio Cesa Bianchi, March 2015 18 | % ambrogio.cesabianchi@gmail.com 19 | 20 | 21 | if nargin<2, error('Not enough input.'),end 22 | if window<=0,error('window must be positive.'),end 23 | if (window~=floor(window)),error('window must be an integer.'),end 24 | 25 | if min(size(DATA))==1, 26 | DATA=DATA(:); % forces DATA to be a column vector 27 | end 28 | 29 | [nobs,nvars] = size(DATA); 30 | if window>nobs, 31 | error('window must not be greater than the length of DATA.') 32 | end 33 | 34 | temp = nan(nobs,nvars); 35 | for jj = (window+1):(nobs-window), 36 | temp(jj,:) = nanmean(DATA(jj-window:jj+window,:)); 37 | end 38 | 39 | OUT = temp; -------------------------------------------------------------------------------- /v3dot0/VAR/L.m: -------------------------------------------------------------------------------- 1 | function OUT = L(X,nlag) 2 | % ======================================================================= 3 | % Creates a matrix (or vector) of lagged values (the first obs are NaN) 4 | % ======================================================================= 5 | % OUT = L(X,nlag) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - X: input matrix (nobs X nvars) 9 | % - nlag: order of lags (-1 is lag ---- +1 is lead) 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - OUT: lagged matrix (nobs X nvars), the first obs are NaN 13 | % ----------------------------------------------------------------------- 14 | % EXAMPLE 15 | % x = 1:10'; 16 | % L1x = L(x,-1); 17 | % ======================================================================= 18 | % VAR Toolbox 3.0 19 | % Ambrogio Cesa-Bianchi 20 | % ambrogiocesabianchi@gmail.com 21 | % March 2012. Updated November 2020 22 | % ----------------------------------------------------------------------- 23 | 24 | init = NaN; 25 | switch(nargin) 26 | case 1 27 | error('Missing input: number of lags'); 28 | case 2 29 | if nlag > 0 % this is lead 30 | zt = ones(nlag,cols(X))*init; 31 | OUT = [trimr(X,nlag,0); zt]; 32 | elseif nlag < 0 % this is lag 33 | zt = ones(abs(nlag),cols(X))*init; 34 | OUT = [ zt; trimr(X,0,abs(nlag))]; 35 | else 36 | OUT = X; 37 | end 38 | otherwise 39 | error('Too many inputs for function L'); 40 | end 41 | 42 | 43 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Auxiliary/winsor.m: -------------------------------------------------------------------------------- 1 | function[y,varargout] = winsor(x,p) 2 | % WINSOR Winsorize a vector 3 | % INPUTS : x - n*1 data vector 4 | % p - 2*1 vector of cut-off percentiles (left, right) 5 | % OUTPUTS : y - winsorized x, n*1 vector 6 | % i - (optional) n*1 value-replaced-indicator vector 7 | % NOTES : Let p1 = prctile(x,p(1)), p2 = prctile(x,p(2)). (Note 8 | % that PRCTILE ignores NaN values). Then 9 | % if x(i) < p1, y(i) = min(x(j) | x(j) >= p1) 10 | % if x(i) > p2, y(i) = max(x(j) | x(j) <= p2) 11 | % EXAMPLE : x = rand(10,1), y = winsor(x,[10 90]) 12 | % AUTHOR : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 4/15/07 13 | 14 | if ~isvector(x) 15 | error('Input argument "x" must be a vector') 16 | end 17 | if nargin < 2 18 | error('Input argument "p" is undefined') 19 | end 20 | if ~isvector(p) 21 | error('Input argument "p" must be a vector') 22 | end 23 | if length(p) ~= 2 24 | error('Input argument "p" must be a 2*1 vector') 25 | end 26 | if p(1) < 0 || p(1) > 100 27 | error('Left cut-off percentile is out of [0,100] range') 28 | end 29 | if p(2) < 0 || p(2) > 100 30 | error('Right cut-off percentile is out of [0,100] range') 31 | end 32 | if p(1) > p(2) 33 | error('Left cut-off percentile exceeds right cut-off percentile') 34 | end 35 | p = prctile(x,p); 36 | i1 = x < p(1); v1 = min(x(~i1)); 37 | i2 = x > p(2); v2 = max(x(~i2)); 38 | y = x; 39 | y(i1) = v1; 40 | y(i2) = v2; 41 | if nargout > 1 42 | varargout(1) = {i1 | i2}; 43 | end -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/MovAvg.m: -------------------------------------------------------------------------------- 1 | function OUT = MovAvg(DATA,window) 2 | % ======================================================================= 3 | % Moving average of the matrix DATA (TxN). The moving average is 4 | % computed down each column. 5 | % ======================================================================= 6 | % OUT = MovAvg(DATA,window) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % DATA: T observations x N variables 10 | % window: window of the moving average 11 | %------------------------------------------------------------------------ 12 | % OUPUT 13 | % OUT: T observations x N variables matrix (the first windows-1 14 | % obseravations are NaN) 15 | % ======================================================================= 16 | % Ambrogio Cesa Bianchi, March 2015 17 | % ambrogio.cesabianchi@gmail.com 18 | 19 | if nargin<2, error('Not enough input.'), end 20 | if window<=0, error('window must be positive.'), end 21 | if (window~=floor(window)), error('window must be an integer.'), end 22 | 23 | if min(size(DATA))==1, 24 | DATA = DATA(:); % forces DATA to be a column vector 25 | end 26 | 27 | [nobs,nvar] = size(DATA); 28 | if window>nobs, 29 | error('window must not be greater than the length of DATA.') 30 | end 31 | 32 | temp=[]; 33 | for row=1:(nobs-window+1), 34 | temp = [temp; mean(DATA(row:(row+window-1),:))]; 35 | end 36 | 37 | OUT = temp; 38 | OUT = [nan(window-1,nvar); OUT]; % add nans to make conformable to original 39 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/VARoption.m: -------------------------------------------------------------------------------- 1 | function VARopt = VARoption 2 | % ======================================================================= 3 | % Optional inputs for VAR analysis 4 | % ======================================================================= 5 | % Ambrogio Cesa Bianchi, March 2015 6 | % ambrogio.cesabianchi@gmail.com 7 | 8 | 9 | VARopt.vnames = []; % endogenous variables' names 10 | VARopt.vnames_ex = []; % exogenous variables' names 11 | VARopt.snames = []; % shocks' names (for sign restriction) 12 | VARopt.nsteps = 40; % number of steps for IRFs and FEVDs 13 | VARopt.impact = 0; % size of the shock for IRFs (0 => 1stdev, 1 => 1) 14 | VARopt.shut = 0; % forces the IRF of one variable to zero 15 | VARopt.ident = 'oir'; % identification method for IRFs ('oir' short-run restr, 'bq' long-run restr, 'sr' sign restr) 16 | VARopt.ndraws = 100; % draws for bootstrap and sign restrictions 17 | VARopt.pctg = 95; % confidence bands for bootstrap 18 | VARopt.method = 'bs'; % type of boostrap 'bs' sampling with replacement; 'wild' wild bootstrap 19 | VARopt.pick = 0; % selects one variable for IRFs and FEVDs plots (0 => plot all) 20 | VARopt.quality = 0; % if set to 1 saves high quality figures (Ghostscript required) 21 | VARopt.suptitle = 0; % title on top of figures 22 | VARopt.firstdate = []; % initial date of the sample in format 1999.75 = 1999Q4 23 | VARopt.frequency = 'q'; % frequency of the data 'q' quarterly, 'y' annual, 'm' monthly 24 | VARopt.figname = []; % string for figure name 25 | -------------------------------------------------------------------------------- /v3dot0/Utils/roundnum2cell.m: -------------------------------------------------------------------------------- 1 | function OUT = roundnum2cell(DATA,approx) 2 | % ======================================================================= 3 | % Trasform numerical matrix in cell wih approx decimal digits 4 | % ======================================================================= 5 | % OUT = roundnum2cell(DATA,approx) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - DATA = a (n x m) matrix of numbers 9 | % ----------------------------------------------------------------------- 10 | % OPTIONAL INPUT 11 | % - approx = number of decimal digits. Default = 2 12 | % ----------------------------------------------------------------------- 13 | % OUTPUT 14 | % - OUT = a cell matrix with desired number of decimal digits 15 | % ----------------------------------------------------------------------- 16 | % EXAMPLE 17 | % x = [1 2; 3 4; 5 6; 7 8; 9 10]; 18 | % OUT = roundnum2cell(x,2) 19 | % ======================================================================= 20 | % VAR Toolbox 3.0 21 | % Ambrogio Cesa-Bianchi 22 | % ambrogiocesabianchi@gmail.com 23 | % March 2012. Updated November 2020 24 | % ----------------------------------------------------------------------- 25 | 26 | % Preliminaries 27 | if ~exist('approx','var') 28 | approx = 2; 29 | end 30 | 31 | % Preallocate 32 | OUT = cell(size(DATA)); 33 | 34 | % Create cell matrix 35 | for i=1:numel(DATA) 36 | XX = DATA(i); 37 | YY = round(XX,approx); % Approx. the number 38 | ZZ = sprintf(['%0.' num2str(approx) 'f'], YY); % Convert it to string 39 | OUT{i} = ZZ; 40 | end 41 | 42 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/MovSum.m: -------------------------------------------------------------------------------- 1 | function OUT = MovSum(DATA,window) 2 | % ======================================================================= 3 | % Moving sum of the vector (or matrix) DATA (T obs x N variables). If 4 | % DATA is a matrix moving sum is computed down each column. 5 | % ======================================================================= 6 | % OUT = MovAvg(DATA,window) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % DATA: T observations x N variables 10 | % window: window of the moving sum 11 | %------------------------------------------------------------------------ 12 | % OUPUT 13 | % OUT: T observations x N variables matrix (the first windows-1 14 | % obseravations are NaN) 15 | % ======================================================================= 16 | % Ambrogio Cesa Bianchi, March 2015 17 | % ambrogio.cesabianchi@gmail.com 18 | 19 | if nargin<2, error('Not enough input.'), end 20 | if window<=0, error('window must be positive.'), end 21 | if (window~=floor(window)), error('window must be an integer.'), end 22 | 23 | if min(size(DATA))==1, 24 | DATA = DATA(:); % forces DATA to be a column vector 25 | end 26 | 27 | [nobs,nvar] = size(DATA); 28 | if window>nobs, 29 | error('window must not be greater than the length of DATA.') 30 | end 31 | 32 | temp=[]; 33 | for row=1:(nobs-window+1), 34 | temp = [temp; sum(DATA(row:(row+window-1),:))]; 35 | end 36 | 37 | OUT = temp; 38 | OUT = [nan(window-1,nvar); OUT]; % add nans to make conformable to original 39 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Oliver J. Woodford, Yair M. Altman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Stats/MovStd.m: -------------------------------------------------------------------------------- 1 | function OUT = MovStd(DATA,window) 2 | % ======================================================================= 3 | % Moving stand. deviation of the vector (or matrix) DATA (T obs x N 4 | % variables). If DATA is a matrix moving average is computed down each 5 | % column. 6 | % ======================================================================= 7 | % OUT = MovAvg(DATA,window) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - DATA : T observations x N variables 11 | % - window: window of the moving average 12 | %------------------------------------------------------------------------ 13 | % OUPUT 14 | % - OUT: T observations x N variables matrix (the first windows-1 15 | % obseravations are NaN) 16 | % ======================================================================= 17 | % Ambrogio Cesa Bianchi, March 2015 18 | % ambrogio.cesabianchi@gmail.com 19 | 20 | 21 | if nargin<2, error('Not enough input.'), end 22 | if window<=0, error('window must be positive.'), end 23 | if (window~=floor(window)), error('window must be an integer.'), end 24 | 25 | if min(size(DATA))==1, 26 | DATA = DATA(:); % forces DATA to be a column vector 27 | end 28 | 29 | [nobs,nvar] = size(DATA); 30 | if window>nobs, 31 | error('window must not be greater than the length of DATA.') 32 | end 33 | 34 | temp = []; 35 | for row=1:(nobs-window+1), 36 | temp = [temp; std(DATA(row:(row+window-1),:))]; 37 | end 38 | 39 | OUT = temp; 40 | OUT = [nan(window-1,nvar); OUT]; % add nans to make conformable to original -------------------------------------------------------------------------------- /v3dot0/Stats/MovCorr.m: -------------------------------------------------------------------------------- 1 | function OUT = MovCorr(X,window,i) 2 | % ======================================================================= 3 | % Computes correlation between X_i and X_j for all j different 4 | % of i, from window to the number of observations. The 5 | % first window rows are NaN. 6 | % ======================================================================= 7 | % OUT = MovCorr(X, window, i) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - X: panel time series T observations x N variables [double] 11 | % - window : size of the moving window [double] 12 | % - i: selects the i^th variable against which correlations are to be 13 | % computed [double] 14 | % ----------------------------------------------------------------------- 15 | % OUTPUT 16 | % - OUT: matrix with moving correlation T observations x N-1 17 | % variables. The first window-1 rows are NaN. [double] 18 | % ----------------------------------------------------------------------- 19 | % EXAMPLE 20 | % X = rand(100,5); 21 | % OUT = MovCorr(X,20,1) 22 | % ======================================================================= 23 | % VAR Toolbox 3.0 24 | % Ambrogio Cesa-Bianchi 25 | % ambrogiocesabianchi@gmail.com 26 | % March 2012. Updated November 2020 27 | % ----------------------------------------------------------------------- 28 | 29 | 30 | [nobs,nvars] = size(X); 31 | OUT = nan(nobs,nvars-1); 32 | 33 | for tt = window:nobs 34 | C = corrcoef(X(tt-window+1:tt, :)); 35 | idx = setdiff(1:nvars, [i]); 36 | OUT(tt, :) = C(i, idx); 37 | end 38 | 39 | -------------------------------------------------------------------------------- /v3dot0/Figure/FigSize.m: -------------------------------------------------------------------------------- 1 | function FigSize(xdim,ydim) 2 | % ======================================================================= 3 | % Sets the figure window to a desired size. The default is full screen 4 | % ======================================================================= 5 | % FigSize(xdim,ydim) 6 | % ----------------------------------------------------------------------- 7 | % OPTIONAL INPUT 8 | % - xdim: horizontal size (in cm) 9 | % - ydim: vertical size (in cm) 10 | % ----------------------------------------------------------------------- 11 | % EXAMPLE 12 | % FigSize(12,6) 13 | % plot(1:10) 14 | % ======================================================================= 15 | % VAR Toolbox 3.0 16 | % Ambrogio Cesa-Bianchi 17 | % ambrogiocesabianchi@gmail.com 18 | % March 2015. Updated November 2020 19 | % ----------------------------------------------------------------------- 20 | 21 | 22 | if nargin==0 23 | figure('units','normalized','outerposition',[0 0.1 1 0.9]) 24 | else 25 | % Get the position of the figure 26 | % [left bottom width height] [standard in px: 403 246 560 420] 27 | position = get(gcf, 'Position'); 28 | 29 | % Place the figure on the south west corner of the screen (in cm) 30 | position(1) = 1; 31 | position(2) = 2; 32 | 33 | % xdim dimension in cm 34 | if exist('xdim','var') 35 | position(3) = xdim; 36 | end 37 | 38 | % ydim dimension in cm 39 | if exist ('ydim','var') 40 | position(4) = ydim; 41 | end 42 | 43 | % Apply rescaling 44 | set(gcf, 'units', 'centimeters', 'Position', position) 45 | end -------------------------------------------------------------------------------- /v3dot0/Stats/MovCorrCent.m: -------------------------------------------------------------------------------- 1 | function OUT = MovCorrCent(X,window,i) 2 | % ======================================================================= 3 | % Computes correlation between X_{i} and X_j for all j different 4 | % of i, from windowdowSize to the number of observations. The 5 | % first windowdowSize rows are NaN. 6 | % ======================================================================= 7 | % OUT = MovCorr(X, windowdowSize, i) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - X: panel time series T observations x N variables [double] 11 | % - window: size of the moving window [double] 12 | % - i: selects the i^th variable against which correlations are to be 13 | % computed [double] 14 | % ----------------------------------------------------------------------- 15 | % OUTPUT 16 | % - OUT: matrix with moving correlation T observations x N-1 17 | % variables. The first window-1 rows are NaN [double] 18 | % ----------------------------------------------------------------------- 19 | % EXAMPLE 20 | % X = rand(100,5); 21 | % OUT = MovCorrCent(X,10,1) 22 | % ======================================================================= 23 | % VAR Toolbox 3.0 24 | % Ambrogio Cesa-Bianchi 25 | % ambrogiocesabianchi@gmail.com 26 | % March 2012. Updated November 2020 27 | % ----------------------------------------------------------------------- 28 | 29 | 30 | [nobs,nvars] = size(X); 31 | OUT = nan(nobs,nvars-1); 32 | 33 | for tt = window+1:nobs-window 34 | C = corrcoef(X(tt-window:tt+window, :)); 35 | idx = setdiff(1:nvars, i); 36 | OUT(tt, :) = C(i, idx); 37 | end 38 | 39 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/VARdrawpost.m: -------------------------------------------------------------------------------- 1 | function [sigma_draw, Ft_draw] = VARdrawpost(VAR) 2 | % ======================================================================= 3 | % Draw from the posterior distribution of a VAR model 4 | % ======================================================================= 5 | % [sigma_draw, Ft_draw] = VARdrawpost(VAR) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - VAR: structure, result of VARmodel function 9 | % ----------------------------------------------------------------------- 10 | % OUPUT 11 | % - sigma_draw: draw from the posterior of VCV matrix of residuals of VAR 12 | % - Ft_draw: draw from the posterior of Ft of VAR 13 | % ======================================================================= 14 | % Ambrogio Cesa Bianchi, March 2015 15 | % ambrogio.cesabianchi@gmail.com 16 | 17 | 18 | 19 | %% Get relevant parameters from VAR structure 20 | %=============================================== 21 | nobs = VAR.nobs; 22 | k = []; 23 | nvar = VAR.nvar; 24 | X = VAR.X; 25 | 26 | 27 | %% OLS estimates 28 | %============================================ 29 | Ft_hat = VAR.Ft; 30 | sigma_hat = VAR.sigma; 31 | inv_sigma_hat = inv(sigma_hat); 32 | 33 | 34 | %% Draw the VCV matrix (sigma) 35 | %============================================ 36 | inv_sigma_draw = wishrnd(inv_sigma_hat/nobs,nobs); 37 | sigma_draw = inv(inv_sigma_draw); 38 | 39 | 40 | %% Draw the coeffiecient matrix (Ft) 41 | %============================================ 42 | aux1 = inv(X'*X); 43 | aux2 = kron(sigma_draw, aux1); 44 | Fthat_vec = Ft_hat(:); 45 | Ftdraw = mvnrnd(Fthat_vec,aux2); 46 | Ft_draw = reshape(Ftdraw,k,nvar); 47 | -------------------------------------------------------------------------------- /v3dot0/Auxiliary/lag.m: -------------------------------------------------------------------------------- 1 | function z = lag(x,n,v) 2 | % PURPOSE: creates a matrix or vector of lagged values 3 | % ------------------------------------------------------- 4 | % USAGE: z = lag(x,n,v) 5 | % where: x = input matrix or vector, (nobs x k) 6 | % n = order of lag 7 | % v = (optional) initial values (default=0) 8 | % e.g. 9 | % z = lag(x) creates a matrix (or vector) of x, lagged 1 observations 10 | % z = lag(x,n) creates a matrix (or vector) of x, lagged n observations 11 | % z = lag(x,n,v) creates a matrix (or vector) of x, lagged n observations, 12 | % with initial values taking a value v. 13 | % ------------------------------------------------------ 14 | % RETURNS: z = matrix (or vector) of lags (nobs x k) 15 | % ------------------------------------------------------ 16 | % NOTES: if n <= 0, z = [] is returned. While you may find this 17 | % preverse, it is sometimes useful. 18 | %------------------------------------------------------- 19 | % SEE ALSO: mlag() 20 | %------------------------------------------------------- 21 | 22 | % written by: 23 | % James P. LeSage, Dept of Economics 24 | % University of Toledo 25 | % 2801 W. Bancroft St, 26 | % Toledo, OH 43606 27 | % jpl@jpl.econ.utoledo.edu 28 | 29 | switch(nargin) 30 | 31 | case 1 32 | n = 1; v = 0; 33 | zt = ones(n,cols(x))*v; 34 | z = [ zt; trimr(x,0,n)]; 35 | 36 | case 2 37 | v = 0; 38 | if n < 1 39 | z = []; 40 | else 41 | zt = ones(n,cols(x))*v; 42 | z = [ zt; trimr(x,0,n)]; 43 | end 44 | 45 | case 3 46 | if n < 1 47 | z = []; 48 | else 49 | zt = ones(n,cols(x))*v; 50 | z = [ zt; trimr(x,0,n)]; 51 | end 52 | 53 | otherwise 54 | error('lag: wrong # of input arguments'); 55 | end; 56 | 57 | 58 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/ExportFig/pdf2eps.m: -------------------------------------------------------------------------------- 1 | %PDF2EPS Convert a pdf file to eps format using pdftops 2 | % 3 | % Examples: 4 | % pdf2eps source dest 5 | % 6 | % This function converts a pdf file to eps format. 7 | % 8 | % This function requires that you have pdftops, from the Xpdf suite of 9 | % functions, installed on your system. This can be downloaded from: 10 | % http://www.foolabs.com/xpdf 11 | % 12 | %IN: 13 | % source - filename of the source pdf file to convert. The filename is 14 | % assumed to already have the extension ".pdf". 15 | % dest - filename of the destination eps file. The filename is assumed to 16 | % already have the extension ".eps". 17 | 18 | % Copyright (C) Oliver Woodford 2009-2010 19 | 20 | % Thanks to Aldebaro Klautau for reporting a bug when saving to 21 | % non-existant directories. 22 | 23 | function pdf2eps(source, dest) 24 | % Construct the options string for pdftops 25 | options = ['-q -paper match -eps -level2 "' source '" "' dest '"']; 26 | % Convert to eps using pdftops 27 | [status message] = pdftops(options); 28 | % Check for error 29 | if status 30 | % Report error 31 | if isempty(message) 32 | error('Unable to generate eps. Check destination directory is writable.'); 33 | else 34 | error(message); 35 | end 36 | end 37 | % Fix the DSC error created by pdftops 38 | fid = fopen(dest, 'r+'); 39 | if fid == -1 40 | % Cannot open the file 41 | return 42 | end 43 | fgetl(fid); % Get the first line 44 | str = fgetl(fid); % Get the second line 45 | if strcmp(str(1:min(13, end)), '% Produced by') 46 | fseek(fid, -numel(str)-1, 'cof'); 47 | fwrite(fid, '%'); % Turn ' ' into '%' 48 | end 49 | fclose(fid); 50 | return 51 | 52 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/TabPrint.m: -------------------------------------------------------------------------------- 1 | function OUT = TabPrint(DATA,hlabel,vlabel,approx) 2 | % ======================================================================= 3 | % Prints a numerical table with labels, with specified numbers of decimal 4 | % digits 5 | % ======================================================================= 6 | % OUT = TabPrint(DATA,hlabel,vlabel,approx) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA = a (n x m) matrix of numbers 10 | % ----------------------------------------------------------------------- 11 | % OPTIONAL INPUT 12 | % - hlabel = a (m x 1) vector of horizontal labels 13 | % - vlabel = a (1 x n) vector of vertical labels 14 | % - approx = number of decimal digits. Default = 2 15 | %-------------------------------------------------------------------------- 16 | % OUTPUT 17 | % - OUT = a cell array with the formatted table 18 | % ======================================================================= 19 | % Ambrogio Cesa Bianchi, March 2015 20 | % ambrogio.cesabianchi@gmail.com 21 | 22 | [n, m] = size(DATA); 23 | 24 | if ~exist('hlabel','var') || isempty(hlabel) 25 | hlabel = cell(1,m); 26 | end 27 | 28 | if ~exist('vlabel','var') || isempty(vlabel) 29 | vlabel = cell(n,1); 30 | end 31 | 32 | if ~exist('approx','var') 33 | approx = 2; 34 | end 35 | 36 | if length(hlabel)~=m 37 | error('ERROR: horizontal label has wrong dimension') 38 | end 39 | 40 | if length(vlabel)~=n 41 | error('ERROR: vertical label has wrong dimension') 42 | end 43 | 44 | OUT = roundnum2cell(DATA,approx); % Trasform matrix in cell wih approx decimal digits 45 | 46 | OUT = [hlabel ; OUT]; 47 | aux = cell(rows(hlabel),cols(vlabel)); 48 | vlabel = [aux; vlabel]; 49 | OUT = [vlabel, OUT]; -------------------------------------------------------------------------------- /v3dot0/Stats/MovAvgCent.m: -------------------------------------------------------------------------------- 1 | function OUT = MovAvgCent(DATA,window) 2 | % ======================================================================= 3 | % Moving average of the matrix DATA (TxN). The moving average is 4 | % compute over the interval [t-window,t+window] and it is computed down 5 | % each column. 6 | % ======================================================================= 7 | % OUT = MovAvg(DATA,window) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % DATA: T observations DATA window variables [double] 11 | % window: window of the moving average [double] 12 | % ----------------------------------------------------------------------- 13 | % OUPUT 14 | % OUT: T x N matrix (the first windows observations are NaN) [double] 15 | % ----------------------------------------------------------------------- 16 | % EXAMPLE 17 | % X = rand(20,2); 18 | % OUT = MovAvgCent(X,2) 19 | % ======================================================================= 20 | % VAR Toolbox 3.0 21 | % Ambrogio Cesa-Bianchi 22 | % ambrogiocesabianchi@gmail.com 23 | % March 2012. Updated November 2020 24 | % ----------------------------------------------------------------------- 25 | 26 | 27 | 28 | if nargin<2, error('Not enough input.'),end 29 | if window<=0,error('window must be positive.'),end 30 | if (window~=floor(window)),error('window must be an integer.'),end 31 | 32 | if min(size(DATA))==1, 33 | DATA=DATA(:); % forces DATA to be a column vector 34 | end 35 | 36 | [nobs,nvars] = size(DATA); 37 | if window>nobs, 38 | error('window must not be greater than the length of DATA.') 39 | end 40 | 41 | temp = nan(nobs,nvars); 42 | for jj = (window+1):(nobs-window), 43 | temp(jj,:) = nanmean(DATA(jj-window:jj+window,:)); 44 | end 45 | 46 | OUT = temp; -------------------------------------------------------------------------------- /v3dot0/Auxiliary/roundn.m: -------------------------------------------------------------------------------- 1 | function x = roundn(x, n) 2 | %ROUNDN Round to multiple of 10^n 3 | % 4 | % Use of ROUNDN is not recommended. Use the round(X,N) syntax of the 5 | % MATLAB ROUND function instead, but note that the sign of N is reversed: 6 | % ROUNDN(X,N) should be replaced with round(X,-N). 7 | % 8 | % ROUNDN(X,N) rounds each element of X to the nearest multiple of 10^N. 9 | % N must be scalar, and integer-valued. For complex X, the imaginary 10 | % and real parts are rounded independently. For N = 0 ROUNDN gives the 11 | % same result as round. That is, ROUNDN(X,0) == round(X). 12 | % 13 | % Examples 14 | % -------- 15 | % % Round pi to the nearest hundredth. The same result, 3.14, is returned 16 | % % by both of the following: 17 | % roundn(pi, -2) 18 | % round(pi, 2) 19 | % 20 | % % Round the equatorial radius of the Earth, 6378137 meters, 21 | % % to the nearest kilometer. Both calls return 6378000. 22 | % roundn(6378137, 3) 23 | % round(6378137, -3) 24 | % 25 | % See also ROUND. 26 | 27 | % Copyright 1996-2015 The MathWorks, Inc. 28 | 29 | % Validate inputs. (Both are required.) 30 | narginchk(2,2) 31 | validateattributes(x, {'single', 'double'}, {}, 'ROUNDN', 'X') 32 | validateattributes(n, ... 33 | {'numeric'}, {'scalar', 'real', 'integer'}, 'ROUNDN', 'N') 34 | 35 | if n < 0 36 | % Compute the inverse of the power of 10 to which input will be 37 | % rounded. Because n < 0, p will be greater than 1. 38 | p = 10 ^ -n; 39 | 40 | % Round x to the nearest multiple of 1/p. 41 | x = round(p * x) / p; 42 | elseif n > 0 43 | % Compute the power of 10 to which input will be rounded. Because 44 | % n > 0, p will be greater than 1. 45 | p = 10 ^ n; 46 | 47 | % Round x to the nearest multiple of p. 48 | x = p * round(x / p); 49 | else 50 | x = round(x); 51 | end 52 | -------------------------------------------------------------------------------- /v3dot0/Stats/MovAvg.m: -------------------------------------------------------------------------------- 1 | function OUT = MovAvg(DATA,window) 2 | % ======================================================================= 3 | % Moving average of the matrix DATA (TxN). The moving average is 4 | % computed down each column. 5 | % ======================================================================= 6 | % OUT = MovAvg(DATA,window) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % DATA: T observations x N variables [double] 10 | % window: window of the moving average [double] 11 | % ----------------------------------------------------------------------- 12 | % OUPUT 13 | % OUT: T x N matrix (the first windows-1 observations are NaN) [double] 14 | % ----------------------------------------------------------------------- 15 | % EXAMPLE 16 | % X = rand(20,2); 17 | % OUT = MovAvg(X,2) 18 | % ======================================================================= 19 | % VAR Toolbox 3.0 20 | % Ambrogio Cesa-Bianchi 21 | % ambrogiocesabianchi@gmail.com 22 | % March 2012. Updated November 2020 23 | % ----------------------------------------------------------------------- 24 | 25 | 26 | if nargin<2, error('Not enough input.'), end 27 | if window<=0, error('Window must be positive.'), end 28 | if (window~=floor(window)), error('Window must be an integer.'), end 29 | 30 | if min(size(DATA))==1 31 | DATA = DATA(:); % forces DATA to be a column vector 32 | end 33 | 34 | [nobs,nvar] = size(DATA); 35 | if window>nobs 36 | error('window must not be greater than the length of DATA.') 37 | end 38 | 39 | temp=[]; 40 | for row=1:(nobs-window+1), 41 | temp = [temp; mean(DATA(row:(row+window-1),:))]; 42 | end 43 | 44 | OUT = temp; 45 | OUT = [nan(window-1,nvar); OUT]; % add nans to make conformable to original 46 | -------------------------------------------------------------------------------- /v3dot0/Stats/MovStd.m: -------------------------------------------------------------------------------- 1 | function OUT = MovStd(DATA,window) 2 | % ======================================================================= 3 | % Moving stand. deviation of the vector (or matrix) DATA (T obs x N 4 | % variables). If DATA is a matrix moving average is computed down each 5 | % column. 6 | % ======================================================================= 7 | % OUT = MovAvg(DATA,window) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - DATA : T observations x N variables 11 | % - window: window of the moving average 12 | % ----------------------------------------------------------------------- 13 | % OUPUT 14 | % - OUT: T observations x N variables matrix (the first window-1 15 | % observations are NaN) 16 | % ----------------------------------------------------------------------- 17 | % EXAMPLE 18 | % DATA = rand(50,4); 19 | % OUT = MovStd(DATA,2) 20 | % ======================================================================= 21 | % VAR Toolbox 3.0 22 | % Ambrogio Cesa-Bianchi 23 | % ambrogiocesabianchi@gmail.com 24 | % March 2012. Updated November 2020 25 | % ----------------------------------------------------------------------- 26 | 27 | 28 | if nargin<2, error('Not enough input.'), end 29 | if window<=0, error('window must be positive.'), end 30 | if (window~=floor(window)), error('window must be an integer.'), end 31 | 32 | if min(size(DATA))==1 33 | DATA = DATA(:); % forces DATA to be a column vector 34 | end 35 | 36 | [nobs,nvar] = size(DATA); 37 | if window>nobs 38 | error('window must not be greater than the length of DATA.') 39 | end 40 | 41 | temp = []; 42 | for row=1:(nobs-window+1) 43 | temp = [temp; std(DATA(row:(row+window-1),:))]; 44 | end 45 | 46 | OUT = temp; 47 | OUT = [nan(window-1,nvar); OUT]; % add nans to make conformable to original -------------------------------------------------------------------------------- /v3dot0/Stats/MovSum.m: -------------------------------------------------------------------------------- 1 | function OUT = MovSum(DATA,window) 2 | % ======================================================================= 3 | % Moving sum of the vector (or matrix) DATA (T obs x N variables). If 4 | % DATA is a matrix moving sum is computed down each column. 5 | % ======================================================================= 6 | % OUT = MovAvg(DATA,window) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % DATA: T observations x N variables 10 | % window: window of the moving sum 11 | % ----------------------------------------------------------------------- 12 | % OUPUT 13 | % OUT: T observations x N variables matrix (the first windows-1 14 | % obseravations are NaN) 15 | % ----------------------------------------------------------------------- 16 | % EXAMPLE 17 | % DATA = rand(50,4); 18 | % OUT = OUT = MovSum(DATA,2) 19 | % ======================================================================= 20 | % VAR Toolbox 3.0 21 | % Ambrogio Cesa-Bianchi 22 | % ambrogiocesabianchi@gmail.com 23 | % March 2012. Updated November 2020 24 | % ----------------------------------------------------------------------- 25 | 26 | 27 | if nargin<2, error('Not enough input.'), end 28 | if window<=0, error('window must be positive.'), end 29 | if (window~=floor(window)), error('window must be an integer.'), end 30 | 31 | if min(size(DATA))==1 32 | DATA = DATA(:); % forces DATA to be a column vector 33 | end 34 | 35 | [nobs,nvar] = size(DATA); 36 | if window>nobs 37 | error('window must not be greater than the length of DATA.') 38 | end 39 | 40 | temp=[]; 41 | for row=1:(nobs-window+1) 42 | temp = [temp; sum(DATA(row:(row+window-1),:))]; 43 | end 44 | 45 | OUT = temp; 46 | OUT = [nan(window-1,nvar); OUT]; % add nans to make conformable to original 47 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/PlotLineOption.m: -------------------------------------------------------------------------------- 1 | function opt = PlotLineOption 2 | % ======================================================================= 3 | % Optional inputs for PlotLine 4 | % ======================================================================= 5 | % Ambrogio Cesa Bianchi, March 2015 6 | % ambrogio.cesabianchi@gmail.com 7 | 8 | opt.row = 3; % rows for subplot 9 | opt.col = 4; % columns for subplot 10 | opt.fo = []; % first observation (1989Q2 => 1989.25) 11 | opt.frequency = 'q'; % frequency 'q' quarterly, 'y' annual 12 | opt.nticks = 5; % number of ticks on x axis 13 | opt.ynames = {}; % variable names in DATA(nobs,y,z) 14 | opt.znames = {}; % variable names in DATA(nobs,y,z) 15 | opt.do_x = 1; % plot x axis 16 | opt.LineWidth = [3 1 1 1]; % line width 17 | opt.LineStyle = {'-', '--', '-', ':'}; % line style 18 | opt.LineColor = {'slightly dark red';... % line color 19 | 'slightly light blue';... 20 | 'dark grey'; 'grey'}; 21 | opt.grid = 0; % plot grid 22 | opt.box = 0; % plot box 23 | opt.interpr = 'None'; % Change to Latex if needed 24 | opt.fontsize = 11; % font size for charts 25 | opt.x_label = {}; % label x axis 26 | opt.y_label = {}; % label y axis 27 | opt.compare = 0; % set to 1 to compare panels 28 | opt.savename = 'FIG'; % figname 29 | opt.quality = 0; % set to 1 for high quality 30 | opt.bins = 40; % number of bins for HistfitPlot 31 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/pdf2eps.m: -------------------------------------------------------------------------------- 1 | %PDF2EPS Convert a pdf file to eps format using pdftops 2 | % 3 | % Examples: 4 | % pdf2eps source dest 5 | % 6 | % This function converts a pdf file to eps format. 7 | % 8 | % This function requires that you have pdftops, from the Xpdf suite of 9 | % functions, installed on your system. This can be downloaded from: 10 | % http://xpdfreader.com 11 | % 12 | % Inputs: 13 | % source - filename of the source pdf file to convert. The filename is 14 | % assumed to already have the extension ".pdf". 15 | % dest - filename of the destination eps file. The filename is assumed to 16 | % already have the extension ".eps". 17 | 18 | % Copyright (C) Oliver Woodford 2009-2010, Yair Altman 2015- 19 | 20 | % Thanks to Aldebaro Klautau for reporting a bug when saving to 21 | % non-existant directories. 22 | 23 | % 22/09/2018 - Xpdf website changed to xpdfreader.com 24 | 25 | function pdf2eps(source, dest) 26 | % Construct the options string for pdftops 27 | options = ['-q -paper match -eps -level2 "' source '" "' dest '"']; 28 | 29 | % Convert to eps using pdftops 30 | [status, message] = pdftops(options); 31 | 32 | % Check for error 33 | if status 34 | % Report error 35 | if isempty(message) 36 | error('Unable to generate eps. Check destination directory is writable.'); 37 | else 38 | error(message); 39 | end 40 | end 41 | 42 | % Fix the DSC error created by pdftops 43 | fid = fopen(dest, 'r+'); 44 | if fid == -1 45 | % Cannot open the file 46 | return 47 | end 48 | fgetl(fid); % Get the first line 49 | str = fgetl(fid); % Get the second line 50 | if strcmp(str(1:min(13, end)), '% Produced by') 51 | fseek(fid, -numel(str)-1, 'cof'); 52 | fwrite(fid, '%'); % Turn ' ' into '%' 53 | end 54 | fclose(fid); 55 | end 56 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/XoX.m: -------------------------------------------------------------------------------- 1 | function OUT = XoX(DATA,frequency,type) 2 | % ======================================================================= 3 | % Compute the rate of change of a panel of time series (DATA, T obs x N 4 | % countries) at quarterly or annual frequency 5 | % ======================================================================= 6 | % OUT = XoX(DATA,frequency,type) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA: matrix DATA(T,N) 10 | % - frequency: 1 for X(t)-X(t-1); 4 for X(t)-X(t-4); etc... 11 | % ----------------------------------------------------------------------- 12 | % OPTIONAL INPUT 13 | % - type: 'logdiff', computes log(X(t))-log(X(t-1)) [DEFAULT] 14 | % 'diff' , computes X(t)-X(t-1) 15 | % 'rate' , computes X(t)/X(t-1)-1 16 | % ----------------------------------------------------------------------- 17 | % OUTPUT 18 | % - OUT: matrix DATA(T,N) of rates of change. The first # (=frequency) 19 | % observations are NaN 20 | % ========================================================================= 21 | % Ambrogio Cesa Bianchi, March 2015 22 | % ambrogiocesabianchi@gmail.com 23 | %------------------------------------------------------------------------- 24 | 25 | if ~exist('type','var') 26 | type = 'logdiff'; 27 | end 28 | 29 | [nobs, nvar] = size(DATA); 30 | 31 | if frequency>nobs 32 | error('Frequency is larger than the number of observations') 33 | end 34 | 35 | 36 | if strcmp(type,'logdiff') 37 | OUT = log(DATA(1+frequency:end,:))-log(DATA(1:end-frequency,:)); 38 | OUT = [nan(frequency,nvar); OUT]; 39 | elseif strcmp(type,'rate') 40 | OUT = DATA(1+frequency:end,:)./DATA(1:end-frequency,:)-1; 41 | OUT = [nan(frequency,nvar); OUT]; 42 | elseif strcmp(type,'diff') 43 | OUT = DATA(1+frequency:end,:) - DATA(1:end-frequency,:); 44 | OUT = [nan(frequency,nvar); OUT]; 45 | end 46 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/CommonSample.m: -------------------------------------------------------------------------------- 1 | function [OUT, fo, lo] = CommonSample(DATA,dim) 2 | % ======================================================================= 3 | % If a row of DATA contains a NaN, the row is removed. If dim=2, if a 4 | % column of DATA contains a NaN, the column is removed. 5 | % ======================================================================= 6 | % [OUT, lo, fo] = CommonSample(DATA) 7 | % - OUT: common sample matrix 8 | % - lo : number of NaNs at the beginning 9 | % - fo : number of NaNs at the end 10 | % ----------------------------------------------------------------------- 11 | % INPUT 12 | % - DATA: matrix DATA(i,j) 13 | % ----------------------------------------------------------------------- 14 | % OPTIONAL INPUT 15 | % - dim: default 1, change to 2 to CommonSample by column 16 | % ========================================================================= 17 | % Ambrogio Cesa Bianchi, March 2015 18 | %------------------------------------------------------------------------- 19 | 20 | % If no dimension is specified, set it to 1 21 | if ~exist('dim','var') 22 | dim = 1; 23 | end 24 | 25 | fo = 0; 26 | lo = 0; 27 | 28 | if dim==1 29 | temp = sum(DATA,2); 30 | ii = 1; 31 | if isnan(temp(ii)) 32 | while isnan(temp(ii)) 33 | fo = fo+1; 34 | ii = ii+1; 35 | if ii>length(temp) 36 | break 37 | end 38 | end 39 | end 40 | for ii=1:rows(DATA)-fo 41 | if isnan(temp(end+1-ii)) 42 | lo = lo+1; 43 | end 44 | end 45 | DATA(any(isnan(DATA),2),:) = []; 46 | else 47 | temp = sum(DATA,1); 48 | ii = 1; 49 | if isnan(temp(ii)) 50 | while isnan(temp(ii)) 51 | fo = fo+1; 52 | ii = ii+1; 53 | end 54 | end 55 | for ii=1:cols(DATA)-fo 56 | if isnan(temp(end+1-ii)) 57 | lo = lo+1; 58 | end 59 | end 60 | DATA(:,any(isnan(DATA),1)) = []; 61 | end 62 | 63 | OUT = DATA; 64 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Utils/TreatData.m: -------------------------------------------------------------------------------- 1 | function out = TreatData(data,treat,vnames,dates,DatesOpt) 2 | % ======================================================================= 3 | % Treat data. 4 | % ======================================================================= 5 | % [nobs, dates] = CountDate(fo_year,lo_year,frequency,fo_period,lo_period) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - data: structure where the the data is stored 9 | % - treat: vector (of length N) with type of treatment 10 | % - vnames: vector (of length N) with variable names 11 | % ----------------------------------------------------------------------- 12 | % OUTPUT 13 | % - out: matrix of treated data 14 | % ======================================================================= 15 | % Ambrogio Cesa Bianchi, March 2015 16 | % ambrogio.cesabianchi@gmail.com 17 | 18 | % Retrieve some parameters 19 | nobs = DatesOpt.nobs; 20 | fo_year = DatesOpt.fo_year; 21 | lo_year = DatesOpt.lo_year; 22 | frequency = DatesOpt.frequency; 23 | fo_period = DatesOpt.fo_period; 24 | lo_period = DatesOpt.lo_period; 25 | 26 | % Get first 27 | if strcmp(frequency,'y') 28 | aux = num2str(fo_year); 29 | else 30 | aux = [num2str(fo_year) frequency num2str(fo_period)]; 31 | end 32 | fo = find(strcmp(aux,dates)); 33 | 34 | % Get last 35 | if strcmp(frequency,'y') 36 | aux = num2str(lo_year); 37 | else 38 | aux = [num2str(lo_year) frequency num2str(lo_period)]; 39 | end 40 | lo = find(strcmp(aux,dates)); 41 | 42 | % Initialize matrix 43 | nvar = length(vnames); 44 | out = nan(nobs,nvar); 45 | 46 | for ii=1:nvar 47 | % No treatment 48 | if treat(ii)==0 49 | out(:,ii) = data.(vnames{ii})(fo:lo); 50 | % Log 51 | elseif treat(ii)==1 52 | out(:,ii) = log(data.(vnames{ii})(fo:lo)); 53 | % Log-diff 54 | elseif treat(ii)==2 55 | out(:,ii) = XoX(data.(vnames{ii})(fo:lo),1,'logdiff'); 56 | % Diff 57 | elseif treat(ii)==3 58 | out(:,ii) = XoX(data.(vnames{ii})(fo:lo),1,'diff'); 59 | end 60 | end -------------------------------------------------------------------------------- /v3dot0/VAR/VARdrawpost_backup.m: -------------------------------------------------------------------------------- 1 | function [sigma_draw, Ft_draw] = VARdrawpost(VAR) 2 | % ======================================================================= 3 | % Draw from the posterior distribution of a VAR model 4 | % ======================================================================= 5 | % [sigma_draw, Ft_draw] = VARdrawpost(VAR) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - VAR: structure, result of VARmodel function 9 | % ----------------------------------------------------------------------- 10 | % OUPUT 11 | % - sigma_draw: draw from the posterior of VCV matrix of VAR residuals 12 | % - Ft_draw: draw from the posterior of Ft of VAR 13 | % ----------------------------------------------------------------------- 14 | % EXAMPLE 15 | % - See VARToolbox_Code.m in "../Primer/" 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | 24 | %% Get relevant parameters from VAR structure 25 | %=============================================== 26 | nobs = VAR.nobs; 27 | k = []; 28 | nvar = VAR.nvar; 29 | X = VAR.X; 30 | 31 | 32 | %% OLS estimates 33 | %============================================ 34 | Ft_hat = VAR.Ft; 35 | sigma_hat = VAR.sigma; 36 | inv_sigma_hat = inv(sigma_hat); 37 | 38 | 39 | %% Draw the VCV matrix (sigma) 40 | %============================================ 41 | inv_sigma_draw = wishrnd(inv_sigma_hat/nobs,nobs); 42 | sigma_draw = inv(inv_sigma_draw); 43 | 44 | %% Draw the coeffiecient matrix (Ft) 45 | %============================================ 46 | % Compute VCV of coefficient matrix 47 | aux1 = (X'*X)\eye(size(X,2)); 48 | aux2 = kron(sigma_draw, aux1); 49 | aux2 = (aux2 + aux2')/2; % Force symmetry (due to numerical error) 50 | Fthat_vec = Ft_hat(:); 51 | Ftdraw = mvnrnd(Fthat_vec,aux2); 52 | Ft_draw = reshape(Ftdraw,k,nvar); 53 | -------------------------------------------------------------------------------- /v3dot0/Figure/PlotLineOption.m: -------------------------------------------------------------------------------- 1 | function opt = PlotLineOption 2 | % ======================================================================= 3 | % Optional inputs for PlotLine 4 | % ======================================================================= 5 | % VAR Toolbox 3.0 6 | % Ambrogio Cesa-Bianchi 7 | % ambrogiocesabianchi@gmail.com 8 | % March 2015. Updated November 2020 9 | % ----------------------------------------------------------------------- 10 | 11 | opt.row = 3; % rows for subplot 12 | opt.col = 4; % columns for subplot 13 | opt.fo = []; % first observation (1989Q2 => 1989.25) 14 | opt.frequency = 'q'; % frequency 'q' quarterly, 'y' annual 15 | opt.nticks = 5; % number of ticks on x axis 16 | opt.ynames = {}; % variable names in DATA(nobs,y,z) 17 | opt.znames = {}; % variable names in DATA(nobs,y,z) 18 | opt.do_x = 1; % plot x axis 19 | opt.LineWidth = [3 1 1 1]; % line width 20 | opt.LineStyle = {'-', '--', '-', ':'}; % line style 21 | opt.LineColor = {'slightly dark red';... % line color 22 | 'slightly light blue';... 23 | 'dark grey'; 'grey'}; 24 | opt.grid = 0; % plot grid 25 | opt.box = 0; % plot box 26 | opt.interpr = 'None'; % Change to Latex if needed 27 | opt.fontsize = 11; % font size for charts 28 | opt.x_label = {}; % label x axis 29 | opt.y_label = {}; % label y axis 30 | opt.compare = 0; % set to 1 to compare panels 31 | opt.savename = 'FIG'; % figname 32 | opt.quality = 0; % set to 1 for high quality 33 | opt.bins = 40; % number of bins for HistfitPlot 34 | opt.SupTitle = []; % Title of figure 35 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/VARmakexy.m: -------------------------------------------------------------------------------- 1 | function [Y, X] = VARmakexy(DATA,lags,const) 2 | % ======================================================================= 3 | % Builds the VAR process from the data-matrix DATA. It orders the data into 4 | % the Y and X matrix --> Example: [x y] = [x(-1) y(-1) x(-2) y(-2)] 5 | % ======================================================================= 6 | % [Y, X] = VARmakexy(DATA, lags, const) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % DATA: matrix containing the original data 10 | % lags: lag order of the VAR 11 | % const : 0, no constant, no trend 12 | % 1, constant, no trend 13 | % 2, constant, trend 14 | % 3, constant, trend, trend^2 15 | % ----------------------------------------------------------------------- 16 | % OUTPUT 17 | % Y: dependent variable 18 | % X: independent variable 19 | % ======================================================================= 20 | % Ambrogio Cesa Bianchi, March 2015 21 | % ambrogio.cesabianchi@gmail.com 22 | 23 | 24 | % Get dimesion of DATA 25 | [nobs, ~]= size(DATA); 26 | 27 | % Y matrix 28 | Y = DATA(lags+1:end,:); 29 | 30 | % X-matrix 31 | if const==0 32 | X=[]; 33 | for jj=0:lags-1 34 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 35 | end 36 | 37 | elseif const==1 %constant 38 | X = []; 39 | for jj=0:lags-1 40 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 41 | end 42 | X = [ones(nobs-lags,1) X]; 43 | 44 | elseif const==2 % time trend and constant 45 | X = []; 46 | for jj=0:lags-1 47 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 48 | end 49 | trend=1:size(X,1); 50 | X = [ones(nobs-lags,1) trend' X]; 51 | 52 | elseif const==3 % squared time trend, linear time trend, and constant 53 | X = []; 54 | for jj=0:lags-1 55 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 56 | end 57 | trend=1:size(X,1); 58 | X = [ones(nobs-lags,1) trend' (trend').^2 X]; 59 | end 60 | -------------------------------------------------------------------------------- /v3dot0/Utils/TabPrint.m: -------------------------------------------------------------------------------- 1 | function OUT = TabPrint(DATA,hlabel,vlabel,approx) 2 | % ======================================================================= 3 | % Prints a numerical table with labels, with specified numbers of decimal 4 | % digits 5 | % ======================================================================= 6 | % OUT = TabPrint(DATA,hlabel,vlabel,approx) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA = a (TxN) matrix of numbers 10 | % ----------------------------------------------------------------------- 11 | % OPTIONAL INPUT 12 | % - hlabel = a (Tx1) vector of horizontal labels 13 | % - vlabel = a (1xT) vector of vertical labels 14 | % - approx = number of decimal digits. Default = 2 15 | % ----------------------------------------------------------------------- 16 | % OUTPUT 17 | % - OUT = a cell array with the formatted table 18 | % ----------------------------------------------------------------------- 19 | % EXAMPLE 20 | % x = [1 2; 3 4; 5 6; 7 8; 9 10]; 21 | % hlab = {'a';'b';'c';'d';'e';} 22 | % vlab = {'A','B'} 23 | % OUT = TabPrint(x,hlab,vlab) 24 | % ======================================================================= 25 | % VAR Toolbox 3.0 26 | % Ambrogio Cesa-Bianchi 27 | % ambrogiocesabianchi@gmail.com 28 | % March 2012. Updated November 2020 29 | % ----------------------------------------------------------------------- 30 | 31 | [n, m] = size(DATA); 32 | 33 | if ~exist('hlabel','var') || isempty(hlabel) 34 | hlabel = cell(1,m); 35 | end 36 | 37 | if ~exist('vlabel','var') || isempty(vlabel) 38 | vlabel = cell(n,1); 39 | end 40 | 41 | if ~exist('approx','var') 42 | approx = 2; 43 | end 44 | 45 | if length(hlabel)~=m 46 | error('ERROR: horizontal label has wrong dimension') 47 | end 48 | 49 | if length(vlabel)~=n 50 | error('ERROR: vertical label has wrong dimension') 51 | end 52 | 53 | OUT = roundnum2cell(DATA,approx); % Trasform matrix in cell wih approx decimal digits 54 | 55 | OUT = [hlabel ; OUT]; 56 | aux = cell(rows(hlabel),cols(vlabel)); 57 | vlabel = [aux; vlabel]; 58 | OUT = [vlabel, OUT]; -------------------------------------------------------------------------------- /v3dot0/Utils/XoX.m: -------------------------------------------------------------------------------- 1 | function OUT = XoX(DATA,frequency,type) 2 | % ======================================================================= 3 | % Compute the rate of change of a panel of time series (DATA, T obs x N 4 | % countries) at quarterly or annual frequency 5 | % ======================================================================= 6 | % OUT = XoX(DATA,frequency,type) 7 | % NOT SUPPORTED ANYMORE 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - DATA: matrix DATA(T,N) 11 | % - frequency: 1 for X(t)-X(t-1); 4 for X(t)-X(t-4); etc... 12 | % ----------------------------------------------------------------------- 13 | % OPTIONAL INPUT 14 | % - type: 'logdiff', computes log(X(t))-log(X(t-1)) [DEFAULT] 15 | % 'diff' , computes X(t)-X(t-1) 16 | % 'rate' , computes X(t)/X(t-1)-1 17 | % ----------------------------------------------------------------------- 18 | % OUTPUT 19 | % - OUT: matrix DATA(T,N) of rates of change. The first # (=frequency) 20 | % observations are NaN 21 | % ----------------------------------------------------------------------- 22 | % EXAMPLE 23 | % x = [1 2; -3 4; 5 6; 7 8; 9 10]; 24 | % OUT = XoX(x,1,'diff') 25 | % ======================================================================= 26 | % VAR Toolbox 3.0 27 | % Ambrogio Cesa-Bianchi 28 | % ambrogiocesabianchi@gmail.com 29 | % March 2012. Updated November 2020 30 | % ----------------------------------------------------------------------- 31 | 32 | if ~exist('type','var') 33 | type = 'logdiff'; 34 | end 35 | 36 | [nobs, nvar] = size(DATA); 37 | 38 | if frequency>nobs 39 | error('Frequency is larger than the number of observations') 40 | end 41 | 42 | if strcmp(type,'logdiff') 43 | OUT = log(DATA(1+frequency:end,:))-log(DATA(1:end-frequency,:)); 44 | OUT = [nan(frequency,nvar); OUT]; 45 | elseif strcmp(type,'rate') 46 | OUT = DATA(1+frequency:end,:)./DATA(1:end-frequency,:)-1; 47 | OUT = [nan(frequency,nvar); OUT]; 48 | elseif strcmp(type,'diff') 49 | OUT = DATA(1+frequency:end,:) - DATA(1:end-frequency,:); 50 | OUT = [nan(frequency,nvar); OUT]; 51 | end 52 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/FigFont.m: -------------------------------------------------------------------------------- 1 | function FigFont(opt) 2 | % ======================================================================= 3 | % Set font in a figure to desired font size and font style 4 | % ======================================================================= 5 | % FigFont(opt) 6 | % ----------------------------------------------------------------------- 7 | % OPTIONAL INPUT 8 | % - opt: output of FigFontOption(fsize) 9 | % ======================================================================= 10 | % Ambrogio Cesa Bianchi, March 2015 11 | % ambrogio.cesabianchi@gmail.com 12 | 13 | 14 | %% CHECK INPUT 15 | % ======================================================================= 16 | if ~exist('opt','var') 17 | opt = FigFontOption; 18 | end 19 | 20 | 21 | %% SET FONT STYLE 22 | % ======================================================================= 23 | % AXES 24 | aux = findobj(gcf,'Type','axes'); 25 | set(aux,'Fontsize',opt.axes_size,'FontWeight',opt.axes_weight,'FontName',opt.axes_name); 26 | 27 | % TITLES 28 | if max(size(aux))==1 29 | aux = get(aux, 'title'); 30 | set(aux,'Fontsize',opt.title_size,'FontWeight',opt.title_weight,'FontName',opt.title_name); 31 | else 32 | aux1 = get(aux(1), 'title'); 33 | set(aux1, 'Fontsize', opt.title_size,'FontWeight',opt.title_weight,'FontName',opt.title_name); 34 | aux2 = get(aux(2), 'title'); 35 | set(aux2, 'Fontsize',opt.title_size,'FontWeight',opt.title_weight,'FontName',opt.title_name); 36 | end 37 | 38 | % SUPTITLE 39 | aux = findobj(gcf,'tag','suptitleText'); 40 | set(aux,'Fontsize',opt.suptitle_size,'FontWeight',opt.suptitle_weight,'FontName',opt.suptitle_name); 41 | 42 | % LEGEND 43 | aux = findobj(gcf,'Type','axes','Tag','legend'); 44 | set(aux,'Fontsize',opt.legend_size, 'FontWeight',opt.legend_weight,'FontName',opt.legend_name); 45 | 46 | % Y LABEL 47 | aux = get(gca,'YLabel'); 48 | if isempty(aux)~=1 49 | set(aux,'Fontsize',opt.ylabel_size, 'FontWeight',opt.ylabel_weight,'FontName',opt.ylabel_name); 50 | end 51 | 52 | % X LABEL 53 | aux = get(gca,'XLabel'); 54 | if isempty(aux)~=1 55 | set(aux,'Fontsize',opt.xlabel_size, 'FontWeight',opt.xlabel_weight,'FontName',opt.xlabel_name); 56 | end -------------------------------------------------------------------------------- /v3dot0/Figure/Date2Cell.m: -------------------------------------------------------------------------------- 1 | function OUT = Date2Cell(dates,frequency) 2 | % ========================================================================= 3 | % Convert a double array of dates into a cell array. The first period of 4 | % the year is coded as a round number. 5 | % ======================================================================= 6 | % OUT = Date2Cell(DATA) 7 | % ----------------------------------------------------------------------- 8 | % INPUTS 9 | % - DATA: a (T x 1) vector with dates in double format 10 | % ----------------------------------------------------------------------- 11 | % OPTIONAL INPUT 12 | % - frequency : monthly ('m'), quarterly ('q') [dflt] or annual ('y') 13 | % ----------------------------------------------------------------------- 14 | % OUTPUT 15 | % - OUT: a (T x 1) vector with dates in string format 16 | % ----------------------------------------------------------------------- 17 | % EXAMPLE 18 | % dates = [1992; 1992.25; 1992.5'; 1992.75; 1993]; 19 | % OUT = Date2Cell(dates,'q') 20 | % ----------------------------------------------------------------------- 21 | % RELATED 22 | % - Dates2Num, DatesCreate, DatesCount 23 | % ======================================================================= 24 | % VAR Toolbox 3.0 25 | % Ambrogio Cesa-Bianchi 26 | % ambrogiocesabianchi@gmail.com 27 | % August 2021 28 | % ----------------------------------------------------------------------- 29 | 30 | % Stops Matlab from showing exponentials 31 | format long g 32 | 33 | % Check inputs 34 | if ~exist('frequency','var') 35 | frequency = 'q'; 36 | end 37 | [r,c] = size(dates); 38 | 39 | % Convert cell array into double array 40 | if strcmp(frequency,'q') 41 | OUT = {}; 42 | for i=1:r 43 | for j=1:c 44 | year = floor(dates(i,j)); 45 | period = 4*(dates(i,j)-year)+1; 46 | OUT{i,j} = [num2str(year) 'Q' num2str(period)]; 47 | end 48 | end 49 | elseif strcmp(frequency,'m') 50 | OUT = {}; 51 | for i=1:r 52 | for j=1:c 53 | year = floor(dates(i,j)); 54 | period = 12*(dates(i,j)-year)+1; 55 | OUT{i,j} = [num2str(year) 'M' num2str(period)]; 56 | end 57 | end 58 | end -------------------------------------------------------------------------------- /v3dot0/VAR/VARdrawpost.m: -------------------------------------------------------------------------------- 1 | function [sigma_draw, Ft_draw, F_draw, Fcomp_draw] = VARdrawpost(VAR) 2 | % ======================================================================= 3 | % Draw from the posterior distribution of a VAR model 4 | % ======================================================================= 5 | % [sigma_draw, Ft_draw] = VARdrawpost(VAR) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - VAR: structure, result of VARmodel function 9 | % ----------------------------------------------------------------------- 10 | % OUPUT 11 | % - sigma_draw: draw from the posterior of VCV matrix of VAR residuals 12 | % - Ft_draw: draw from the posterior of Ft of VAR 13 | % ----------------------------------------------------------------------- 14 | % EXAMPLE 15 | % - See VARToolbox_Code.m in "../Primer/" 16 | % ======================================================================= 17 | % VAR Toolbox 3.0 18 | % Ambrogio Cesa-Bianchi 19 | % ambrogiocesabianchi@gmail.com 20 | % March 2012. Updated November 2020 21 | % ----------------------------------------------------------------------- 22 | 23 | 24 | %% Get relevant parameters from VAR structure 25 | %=============================================== 26 | nobs = VAR.nobs; 27 | k = []; 28 | X = VAR.X; 29 | const= VAR.const; 30 | nvar = VAR.nvar; 31 | nlag = VAR.nlag; 32 | 33 | 34 | %% OLS estimates 35 | %============================================ 36 | Ft_hat = VAR.Ft; 37 | sigma_hat = VAR.sigma; 38 | inv_sigma_hat = inv(sigma_hat); 39 | 40 | 41 | %% Draw the VCV matrix (sigma) 42 | %============================================ 43 | inv_sigma_draw = wishrnd(inv_sigma_hat/nobs,nobs); 44 | sigma_draw = inv(inv_sigma_draw); 45 | 46 | %% Draw the coeffiecient matrix (Ft) 47 | %============================================ 48 | % Compute VCV of coefficient matrix 49 | aux1 = (X'*X)\eye(size(X,2)); 50 | aux2 = kron(sigma_draw, aux1); 51 | aux2 = (aux2 + aux2')/2; % Force symmetry (might fail bc of numerical error) 52 | Fthat_vec = Ft_hat(:); 53 | Ftdraw = mvnrnd(Fthat_vec,aux2); 54 | Ft_draw = reshape(Ftdraw,k,nvar); 55 | F_draw = Ft_draw'; 56 | Fcomp_draw = [F_draw(:,1+const:nvar*nlag+const); eye(nvar*(nlag-1)) zeros(nvar*(nlag-1),nvar)]; 57 | 58 | -------------------------------------------------------------------------------- /v3dot0/Stats/CorrTable.m: -------------------------------------------------------------------------------- 1 | function [CORR, TABLE] = CorrTable(x,vnames,pairwise) 2 | % ======================================================================= 3 | % Computes the correlation matrix of a matrix of time series with titles 4 | % ======================================================================= 5 | % out = CorrTable(x,vnames) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - x: matrix (rows x cols) [double] 9 | % - vnames: array (1 x cols) with names of the (cols) series [cell] 10 | % ----------------------------------------------------------------------- 11 | % OPTIONAL INPUT 12 | % - pairwise: default 0, change to 1 to compute pairwise correlations 13 | % ----------------------------------------------------------------------- 14 | % OUTPUT 15 | % - CORR: correlation matrix [double] 16 | % - TABLE: table of correlation matrix with titles [cell] 17 | % ----------------------------------------------------------------------- 18 | % EXAMPLE 19 | % x = rand(50,2); 20 | % [CORR, TABLE] = CorrTable(x,{'Consumption','Investment'}) 21 | % ======================================================================= 22 | % VAR Toolbox 3.0 23 | % Ambrogio Cesa-Bianchi 24 | % ambrogiocesabianchi@gmail.com 25 | % March 2015. Updated November 2020 26 | % ----------------------------------------------------------------------- 27 | 28 | % If no dimension is specified, set it to 1 29 | if ~exist('pairwise','var') 30 | pairwise = 0; 31 | end 32 | 33 | % vnames must be a row vector 34 | if size(vnames,1)>1 35 | vnames = vnames'; 36 | end 37 | 38 | % Compute correlation 39 | if pairwise==0 40 | CORR = corr(x); 41 | elseif pairwise==1 42 | CORR = corr(x,'rows','pairwise'); 43 | end 44 | [r, ~] = size(CORR); 45 | 46 | % Place NaNs on the upper triangular 47 | CORR(find(triu(CORR))) = NaN; 48 | jj = 1; 49 | for ii=1:r 50 | CORR(ii,jj) = 1; 51 | jj = jj +1; 52 | end 53 | 54 | % Save position of NaNs 55 | nans = isnan(CORR); 56 | 57 | % Transform table into cell array 58 | TAB = num2cell(CORR); 59 | 60 | % Add vnames on top 61 | TAB = [vnames ; TAB]; 62 | 63 | % Add vnames on the left 64 | aux = [{''} vnames]'; 65 | TABLE = [aux TAB]; 66 | 67 | % Print using mprint 68 | info.cvnames = char(vnames); 69 | info.rvnames = char([{' '} vnames]); 70 | mprint(CORR,info); -------------------------------------------------------------------------------- /v3dot0/ExportFig/copyfig.m: -------------------------------------------------------------------------------- 1 | function fh = copyfig(fh) 2 | %COPYFIG Create a copy of a figure, without changing the figure 3 | % 4 | % Examples: 5 | % fh_new = copyfig(fh_old) 6 | % 7 | % This function will create a copy of a figure, but not change the figure, 8 | % as copyobj sometimes does, e.g. by changing legends. 9 | % 10 | % IN: 11 | % fh_old - The handle of the figure to be copied. Default: gcf. 12 | % 13 | % OUT: 14 | % fh_new - The handle of the created figure. 15 | 16 | % Copyright (C) Oliver Woodford 2012, Yair Altman 2015 17 | 18 | % 26/02/15: If temp dir is not writable, use the dest folder for temp 19 | % destination files (Javier Paredes) 20 | % 15/04/15: Suppress warnings during copyobj (Dun Kirk comment on FEX page 2013-10-02) 21 | % 09/09/18: Fix issue #252: Workaround for cases where copyobj() fails for any reason 22 | 23 | % Set the default 24 | if nargin == 0 25 | fh = gcf; 26 | end 27 | % Is there a legend? 28 | useCopyobj = isempty(findall(fh, 'Type', 'axes', 'Tag', 'legend')); 29 | if useCopyobj 30 | % Safe to copy using copyobj 31 | oldWarn = warning('off'); %Suppress warnings during copyobj (Dun Kirk comment on FEX page 2013-10-02) 32 | try 33 | fh = copyobj(fh, 0); 34 | catch 35 | % Fix issue #252: Workaround for cases where copyobj() fails for any reason 36 | useCopyobj = false; % if copyobj() croaks, use file save/load below 37 | end 38 | warning(oldWarn); 39 | end 40 | if ~useCopyobj 41 | % copyobj will change the figure, so save and then load it instead 42 | tmp_nam = [tempname '.fig']; 43 | try 44 | % Ensure that the temp dir is writable (Javier Paredes 26/2/15) 45 | fid = fopen(tmp_nam,'w'); 46 | fwrite(fid,1); 47 | fclose(fid); 48 | delete(tmp_nam); % cleanup 49 | catch 50 | % Temp dir is not writable, so use the current folder 51 | [dummy,fname,fext] = fileparts(tmp_nam); %#ok 52 | fpath = pwd; 53 | tmp_nam = fullfile(fpath,[fname fext]); 54 | end 55 | hgsave(fh, tmp_nam); 56 | fh = hgload(tmp_nam); 57 | delete(tmp_nam); 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /v3dot0/ExportFig/hyperlink.m: -------------------------------------------------------------------------------- 1 | function str = hyperlink(url, label, msg) 2 | %HYPERLINK create a string that is displayable as hyperlink in Matlab console 3 | % 4 | % Usage examples: 5 | % fprintf('Search on %s\n', hyperlink('http://google.com','Google')); 6 | % fprintf(hyperlink('http://google.com','Google','Search on Google\n')); 7 | % 8 | % HYPERLINK converts the specified URL and text label into a string that is 9 | % displayed as a hyperlink in the Matlab console (Command Window). 10 | % In a deployed (compiled) program, the URL and text label (if different 11 | % from the URL) are displayed in a non-hyperlinked plain-text manner. 12 | % If the optional 3rd input argument (msg) is specified, then all instances of 13 | % the specified label within msg will be handled as above (hyperlinked etc.) 14 | % 15 | % IN: 16 | % url - (mandatory) URL of webpage or Matlab command (e.g., 'matlab:which(...') 17 | % label - (optional) text label of the hyperlink. Default: url 18 | % msg - (optional) string in which all label instances should be hyperlinked 19 | % 20 | % OUT: 21 | % str - string output 22 | 23 | % Copyright: Yair Altman 2020- 24 | %{ 25 | % 15/01/20 - Initial version 26 | %} 27 | 28 | error(nargchk(1,3,nargin)); %#ok narginchk is only available in R2011b+ 29 | if nargin > 2 % msg was specified 30 | % replace all instances of label within msg with corresponding hyperlink 31 | str = strrep(msg, label, hyperlink(url,label)); 32 | return 33 | end 34 | if nargin < 2, label = url; end 35 | isWebpage = strncmpi(url,'http',4); 36 | 37 | % Only hyperlink in interactive Matlab sessions, not in a deployed program 38 | if ~isdeployed % interactive Matlab session 39 | if isWebpage % open in a web browser 40 | str = ['' label '']; 41 | else % Matlab command e.g. 'matlab:which(...' 42 | str = ['' label '']; 43 | end 44 | else % deployed (compiled) 45 | if isWebpage && ~strcmp(label,url) % display label next to url 46 | str = [label ' (' url ')']; 47 | elseif isWebpage % text==url - display only the url 48 | str = url; 49 | else % Matlab command (not a webpage) - just display the label 50 | str = label; 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/DatesCount.m: -------------------------------------------------------------------------------- 1 | function opt = DatesCount(fo_year,lo_year,frequency,fo_period,lo_period) 2 | % ======================================================================= 3 | % For given initial observation, final observation and frequency this 4 | % function computes the number of observations between them and creates a 5 | % cell aray with the dates (of the type 1979M2). 6 | % ======================================================================= 7 | % opt = DatesCount(fo_year,lo_year,frequency,fo_period,lo_period) 8 | % ----------------------------------------------------------------------- 9 | % INPUT 10 | % - fo_year: initial year of the timeline 11 | % - lo_year: final year of the timeline 12 | % - frequency: quarterly 'q' [def], monthly 'm', yearly 'y' 13 | % ----------------------------------------------------------------------- 14 | % OPTIONAL INPUT 15 | % - fo_period: initial quarter/month of the timeline (not for yearly frequency) 16 | % - lo_period: last quarter/month of the timeline (not for yearly frequency) 17 | % ----------------------------------------------------------------------- 18 | % OUTPUT 19 | % - nobs: number of observations 20 | % - dates: cell array of dates 21 | % ======================================================================= 22 | % Ambrogio Cesa Bianchi, March 2015 23 | % ambrogio.cesabianchi@gmail.com 24 | 25 | % Check inputs 26 | if ~exist('frequency','var') 27 | frequency = 'q'; 28 | end 29 | 30 | if strcmp(frequency,'m') 31 | if ~exist('fo_period','var'), error('You need to provide first period'), end 32 | if ~exist('lo_period','var'), error('You need to provide last period'), end 33 | fo = fo_year + fo_period*(1/12); 34 | lo = lo_year + lo_period*(1/12); 35 | aux = fo:(1/12):lo; 36 | nobs = length(aux); 37 | elseif strcmp(frequency,'q') 38 | if ~exist('fo_period','var'), error('You need to provide first period'), end 39 | if ~exist('lo_period','var'), error('You need to provide last period'), end 40 | fo = fo_year + fo_period*(1/4); 41 | lo = lo_year + lo_period*(1/4); 42 | aux = fo:(1/4):lo; 43 | nobs = length(aux); 44 | elseif strcmp(frequency,'y') 45 | fo = fo_year; 46 | lo = lo_year; 47 | aux = fo:lo; 48 | nobs = length(aux); 49 | end 50 | 51 | opt.dates = DatesCreate(fo_year,fo_period,nobs,frequency); 52 | opt.nobs 53 | -------------------------------------------------------------------------------- /v3dot0/Utils/datatreat.m: -------------------------------------------------------------------------------- 1 | function OUT = datatreat(DATA,vtreat,nlag) 2 | % ======================================================================= 3 | % Treat a time series with the specified method. If changes are computed 4 | % the function assumes 1 lag (unless otherwise specified) 5 | % ======================================================================= 6 | % OUT = datatreat(DATA,vtreat,lag) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA: matrix DATA(T,N) 10 | % - vtreat: 0 No treatment 11 | % 1 Log 12 | % 2 Difference 13 | % 3 Log Difference 14 | % 4 Percent change 15 | % ----------------------------------------------------------------------- 16 | % OPTIONAL INPUT 17 | % - lag: number of lags for changes 18 | % ----------------------------------------------------------------------- 19 | % OUTPUT 20 | % - OUT: matrix DATA(T,N) of treated data. The first "nlag" 21 | % observations are NaNs 22 | % ----------------------------------------------------------------------- 23 | % EXAMPLE 24 | % x = [1 2; -3 4; 5 6; 7 8; 9 10]; 25 | % OUT = datatreat(x,3) 26 | % ======================================================================= 27 | % VAR Toolbox 3.0 28 | % Ambrogio Cesa-Bianchi 29 | % ambrogiocesabianchi@gmail.com 30 | % March 2012. Updated November 2020 31 | % ----------------------------------------------------------------------- 32 | 33 | % Check input 34 | if ~exist('nlag','var') 35 | nlag = 1; 36 | end 37 | 38 | % Set matrices 39 | [nobs, nvar] = size(DATA); 40 | OUT = nan(nobs,nvar); 41 | 42 | % No treatment 43 | if vtreat==0 44 | OUT = DATA; 45 | 46 | % Log 47 | elseif vtreat==1 48 | if ~isempty(DATA<0), warning('Negative numbers set to NaN before taking logs'), end 49 | DATA(DATA<0) = NaN; 50 | OUT = log(DATA); 51 | 52 | % Difference 53 | elseif vtreat==2 54 | OUT(nlag+1:end,:) = DATA(1+nlag:end,:) - DATA(1:end-nlag,:); 55 | 56 | % Log difference 57 | elseif vtreat==3 58 | if ~isempty(DATA<0), warning('Negative numbers set to NaN before taking logs'), end 59 | DATA(DATA<0) = NaN; 60 | OUT(nlag+1:end,:) = log(DATA(1+nlag:end,:))-log(DATA(1:end-nlag,:)); 61 | 62 | % Percent change 63 | elseif vtreat==4 64 | OUT(nlag+1:end,:) = DATA(1+nlag:end,:)./DATA(1:end-nlag,:)-1; 65 | end 66 | -------------------------------------------------------------------------------- /v3dot0/Utils/CommonSample.m: -------------------------------------------------------------------------------- 1 | function [OUT, fo, lo] = CommonSample(DATA,dim) 2 | % ======================================================================= 3 | % If a row of DATA contains a NaN, the row is removed. If dim=2, if a 4 | % column of DATA contains a NaN, the column is removed. 5 | % ======================================================================= 6 | % [OUT, fo, lo] = CommonSample(DATA) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA: matrix DATA(i,j) 10 | % ----------------------------------------------------------------------- 11 | % OPTIONAL INPUT 12 | % - dim: default 1, change to 2 to CommonSample by column 13 | % ----------------------------------------------------------------------- 14 | % OUTPUT 15 | % - OUT: common sample matrix 16 | % - fo : number of NaNs at the beginning 17 | % - lo : number of NaNs at the end 18 | % ----------------------------------------------------------------------- 19 | % EXAMPLE 20 | % x = [1 2; NaN 4; 5 6]; 21 | % OUT = CommonSample(x) 22 | % ======================================================================= 23 | % VAR Toolbox 3.0 24 | % Ambrogio Cesa-Bianchi 25 | % ambrogiocesabianchi@gmail.com 26 | % March 2012. Updated November 2020 27 | % ----------------------------------------------------------------------- 28 | 29 | % If no dimension is specified, set it to 1 30 | if ~exist('dim','var') 31 | dim = 1; 32 | end 33 | 34 | fo = 0; 35 | lo = 0; 36 | 37 | if dim==1 38 | temp = sum(DATA,2); 39 | ii = 1; 40 | if isnan(temp(ii)) 41 | while isnan(temp(ii)) 42 | fo = fo+1; 43 | ii = ii+1; 44 | if ii>length(temp) 45 | break 46 | end 47 | end 48 | end 49 | for ii=1:rows(DATA)-fo 50 | if isnan(temp(end+1-ii)) 51 | lo = lo+1; 52 | end 53 | end 54 | DATA(any(isnan(DATA),2),:) = []; 55 | else 56 | temp = sum(DATA,1); 57 | ii = 1; 58 | if isnan(temp(ii)) 59 | while isnan(temp(ii)) 60 | fo = fo+1; 61 | ii = ii+1; 62 | end 63 | end 64 | for ii=1:cols(DATA)-fo 65 | if isnan(temp(end+1-ii)) 66 | lo = lo+1; 67 | end 68 | end 69 | DATA(:,any(isnan(DATA),1)) = []; 70 | end 71 | 72 | OUT = DATA; 73 | -------------------------------------------------------------------------------- /v3dot0/VAR/VARmakexy.m: -------------------------------------------------------------------------------- 1 | function [Y, X] = VARmakexy(DATA,lags,const) 2 | %======================================================================== 3 | % Builds VAR matrices from DATA, e.g. [x y] = [x(-1) y(-1) x(-2) y(-2)] 4 | % in case of 2 lags and no constant 5 | %======================================================================== 6 | % [Y, X] = VARmakexy(DATA, lags, const) 7 | %-------------------------------------------------------------------------- 8 | % INPUT 9 | % - DATA: matrix containing the original data 10 | % - lags: lag order of the VAR 11 | % - const : 0, no constant, no trend 12 | % 1, constant, no trend 13 | % 2, constant, trend 14 | % 3, constant, trend, trend^2 15 | %-------------------------------------------------------------------------- 16 | % OUTPUT 17 | % - Y: VAR dependent variable 18 | % - X: VAR independent variable 19 | % ----------------------------------------------------------------------- 20 | % EXAMPLE 21 | % x = [1 2; 3 4; 5 6; 7 8; 9 10]; 22 | % [Y,X]= VARmakexy(x,2,1) 23 | % ======================================================================= 24 | % VAR Toolbox 3.0 25 | % Ambrogio Cesa-Bianchi 26 | % ambrogiocesabianchi@gmail.com 27 | % March 2012. Updated November 2020 28 | % ----------------------------------------------------------------------- 29 | 30 | 31 | % Get dimesion of DATA 32 | [nobs, ~]= size(DATA); 33 | 34 | % Y matrix 35 | Y = DATA(lags+1:end,:); 36 | 37 | % X-matrix 38 | if const==0 39 | X=[]; 40 | for jj=0:lags-1 41 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 42 | end 43 | 44 | elseif const==1 %constant 45 | X = []; 46 | for jj=0:lags-1 47 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 48 | end 49 | X = [ones(nobs-lags,1) X]; 50 | 51 | elseif const==2 % time trend and constant 52 | X = []; 53 | for jj=0:lags-1 54 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 55 | end 56 | trend=1:size(X,1); 57 | X = [ones(nobs-lags,1) trend' X]; 58 | 59 | elseif const==3 % linear time trend, squared time trend, and constant 60 | X = []; 61 | for jj=0:lags-1 62 | X = [DATA(jj+1:nobs-lags+jj,:), X]; 63 | end 64 | trend=1:size(X,1); 65 | X = [ones(nobs-lags,1) trend' (trend').^2 X]; 66 | end 67 | -------------------------------------------------------------------------------- /v3dot0/Figure/Date2Num.m: -------------------------------------------------------------------------------- 1 | function OUT = Date2Num(dates,frequency) 2 | % ========================================================================= 3 | % Convert a cell array of dates into a double array. The first period of 4 | % the year is coded as a round number. For quarterly data the step change 5 | % is 0.25, so that 1984Q2 => 1984.25; For monthly data the step change 6 | % is 0.833, so that 1984M2 => 1984.0833. 7 | % ======================================================================= 8 | % OUT = Date2Num(DATA) 9 | % ----------------------------------------------------------------------- 10 | % INPUTS 11 | % - DATA: a (T x 1) vector with dates in cell format 12 | % ----------------------------------------------------------------------- 13 | % OPTIONAL INPUT 14 | % - frequency : monthly ('m'), quarterly ('q') [dflt] or annual ('y') 15 | % ----------------------------------------------------------------------- 16 | % OUTPUT 17 | % - OUT: a (T x 1) vector with dates in numeric format 18 | % ----------------------------------------------------------------------- 19 | % EXAMPLE 20 | % dates = {'1992M1';'1992M2';'1992M3';'1992M4';'1992M5';}; 21 | % OUT = Date2Num(dates,'m') 22 | % ----------------------------------------------------------------------- 23 | % RELATED 24 | % - DatesCreate, DatesCount 25 | % ======================================================================= 26 | % VAR Toolbox 3.0 27 | % Ambrogio Cesa-Bianchi 28 | % ambrogiocesabianchi@gmail.com 29 | % March 2015. Updated November 2020 30 | % ----------------------------------------------------------------------- 31 | 32 | 33 | format long 34 | % Check inputs 35 | if ~exist('frequency','var') 36 | frequency = 'q'; 37 | end 38 | [n,c] = size(dates); 39 | 40 | % Convert cell array into double array 41 | if strcmp(frequency,'q') 42 | OUT = nan(n,c); 43 | for i=1:n 44 | for j=1:c 45 | aux = dates{i,j}; 46 | year = str2double(aux(1:4)); 47 | period = str2double(aux(6)); 48 | OUT(i,j) = year + period/4 -0.25; 49 | end 50 | end 51 | elseif strcmp(frequency,'m') 52 | OUT = nan(n,c); 53 | for i=1:n 54 | for j=1:c 55 | aux = dates{i,j}; 56 | year = str2double(aux(1:4)); 57 | period = str2double(aux(6:end)); 58 | OUT(i,j) = year + period/12 -0.08333333333333333333333333333333; 59 | end 60 | end 61 | end -------------------------------------------------------------------------------- /v3dot0/Stats/CorrTableUnbalanced.m: -------------------------------------------------------------------------------- 1 | function [CORR, TABLE] = CorrTableUnbalanced(x,vnames) 2 | % ======================================================================= 3 | % Computes the correlation matrix of a matrix of time series with titles 4 | % ======================================================================= 5 | % out = CorrTable(x,vnames) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - x: matrix (rows x cols) [double] 9 | % - vnames: array (1 x cols) with names of the (cols) series [cell] 10 | % ----------------------------------------------------------------------- 11 | % OUTPUT 12 | % - CORR: correlation matrix [double] 13 | % - TABLE: table of correlation matrix with titles [cell] 14 | % ----------------------------------------------------------------------- 15 | % EXAMPLE 16 | % x = rand(50,2); 17 | % [CORR, TABLE] = CorrTableUnbalanced(x,{'Consumption','Investment'}) 18 | % ======================================================================= 19 | % VAR Toolbox 3.0 20 | % Ambrogio Cesa-Bianchi 21 | % ambrogiocesabianchi@gmail.com 22 | % March 2015. Updated November 2020 23 | % ----------------------------------------------------------------------- 24 | 25 | 26 | % vnames must be a row vector 27 | if size(vnames,1)>1 28 | vnames = vnames'; 29 | end 30 | 31 | % Compute the correlation matrix using the maximum amount of avaliable obs 32 | [row , col] = size(x); 33 | CORR = nan(col,col); 34 | for ii=1:col 35 | x1 = x(:,ii); 36 | for jj=1:col 37 | x2 = x(:,jj); 38 | y = CommonSample([x1 x2]); 39 | if isempty(y) == 1 40 | CORR(ii,jj) = NaN; 41 | else 42 | aux = corr(y(:,1),y(:,2)); 43 | if isnan(aux)==1 44 | if ii==jj 45 | CORR(ii,jj) = 1; 46 | end 47 | else 48 | CORR(ii,jj) = corr(y(:,1),y(:,2)); 49 | end 50 | end 51 | end 52 | end 53 | 54 | % Place NaNs on the uuper triangular 55 | CORR(find(triu(CORR))) = NaN; 56 | jj = 1; 57 | for ii=1:col 58 | CORR(ii,jj) = 1; 59 | jj = jj +1; 60 | end 61 | 62 | % Transform table into cell array 63 | table = num2cell(CORR); 64 | 65 | % Add vnames on top 66 | table = [vnames ; table]; 67 | 68 | % Add vnames on the left 69 | aux = [{''} vnames]'; 70 | TABLE = [aux table]; 71 | 72 | % Print using mprint 73 | info.cvnames = char(vnames); 74 | info.rvnames = char([{' '} vnames]); 75 | mprint(CORR,info); -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/VARhdplot.m: -------------------------------------------------------------------------------- 1 | function VARhdplot(HD,VARopt) 2 | % ======================================================================= 3 | % Plot the HD shocks computed with VARhd 4 | % ======================================================================= 5 | % VARhdplot(HD,VARopt) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - HD: structure from VARhd 9 | % - VARopt: options of the VAR (see VARopt from VARmodel) 10 | % ======================================================================= 11 | % Ambrogio Cesa Bianchi, March 2015 12 | % ambrogio.cesabianchi@gmail.com 13 | 14 | 15 | %% Check inputs 16 | %=============================================== 17 | if ~exist('VARopt','var') 18 | error('You need to provide VAR options (VARopt from VARmodel)'); 19 | end 20 | % If there is VARopt check that vnames is not empty 21 | vnames = VARopt.vnames; 22 | if isempty(vnames) 23 | error('You need to add label for endogenous variables in VARopt'); 24 | end 25 | 26 | 27 | %% Check inputs Define some parameters 28 | %=============================================== 29 | filename = [VARopt.figname 'HD_']; 30 | quality = VARopt.quality; 31 | suptitle = VARopt.suptitle; 32 | pick = VARopt.pick; 33 | 34 | % Initialize HD matrix 35 | [nsteps, nvars, nshocks] = size(HD.shock); 36 | 37 | % If one shock is chosen, set the right value for nshocks 38 | if pick<0 || pick>nvars 39 | error('The selected shock is non valid') 40 | else 41 | if pick==0 42 | pick=1; 43 | else 44 | nshocks = pick; 45 | end 46 | end 47 | 48 | 49 | %% Plot 50 | %=============================================== 51 | FigSize 52 | for ii=pick:nvars 53 | colormap(parula) 54 | BarPlot(HD.shock(:,1:nshocks,ii)); 55 | xlim([1 nsteps]); 56 | title([vnames{ii}], 'FontWeight','bold','FontSize',10); 57 | % Save 58 | FigName = [filename num2str(ii)]; 59 | if quality 60 | if suptitle==1 61 | Alphabet = char('a'+(1:nvars)-1); 62 | SupTitle([Alphabet(jj) ') HD of ' vnames{ii}]) 63 | end 64 | opt = LegOption; LegSubplot(vnames,opt); 65 | set(gcf, 'Color', 'w'); 66 | export_fig(FigName,'-pdf','-png','-painters') 67 | else 68 | legend(vnames) 69 | print('-dpng','-r100',FigName); 70 | print('-dpdf','-r100',FigName); 71 | end 72 | clf('reset'); 73 | end 74 | 75 | close all 76 | -------------------------------------------------------------------------------- /OldVersions/v2dot0/Figure/DatesCreate.m: -------------------------------------------------------------------------------- 1 | function [dates, dates_short] = DatesCreate(year,nobs,frequency,fo_period) 2 | % ======================================================================= 3 | % Create a timeline (cell array) of the type 1999Q1. Can be used as an 4 | % input for PlotOption, for the field opt.timeline 5 | % ======================================================================= 6 | % [dates, dates_short] = DatesCreate(year,nobs,frequency,fo_period) 7 | % ----------------------------------------------------------------------- 8 | % INPUT 9 | % - year: initial year of the timeline 10 | % - nobs: number of observations 11 | % ----------------------------------------------------------------------- 12 | % OPTIONAL INPUT 13 | % - frequency: quarterly 'q' [def], monthly 'm', yearly 'y' 14 | % - fo_period : initial quarter/month of the timeline (not for yearly frequency) 15 | % ----------------------------------------------------------------------- 16 | % OUTPUT 17 | % - dates: vector of dates 18 | % - dates_short: vector of dates only year 19 | % ======================================================================= 20 | % Ambrogio Cesa Bianchi, March 2015 21 | % ambrogio.cesabianchi@gmail.com 22 | 23 | % Check inputs 24 | if ~exist('frequency','var') 25 | frequency = 'q'; 26 | end 27 | 28 | % Set the first observation, eg first quarter, second month, etc 29 | incr = fo_period; 30 | 31 | % Create the timeline 32 | if strcmp(frequency,'q') 33 | if ~exist('fo_period','var'), error('You need to provide first period'), end 34 | for ii=1:nobs 35 | if incr==5 % when incr=5 set it back to 1 and increase the year counter 36 | incr=1; 37 | year = year + 1; 38 | end 39 | dates(ii,1) = {[num2str(year) 'q' num2str(incr)]}; 40 | incr = incr + 1; 41 | end 42 | elseif strcmp(frequency,'m') 43 | if ~exist('fo_period','var'), error('You need to provide first period'), end 44 | for ii=1:nobs 45 | if incr==13 % when incr=5 set it back to 1 and increase the year counter 46 | incr=1; 47 | year = year + 1; 48 | end 49 | dates(ii,1) = {[num2str(year) 'm' num2str(incr)]}; 50 | incr = incr + 1; 51 | end 52 | elseif strcmp(frequency,'y') 53 | for ii=1:nobs 54 | dates(ii,1) = {num2str(year)}; 55 | year = year + 1; 56 | end 57 | end 58 | 59 | % Create the short vector 60 | for kk = 1:nobs 61 | aux = char(dates(kk,1)); 62 | dates_short(kk,1) = {[aux(1:4)]}; 63 | end -------------------------------------------------------------------------------- /OldVersions/v2dot0/VAR/SRhdplot.m: -------------------------------------------------------------------------------- 1 | function SRhdplot(HD,VARopt) 2 | % ======================================================================= 3 | % Plot the HD shocks computed with SR (sign restriction procedure) 4 | % ======================================================================= 5 | % SRhdplot(HD,VARopt) 6 | % ----------------------------------------------------------------------- 7 | % INPUT 8 | % - HD: structure from SR 9 | % - VARopt: options of the VAR (from VARmodel and SR) 10 | % ======================================================================= 11 | % Ambrogio Cesa Bianchi, March 2015 12 | % ambrogio.cesabianchi@gmail.com 13 | 14 | 15 | %% Check inputs 16 | %================================================ 17 | if ~exist('VARopt','var') 18 | error('You need to provide VAR options (VARopt from VARmodel)'); 19 | end 20 | % If there is VARopt check that vnames and snames are not empty 21 | vnames = VARopt.vnames; 22 | snames = VARopt.snames; 23 | if isempty(vnames) 24 | error('You need to add label for endogenous variables in VARopt'); 25 | end 26 | if isempty(snames) 27 | error('You need to add label for shocks in VARopt'); 28 | end 29 | 30 | 31 | %% Check inputs Define some parameters 32 | %=============================================== 33 | filename = [VARopt.figname 'HD_SR_']; 34 | quality = VARopt.quality; 35 | suptitle = VARopt.suptitle; 36 | pick = VARopt.pick; 37 | 38 | % Initialize HD matrix 39 | nshocks = length(snames); [nsteps, nvars, ~] = size(HD); 40 | 41 | % If one shock is chosen, set the right value for nshocks 42 | if pick<0 || pick>nvars 43 | error('The selected shock is non valid') 44 | else 45 | if pick==0 46 | pick=1; 47 | else 48 | nshocks = pick; 49 | end 50 | end 51 | 52 | 53 | %% Plot 54 | %================================================ 55 | FigSize 56 | for ii=pick:nvars 57 | colormap(parula) 58 | BarPlot(HD(:,1:nshocks,ii)); 59 | xlim([1 nsteps]); 60 | title([vnames{ii}], 'FontWeight','bold','FontSize',10); 61 | % Save 62 | FigName = [filename num2str(ii)]; 63 | if quality 64 | if suptitle==1 65 | Alphabet = char('a'+(1:nvars)-1); 66 | SupTitle([Alphabet(jj) ') HD of ' vnames{ii}]) 67 | end 68 | opt = LegOption; LegSubplot(vnames,opt); 69 | set(gcf, 'Color', 'w'); 70 | export_fig(FigName,'-pdf','-png','-painters') 71 | else 72 | legend(snames) 73 | print('-dpng','-r100',FigName); 74 | print('-dpdf','-r100',FigName); 75 | end 76 | clf('reset'); 77 | end 78 | 79 | close all 80 | --------------------------------------------------------------------------------