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

Bootstrap for linear regression could return NaN #111

Open
Shimuuar opened this issue Nov 17, 2016 · 1 comment
Open

Bootstrap for linear regression could return NaN #111

Shimuuar opened this issue Nov 17, 2016 · 1 comment
Milestone

Comments

@Shimuuar
Copy link
Collaborator

Problem is simple. During resampling we can get sample where all x are same. This means we get singular matrix when solving linear equation and answer will be NaN which contaminate everything.

Originally reported as haskell/criterion#65

@RyanGlScott
Copy link
Member

BTW, I had to update my minimal example in haskell/criterion#65 (comment) in order to make it work with statistics-0.14:

$ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /Users/rscott/.ghci
λ> :m + System.Random.MWC Statistics.Regression Data.Word Statistics.Types
λ> import qualified Data.Vector.Unboxed as U
λ> :set -XOverloadedLists 
λ> gen <- initialize ([1..1000] :: U.Vector Word32)
λ> bootstrapRegress gen 1000 (mkCL 0.95) olsRegress [[1.0,2.0,3.0,4.0]] [0.4834418371319771,0.9643802028149366,1.4471413176506758,1.9452479053288698]
([Estimate {estPoint = 0.48681793194264117, estError = ConfInt {confIntLDX = 5.879566259681779e-3, confIntUDX = 4.313440807164948e-3, confIntCL = mkCLFromSignificance 5.0000000000000044e-2}},Estimate {estPoint = -6.992014124988053e-3, estError = ConfInt {confIntLDX = 4.018643125892002e-2, confIntUDX = 9.495485574005886e-3, confIntCL = mkCLFromSignificance 5.0000000000000044e-2}}],Estimate {estPoint = 0.999930103564569, estError = ConfInt {confIntLDX = 5.246837438233065e-5, confIntUDX = NaN, confIntCL = mkCLFromSignificance 5.0000000000000044e-2}})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants