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

MultiChainLadder plot error when NA's in triangle #62

Open
trinostics opened this issue Mar 18, 2019 · 1 comment
Open

MultiChainLadder plot error when NA's in triangle #62

trinostics opened this issue Mar 18, 2019 · 1 comment

Comments

@trinostics
Copy link
Collaborator

When upper left of triangle is NA, plot fails. Here is a simple example:

GenIns[1, 1] <- NA
plot(MultiChainLadder(list(GenIns)))
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ
In addition: Warning message:
In cbind(do.call("rbind", fitted.values), dev) :
number of rows of result is not a multiple of vector length (arg 2)

This appears to be caused in the fitted method. By removing NA's in the variable 'x' (in the "MCL" case) after line 1272 thus
1272: x <- sapply(Triangles, "[", 1:(m-i),i)
x <- x[!is.na(x)]
old 1273: fitted[[i]] <- x%*%diag(B[[i]],nrow=p)
the package compiled and the error went away for me.

I did not thoroughly test, nor test the "GMCL" case.

Perhaps a more elegant solution would utilize each model's fitted method as is currently done for the 'residuals' method, but I did not investigate that.

Thanks,
Dan

R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.3
year 2019
month 03
day 11
svn rev 76217
language R
version.string R version 3.5.3 (2019-03-11)
nickname Great Truth

@trinostics
Copy link
Collaborator Author

Apologies, but that fix did not work when more than one triangle is included:

plot(MultiChainLadder(list(GenIns, RAA)))
Error in x %*% diag(B[[i]], nrow = p) : non-conformable arguments

But this hack after lines 736 and 737 worked:
# fitted values
fitted.values <- fitted(object)
# remove all-NA rows, maintaining matrix structure
fitted.values <- lapply(fitted.values, function(x)
x[rowSums(is.na(x)) != ncol(x), , drop = FALSE])

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

1 participant