Example #1
0
def run_analysis(cname, cause, ename, effect, db, rng, ccm_settings):
    '''Run analysis for a single causal direction.'''
    sys.stderr.write('Running {0}-causes-{1}\n'.format(cname, ename))

    # Check if effect has no variation
    cause_sd = numpy.std(cause)
    effect_sd = numpy.std(effect)
    if cause_sd == 0.0 or effect_sd == 0.0:
        sys.stderr.write(
            'No variation cause or effect time series; skipping analysis.\n')
        return
    else:
        # Identify delay at which autocorrelation drops to 1/e
        ac_delay, autocorr = pyembedding.autocorrelation_threshold_delay(
            effect, 1.0 / numpy.e)
        sys.stderr.write('  ac_delay, autocorr = {0}, {1}\n'.format(
            ac_delay, autocorr))

        # Calculate Theiler window (limit on closeness of neighbors in time)
        theiler_window = min(ccm_settings['max_theiler_window'], 3 * ac_delay)
        sys.stderr.write('  theiler_window = {0}\n'.format(theiler_window))
        assert theiler_window < effect.shape[0]

        embedding_algorithm = ccm_settings['embedding_algorithm']
        assert embedding_algorithm == 'max_univariate_prediction_plus_lags'
        run_analysis_max_univariate_prediction_plus_lags(
            cname, cause, ename, effect, theiler_window, db, rng, ccm_settings)
Example #2
0
def run_analysis(cname, cause, ename, effect):
    '''Run analysis for a single causal direction.'''
    sys.stderr.write('Running {0}-causes-{1}\n'.format(cname, ename))

    # Check if effect has no variation
    cause_sd = numpy.std(cause)
    effect_sd = numpy.std(effect)
    if cause_sd < EPS or effect_sd < EPS:
        sys.stderr.write(
            'No variation cause or effect time series; skipping analysis.\n')
        return
    else:
        # Identify delay at which autocorrelation drops to 1/e
        ac_delay, autocorr = pyembedding.autocorrelation_threshold_delay(
            effect, 1.0 / numpy.e)
        sys.stderr.write('  ac_delay, autocorr = {0}, {1}\n'.format(
            ac_delay, autocorr))

        # Calculate Theiler window (limit on closeness of neighbors in time)
        theiler_window = min(MAX_THEILER_WINDOW, 3 * ac_delay)
        sys.stderr.write('  theiler_window = {0}\n'.format(theiler_window))
        assert theiler_window < effect.shape[0]

        if EMBEDDING_ALGORITHM == 'uzal_nichkawde':
            run_analysis_uzal_nichkawde(cname, cause, ename, effect,
                                        theiler_window)
        elif EMBEDDING_ALGORITHM == 'uniform_sweep':
            run_analysis_uniform_sweep(cname, cause, ename, effect,
                                       theiler_window)
        elif EMBEDDING_ALGORITHM == 'max_ccm_rho':
            run_analysis_max_ccm_rho(cname, cause, ename, effect,
                                     theiler_window)
        elif EMBEDDING_ALGORITHM == 'max_univariate_prediction':
            run_analysis_max_univariate_prediction(cname, cause, ename, effect,
                                                   theiler_window)
Example #3
0
def run_analysis(cname, cause, ename, effect):
    '''Run analysis for a single causal direction.'''
    sys.stderr.write('Running {0}-causes-{1}\n'.format(cname, ename))

    # Check if effect has no variation
    cause_sd = numpy.std(cause)
    effect_sd = numpy.std(effect)
    if cause_sd < EPS or effect_sd < EPS:
        sys.stderr.write('No variation cause or effect time series; skipping analysis.\n')
        return
    else:
        # Identify delay at which autocorrelation drops to 1/e
        ac_delay, autocorr = pyembedding.autocorrelation_threshold_delay(effect, 1.0/numpy.e)
        sys.stderr.write('  ac_delay, autocorr = {0}, {1}\n'.format(ac_delay, autocorr))
        
        # Calculate Theiler window (limit on closeness of neighbors in time)
        theiler_window = min(MAX_THEILER_WINDOW, 3 * ac_delay)
        sys.stderr.write('  theiler_window = {0}\n'.format(theiler_window))
        assert theiler_window < effect.shape[0]
        
        if EMBEDDING_ALGORITHM == 'uzal_nichkawde':
            run_analysis_uzal_nichkawde(cname, cause, ename, effect, theiler_window)
        elif EMBEDDING_ALGORITHM == 'uniform_sweep':
            run_analysis_uniform_sweep(cname, cause, ename, effect, theiler_window)
        elif EMBEDDING_ALGORITHM == 'max_ccm_rho':
            run_analysis_max_ccm_rho(cname, cause, ename, effect, theiler_window)
        elif EMBEDDING_ALGORITHM == 'max_univariate_prediction':
            run_analysis_max_univariate_prediction(cname, cause, ename, effect, theiler_window)
def run_analysis(cname, cause, ename, effect, db, rng):
    '''Run analysis for a single causal direction.'''
    sys.stderr.write('Running {0}-causes-{1}\n'.format(cname, ename))

    # Check if effect has no variation
    cause_sd = numpy.std(cause)
    effect_sd = numpy.std(effect)
    if cause_sd == 0.0 or effect_sd == 0.0:
        sys.stderr.write('No variation cause or effect time series; skipping analysis.\n')
        return
    else:
        # Identify delay at which autocorrelation drops to 1/e
        ac_delay, autocorr = pyembedding.autocorrelation_threshold_delay(effect, 1.0/numpy.e)
        sys.stderr.write('  ac_delay, autocorr = {0}, {1}\n'.format(ac_delay, autocorr))
        
        # Calculate Theiler window (limit on closeness of neighbors in time)
        theiler_window = 3 * ac_delay
        sys.stderr.write('  theiler_window = {0}\n'.format(theiler_window))
        assert theiler_window < effect.shape[0]
        
        run_analysis_max_univariate_prediction_plus_lags(cname, cause, ename, effect, theiler_window, db, rng)
Example #5
0
def run_analysis(cname, cause, ename, effect, db, rng, ccm_settings):
    '''Run analysis for a single causal direction.'''
    sys.stderr.write('Running {0}-causes-{1}\n'.format(cname, ename))

    # Check if effect has no variation
    cause_sd = numpy.std(cause)
    effect_sd = numpy.std(effect)
    if cause_sd == 0.0 or effect_sd == 0.0:
        sys.stderr.write('No variation cause or effect time series; skipping analysis.\n')
        return
    else:
        # Identify delay at which autocorrelation drops to 1/e
        ac_delay, autocorr = pyembedding.autocorrelation_threshold_delay(effect, 1.0/numpy.e)
        sys.stderr.write('  ac_delay, autocorr = {0}, {1}\n'.format(ac_delay, autocorr))
        
        # Calculate Theiler window (limit on closeness of neighbors in time)
        theiler_window = min(ccm_settings['max_theiler_window'], 3 * ac_delay)
        sys.stderr.write('  theiler_window = {0}\n'.format(theiler_window))
        assert theiler_window < effect.shape[0]

        embedding_algorithm = ccm_settings['embedding_algorithm']
        assert embedding_algorithm == 'tajima_projection'
        if embedding_algorithm == 'tajima_projection':
            run_analysis_tajima_projection(cname, cause, ename, effect, theiler_window, db, rng, ccm_settings)