def lowess(x, y, span=SPAN): "returns y-values estimated using the lowess function in statsmodels." """ for more see statsmodels.nonparametric.smoothers_lowess.lowess """ x, y = map(_plot_friendly, [x, y]) if _isdate(x[0]): x = np.array([i.toordinal() for i in x]) result = smlowess(np.array(y), np.array(x), frac=span) x = pd.Series(result[::, 0]) y = pd.Series(result[::, 1]) lower, upper = stats.t.interval(span, len(x), loc=0, scale=2) std = np.std(y) y1 = pd.Series(lower * std + y) y2 = pd.Series(upper * std + y) return (y, y1, y2)
def lowess(x, y, span=SPAN): "returns y-values estimated using the lowess function in statsmodels." """ for more see statsmodels.nonparametric.smoothers_lowess.lowess """ x, y = map(plot_friendly, [x,y]) if _isdate(x[0]): x = np.array([i.toordinal() for i in x]) result = smlowess(np.array(y), np.array(x), frac=span) x = pd.Series(result[::,0]) y = pd.Series(result[::,1]) lower, upper = stats.t.interval(span, len(x), loc=0, scale=2) std = np.std(y) y1 = pd.Series(lower * std + y) y2 = pd.Series(upper * std + y) return (y, y1, y2)