Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Standard Deviation for Linear Regression #741

Open
enilno opened this issue Nov 29, 2023 · 2 comments
Open

Create Standard Deviation for Linear Regression #741

enilno opened this issue Nov 29, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@enilno
Copy link

enilno commented Nov 29, 2023

I needed to have standard deviation for linear regression and there was not function for it. so i coded it and if you like you can edit it and add to next version.

def stdevlinreg(close, length: int):
    x_value = close
    stdev = close
    slope = ta.linreg(close=close, length=length, slope=True)
    tsf = ta.linreg(close=close, length=length, tsf=True)
    variance = 0
    for i in range(1, length):
        variance += (x_value.shift(i) - (tsf - i * slope)) ** 2
    stdev = (variance / (length - 1)) ** 0.5
    return stdev

so we can now use it as:
df['stdlinreg'] = stdevlinreg(df['close'], length=15)
and if add to 'linreg' it can be like:
df['stdlinreg'] = ta.linreg(df['close'], length=15, stdev=True)

@enilno enilno added the enhancement New feature or request label Nov 29, 2023
@twopirllc twopirllc added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 29, 2023
@mobley-trent
Copy link

@twopirllc please assign me this issue

@twopirllc
Copy link
Owner

Hello @mobley-trent,

Assignment unnecessary, contributions are always welcome. 😎
Checkout the development branch.
Edit and submit a PR and I'll get to it as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants