Giter Club home page Giter Club logo

Comments (3)

cjekel avatar cjekel commented on May 22, 2024

The standard errors are for each model parameter, and represents the standard deviation if you assume that the model is the correct form for each of the model parameters (that assumption includes that the break point locations are correct).

I still need to investigate an approach of a piecewise linear standard deviation... but in the meantime you can calculated the unbiased prediction variance and use it to generate your 95% confidence interval of your model.

I include a function to calculate the sum of squares of the residuals, which is the hard part.

Then all you need to do is calculate the unbiased prediction variance. It's usually easier though to work with standard deviations instead.

# calculate the sum of the square of the residuals
ssr = my_pwlf.fit_with_breaks(my_pwlf.fit_breaks)

# calculate the unbiased standard deviation
sigma = np.sqrt(ssr / (my_pwlf.n_data - my_pwlf.n_parameters))
# sigma can be used as a prediction variance

# plot the results
plt.figure()
plt.plot(x, y, 'o')
plt.plot(xHat, yHat, '-')
plt.fill_between(xHat, yHat - (sigma*1.96), yHat + (sigma*1.96), alpha=0.1,
                 color="r")
plt.show()

https://github.com/cjekel/piecewise_linear_fit_py/blob/master/examples/fitForSpecifiedNumberOfLineSegments_standard_deviation.py

from piecewise_linear_fit_py.

cjekel avatar cjekel commented on May 22, 2024

So I've finally implemented a prediction variance that represents the uncertainty due to the lack of data. My formula is based on one from http://www2.mae.ufl.edu/haftka/vvuq/lectures/Regression-accuracy.pptx Prediction variance is the squared version of standard error. Standard error should not be confused with standard errors.

An example on how to use the prediction variance is found in https://github.com/cjekel/piecewise_linear_fit_py/blob/master/examples/prediction_variance.py

I'll upload a new version to pypi shortly. I believe this change is what you were looking for.

from piecewise_linear_fit_py.

TorsteinSkar avatar TorsteinSkar commented on May 22, 2024

Thank you very much :)

from piecewise_linear_fit_py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.