Esempio n. 1
0
    def plot_cum_effects(self, orth=False, impulse=None, response=None,
                         signif=0.05, plot_params=None,
                         subplot_params=None, plot_stderr=True):
        """

        """

        if orth:
            title = 'Cumulative responses responses (orthogonalized)'
            cum_effects = self.orth_cum_effects
            lr_effects = self.orth_lr_effects
        else:
            title = 'Cumulative responses'
            cum_effects = self.cum_effects
            lr_effects = self.lr_effects

        try:
            stderr = self.cum_effect_cov(orth=orth)
        except NotImplementedError: # pragma: no cover
            stderr = None

        if not plot_stderr:
            stderr = None

        plotting.irf_grid_plot(cum_effects, stderr, impulse, response,
                               self.model.names, title, signif=signif,
                               hlines=lr_effects, subplot_params=subplot_params,
                               plot_params=plot_params)
Esempio n. 2
0
    def plot_cum_effects(self, orth=False, impulse=None, response=None,
                         signif=0.05, plot_params=None,
                         subplot_params=None, plot_stderr=True):
        """

        """

        if orth:
            title = 'Cumulative responses responses (orthogonalized)'
            cum_effects = self.orth_cum_effects
            lr_effects = self.orth_lr_effects
        else:
            title = 'Cumulative responses'
            cum_effects = self.cum_effects
            lr_effects = self.lr_effects

        try:
            stderr = self.cum_effect_cov(orth=orth)
        except NotImplementedError: # pragma: no cover
            stderr = None

        if not plot_stderr:
            stderr = None

        plotting.irf_grid_plot(cum_effects, stderr, impulse, response,
                               self.model.names, title, signif=signif,
                               hlines=lr_effects, subplot_params=subplot_params,
                               plot_params=plot_params, stderr_type='asym')
Esempio n. 3
0
    def plot_cum_effects(self, orth=False, impulse=None, response=None,
                         signif=0.05, plot_params=None,
                         subplot_params=None, plot_stderr=True,
                         stderr_type='asym', repl=1000, seed=None):
        """
        Plot cumulative impulse response functions

        Parameters
        ----------
        orth : bool, default False
            Compute orthogonalized impulse responses
        impulse : string or int
            variable providing the impulse
        response : string or int
            variable affected by the impulse
        signif : float (0 < signif < 1)
            Significance level for error bars, defaults to 95% CI
        subplot_params : dict
            To pass to subplot plotting funcions. Example: if fonts are too big,
            pass {'fontsize' : 8} or some number to your taste.
        plot_params : dict

        plot_stderr: bool, default True
            Plot standard impulse response error bands
        stderr_type: string
            'asym': default, computes asymptotic standard errors
            'mc': monte carlo standard errors (use rpl)
        repl: int, default 1000
            Number of replications for monte carlo standard errors
        seed: int
            np.random.seed for Monte Carlo replications

        """

        if orth:
            title = 'Cumulative responses responses (orthogonalized)'
            cum_effects = self.orth_cum_effects
            lr_effects = self.orth_lr_effects
        else:
            title = 'Cumulative responses'
            cum_effects = self.cum_effects
            lr_effects = self.lr_effects

        if stderr_type not in ['asym', 'mc']:
            raise TypeError
        else:
            if stderr_type == 'asym':
                stderr = self.cum_effect_cov(orth=orth)
            if stderr_type == 'mc':
                stderr = self.cum_errband_mc(orth=orth, repl=repl,
                                                signif=signif, seed=seed)
        if not plot_stderr:
            stderr = None

        plotting.irf_grid_plot(cum_effects, stderr, impulse, response,
                               self.model.names, title, signif=signif,
                               hlines=lr_effects, subplot_params=subplot_params,
                               plot_params=plot_params, stderr_type=stderr_type)
Esempio n. 4
0
    def plot(self, orth=False, impulse=None, response=None, signif=0.05,
             plot_params=None, subplot_params=None, plot_stderr=True):
        """
        Plot impulse responses

        Parameters
        ----------
        orth : bool, default False
            Compute orthogonalized impulse responses
        impulse : string or int
            variable providing the impulse
        response : string or int
            variable affected by the impulse
        signif : float (0 < signif < 1)
            Significance level for error bars, defaults to 95% CI
        subplot_params : dict
            To pass to subplot plotting funcions. Example: if fonts are too big,
            pass {'fontsize' : 8} or some number to your taste.
        plot_params : dict
        """
        if orth:
            title = 'Impulse responses (orthogonalized)'
            irfs = self.orth_irfs
        else:
            title = 'Impulse responses'
            irfs = self.irfs

        try:
            stderr = self.cov(orth=orth)
        except NotImplementedError: # pragma: no cover
            stderr = None

        if not plot_stderr:
            stderr = None

        plotting.irf_grid_plot(irfs, stderr, impulse, response,
                               self.model.names, title, signif=signif,
                               subplot_params=subplot_params,
                               plot_params=plot_params)
Esempio n. 5
0
    def plot(
        self,
        orth=False,
        impulse=None,
        response=None,
        signif=0.05,
        plot_params=None,
        subplot_params=None,
        plot_stderr=True,
        stderr_type="asym",
        repl=1000,
        seed=None,
        component=None,
    ):
        """
        Plot impulse responses

        Parameters
        ----------
        orth : bool, default False
            Compute orthogonalized impulse responses
        impulse : string or int
            variable providing the impulse
        response : string or int
            variable affected by the impulse
        signif : float (0 < signif < 1)
            Significance level for error bars, defaults to 95% CI
        subplot_params : dict
            To pass to subplot plotting funcions. Example: if fonts are too big,
            pass {'fontsize' : 8} or some number to your taste.
        plot_params : dict

        plot_stderr: bool, default True
            Plot standard impulse response error bands
        stderr_type: string
            'asym': default, computes asymptotic standard errors
            'mc': monte carlo standard errors (use rpl)
        repl: int, default 1000
            Number of replications for Monte Carlo and Sims-Zha standard errors
        seed: int
            np.random.seed for Monte Carlo replications
        component: array or vector of principal component indices
        """
        periods = self.periods
        model = self.model
        svar = self.svar

        if orth and svar:
            raise ValueError("For SVAR system, set orth=False")

        if orth:
            title = "Impulse responses (orthogonalized)"
            irfs = self.orth_irfs
        elif svar:
            title = "Impulse responses (structural)"
            irfs = self.svar_irfs
        else:
            title = "Impulse responses"
            irfs = self.irfs

        if plot_stderr == False:
            stderr = None

        elif stderr_type not in ["asym", "mc", "sz1", "sz2", "sz3"]:
            raise ValueError("Error type must be either 'asym', 'mc','sz1','sz2', or 'sz3'")
        else:
            if stderr_type == "asym":
                stderr = self.cov(orth=orth)
            if stderr_type == "mc":
                stderr = self.errband_mc(orth=orth, svar=svar, repl=repl, signif=signif, seed=seed)
            if stderr_type == "sz1":
                stderr = self.err_band_sz1(
                    orth=orth, svar=svar, repl=repl, signif=signif, seed=seed, component=component
                )
            if stderr_type == "sz2":
                stderr = self.err_band_sz2(
                    orth=orth, svar=svar, repl=repl, signif=signif, seed=seed, component=component
                )
            if stderr_type == "sz3":
                stderr = self.err_band_sz3(
                    orth=orth, svar=svar, repl=repl, signif=signif, seed=seed, component=component
                )

        plotting.irf_grid_plot(
            irfs,
            stderr,
            impulse,
            response,
            self.model.names,
            title,
            signif=signif,
            subplot_params=subplot_params,
            plot_params=plot_params,
            stderr_type=stderr_type,
        )
Esempio n. 6
0
    def plot(self, orth=False, impulse=None, response=None,
             signif=0.05, plot_params=None, subplot_params=None,
             plot_stderr=True, stderr_type='asym', repl=1000,
             seed=None, component=None):
        """
        Plot impulse responses

        Parameters
        ----------
        orth : bool, default False
            Compute orthogonalized impulse responses
        impulse : string or int
            variable providing the impulse
        response : string or int
            variable affected by the impulse
        signif : float (0 < signif < 1)
            Significance level for error bars, defaults to 95% CI
        subplot_params : dict
            To pass to subplot plotting funcions. Example: if fonts are too big,
            pass {'fontsize' : 8} or some number to your taste.
        plot_params : dict

        plot_stderr: bool, default True
            Plot standard impulse response error bands
        stderr_type: string
            'asym': default, computes asymptotic standard errors
            'mc': monte carlo standard errors (use rpl)
        repl: int, default 1000
            Number of replications for Monte Carlo and Sims-Zha standard errors
        seed: int
            np.random.seed for Monte Carlo replications
        component: array or vector of principal component indices
        """
        periods = self.periods
        model = self.model
        svar = self.svar

        if orth and svar:
            raise ValueError("For SVAR system, set orth=False")

        if orth:
            title = 'Impulse responses (orthogonalized)'
            irfs = self.orth_irfs
        elif svar:
            title = 'Impulse responses (structural)'
            irfs = self.svar_irfs
        else:
            title = 'Impulse responses'
            irfs = self.irfs

        if plot_stderr == False:
            stderr = None

        elif stderr_type not in ['asym', 'mc', 'sz1', 'sz2','sz3']:
            raise ValueError("Error type must be either 'asym', 'mc','sz1','sz2', or 'sz3'")
        else:
            if stderr_type == 'asym':
                stderr = self.cov(orth=orth)
            if stderr_type == 'mc':
                stderr = self.errband_mc(orth=orth, svar=svar,
                                         repl=repl, signif=signif,
                                         seed=seed)
            if stderr_type == 'sz1':
                stderr = self.err_band_sz1(orth=orth, svar=svar,
                                           repl=repl, signif=signif,
                                           seed=seed,
                                           component=component)
            if stderr_type == 'sz2':
                stderr = self.err_band_sz2(orth=orth, svar=svar,
                                           repl=repl, signif=signif,
                                           seed=seed,
                                           component=component)
            if stderr_type == 'sz3':
                stderr = self.err_band_sz3(orth=orth, svar=svar,
                                           repl=repl, signif=signif,
                                           seed=seed,
                                           component=component)

        plotting.irf_grid_plot(irfs, stderr, impulse, response,
                               self.model.names, title, signif=signif,
                               subplot_params=subplot_params,
                               plot_params=plot_params, stderr_type=stderr_type)