beta
Syntax
beta(Y, X)
Details
Return the coefficient estimate of an ordinary-least-squares regression of Y on X (with intercept).
Difference from Python’s scipy.stats.beta:
scipy.stats.beta is a beta continuous random variable object for
calculating probability density, distribution functions, random variates, and
related statistics. DolphinDB’s beta is a statistical
regression function that returns the OLS regression coefficient of Y on
X.
Difference from Python TA-Lib’s BETA: TA-Lib’s BETA(high,
low, timeperiod=5) is a rolling technical-analysis statistic. It
calculates beta on the rate-of-change series of high and low over each
window. DolphinDB’s beta(Y, X) calculates one OLS regression
coefficient over the full input when vectors are specified. To reproduce TA-Lib’s
indicator behavior, use DolphinDB’s TA module ta::beta.
Parameters
Y and X are vectors of the same length.
Returns
A DOUBLE scalar/vector/table.
Examples
x=1 3 5 7 11 16 23
y=0.1 4.2 5.6 8.8 22.1 35.6 77.2;
beta(y,x);
// output: 3.378632
