def calc_ar1_dof_pearsonr(phi1, phi2=1.0, n=1):
    """Calculate degrees of freedom for correlation between
    two autocorrelated time series with autocorrelation coefficients
    phi1 and phi2

    Parameter
    ----------
    phi1, phi2 : float
        Lag-one autocorrelations of the two timeseries
    n : int
        Length of the time series

    Return
    -------
    dof_eff : float
        Degrees of freedom to be used for the null-hypothesis significance
        test of the pearson correlation coefficient

    References
    ----------
      ..Hu, J. et al., Earth Planet. Sci. Lett., 2017,
        Correlation-based interpretations of paleocliamte data -
        where statistics meet past climates.
    """
    dof_eff = n * (1 - phi1 * phi2) / (1 + phi1 * phi2)
    return dof_eff