Code Monkey home page Code Monkey logo

Comments (8)

mages avatar mages commented on July 29, 2024 1

Residuals

The way the above paper and you calculate the residuals is different to the rstandard method in R, which is used by residual.MackChainLadder. See for example the following entries on Stackoverflow here and here.

The following R statement will give you the proportional factor difference between your calculated residuals and the standardised R output (Std R Resdiuals/ Std Data Residuals):

RAAmacksa <- MackChainLadder(RAA, alpha = 0, est.sigma="Mack")
lapply(RAAmacksa[["Models"]], function(model) sqrt(1-lm.influence(model, do.coef = FALSE)$hat))

sigma

The missing sigma value is calculated using the formula in Mack's 1999 paper on page 363. Entering the formula into your spreadsheet =SQRT(MIN(I44^4/H44^2,MIN(I44^2,H44^2))) produces the value your getting from R.

from chainladder.

mages avatar mages commented on July 29, 2024

Please provide a minimal reproducible example in R.

from chainladder.

Vinoths17 avatar Vinoths17 commented on July 29, 2024

My R code could be found below... I have attached the R console output in an excel file.
R Std. Residuals.xlsx

#Plotting RAA data
plot(RAAtri)
#ATA of RAA
coef(chainladder(RAAtri))
###########1:Mack method using straight average age-to-age factors##########
RAAmacksa <- MackChainLadder(RAAtri,alpha = 0, est.sigma="Mack")
# ATA of MACK method
RAAmacksa$f
# (S.D)Standard errors of the chain-ladder age-to-age factors
RAAmacksa$f.se
# (S.E)Standard errors of the true chain-ladder age-to-age factors
RAAmacksa$F.se
# Standard Deviation 
RAAmacksa$sigma
#simple average ATA FULL Mack triangle
RAAmacksa$FullTriangle
ChainLadder:::residuals.MackChainLadder(chainladder(RAAtri))
# simpla average residual of mack
resid(RAAmacksa)
plot(RAAmacksa)

from chainladder.

mages avatar mages commented on July 29, 2024

Please try to be more helpful by providing detailed code with comments. An Excel file is not that helpful. Please replicate your Excel calculations in R. Be specific about where you the think the current code is incorrect, e.g. point to the relevant lines in the R code hosted on GitHub.

from chainladder.

Vinoths17 avatar Vinoths17 commented on July 29, 2024

These are the codes to be very precise. I replicated R calculations in excel which I have already attached.

RAAmacksa <- MackChainLadder(RAAtri,alpha = 0, est.sigma="Mack")
resid(RAAmacksa) 

standard.residuals which you get as part of the output does not look correct.

Another issue:

RAAmacksa$F.se and  RAAmacksa$sigma seems to be picking "0.008580526" as standard deviation for the link development ratio of 1.009. 

RAAmacksa$sigma
[1] 12.340461705  0.474090850  0.317091093  0.066795689  0.074660819  0.050245830
[7]  **0.008580526**  0.021344747  **0.008580526**

I could not locate the exact codes in GitHub but they start from line 580 and ends at 610.

from chainladder.

Vinoths17 avatar Vinoths17 commented on July 29, 2024

For cross checking all that needs to be done is run the RAA data with mack chain ladder code using alpha = 0.

The standardized residuals of the all year's simple average of the link development ratio can be cross checked with page number 10 of the paper....
"Flexible Factor Chain Ladder Model: A Stochastic Framework for Reasonable Link Ratio Selections" by Emanuel Bardis and Ali Majidi; and Daniel Murphy.
Like I mentioned earlier the RAAmacksa$F.se and RAAmacksa$sigma provides standard deviation of 0.008580526 for the link development factor of 1.009. which must not be there in my view.

from chainladder.

Vinoths17 avatar Vinoths17 commented on July 29, 2024

About the sigma.... I am assuming thar Mr.Thomas Mack would have wanted it to be like that for some purpose.... however in the normal chain ladder we would not expect a standard deviation...am I correct?
Residuals
Is it possible to use what Mr.Murphy has suggested unlike what R is picking up by default? Could that option be provided for the users? My understanding is that results of both the methods are not completely off from each other.

from chainladder.

mages avatar mages commented on July 29, 2024

I'd rather have the package consistent with the original paper and R's approach of calculating standardised residuals. However, feel free to fork the repository and change the code to your own requirements.

from chainladder.

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.