def __init__(self, input=None, ij=None, order=None, max_order=10, criterion=utils.bayesian_information_criterion, n_freqs=1024): """ Initializer for the GrangerAnalyzer. Parameters ---------- input: nitime TimeSeries object ij: List of tuples of the form: [(0, 1), (0, 2)], etc. These are the indices of pairs of time-series for which the analysis will be done. Defaults to all vs. all. order: int (optional) The order of the process. If this is not known, it will be estimated from the data, using the information criterion max_order: if the order is estimated, this is the maximal order to estimate for. n_freqs: int (optional) The size of the sampling grid in the frequency domain. Defaults to 1024 criterion: XXX """ self.data = input.data self.sampling_rate = input.sampling_rate self._n_process = input.shape[0] self._n_freqs = n_freqs self._order = order self._criterion = criterion self._max_order = max_order if ij is None: # The following gets the full list of combinations of # non-same i's and j's: x, y = np.meshgrid(np.arange(self._n_process), np.arange(self._n_process)) self.ij = zip(x[tril_indices_from(x, -1)], y[tril_indices_from(y, -1)]) else: self.ij = ij
def __init__(self, input=None, ij=None, order=None, max_order=10, criterion=utils.bayesian_information_criterion, n_freqs=1024): """ Initializer for the GrangerAnalyzer. Parameters ---------- input: nitime TimeSeries object ij: List of tuples of the form: [(0, 1), (0, 2)], etc. These are the indices of pairs of time-series for which the analysis will be done. Defaults to all vs. all. order: int (optional) The order of the process. If this is not known, it will be estimated from the data, using the information criterion max_order: if the order is estimated, this is the maximal order to estimate for. n_freqs: int (optional) The size of the sampling grid in the frequency domain. Defaults to 1024 criterion: XXX """ self.data = input.data self.sampling_rate = input.sampling_rate self._n_process = input.shape[0] self._n_freqs = n_freqs self._order = order self._criterion = criterion self._max_order = max_order if ij is None: # The following gets the full list of combinations of # non-same i's and j's: x, y = np.meshgrid(np.arange(self._n_process), np.arange(self._n_process)) self.ij = list(zip(x[tril_indices_from(x, -1)], y[tril_indices_from(y, -1)])) else: self.ij = ij
def correlation(self): """ The correlation between all combinations of trials Returns ------- (r,e) : tuple r is the mean correlation and e is the mean error of the correlation (with df = n_trials - 1) """ c = np.corrcoef(self.input.data) c = c[tril_indices_from(c, -1)] return np.mean(c), stats.sem(c)
def correlation(self): """ The correlation between all combinations of trials Returns ------- (r,e) : tuple r is the mean correlation and e is the mean error of the correlation (with df = n_trials - 1) """ c = np.corrcoef(self.input.data) c = c[tril_indices_from(c, -1)] return np.mean(c), stats.sem(c)