Skip to content

[BUG] WeightRegression produces incorrect regression when thru_orig = False #1024

@henrydingliu

Description

@henrydingliu

Are you on the latest chainladder version?

  • Yes, this bug occurs on the latest version.

Describe the bug in words

came across a bug in _fit_OLS while trying to recreate chapter 11. likely culprit is a missing w (or two) around here. should be a quick PR for the students in our contributor group

How can the bug be reproduced?

test = cl.Triangle(
    data = {
        'value':[100,200,300,400,500,0,0,0],
        'weight':[1,1,1,1,1,0,0,0],
        'ay': [2001,2002,2003,2004,2005,2006,2007,2008],
        'dev':[2008,2008,2008,2008,2008,2008,2008,2008],
    },
    origin = 'ay',
    development='dev',
    columns=['value','weight'],
    cumulative=True,
)
reg = cl.WeightedRegression(
    axis=2,
    thru_orig=False,
    xp=test.get_array_module()
).fit(
    np.ones((1,1,8,1)) * test.origin.year.values[None,None,:,None],
    test['value'].values,
    test['weight'].values
)
reg.slope_

What is the expected behavior?

100

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Great First Contribution! 🌱Beginner friendly tickets with narrow scope and huge impact. Perfect to get your feet wet!

    Type

    Priority

    Urgent

    Effort

    Low

    Scope

    Codebase

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions