Skip to content

Commit

Permalink
rhub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gpitt71 committed May 15, 2024
1 parent 955684b commit 7e05f30
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 14 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Authors@R:
family = "Villegas",
role = c("aut", "cph"),
email="[email protected]"))
Description: Implementation of the age-period-cohort models for the claim development
introduced in Pittarello G., Hiabu M., and Villegas A. (2024) <doi:10.48550/arXiv.2301.03858>.
Description: Implementation of the age-period-cohort models for the claim development presented in the manuscript 'Replicating and extending chain-ladder via an age-period-cohort structure on the claim development in a run-off triangle' <doi:10.48550/arXiv.2301.03858>.
URL: https://github.com/gpitt71/clmplus
BugReports: https://github.com/gpitt71/clmplus/issues
License: GPL (>= 2)
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ S3method(plot,clmpluspredictions)
S3method(predict,clmplusmodel)
export(AggregateDataPP)
export(clmplus)
importFrom(forecast,Arima)
importFrom(forecast,forecast)
9 changes: 7 additions & 2 deletions R/globalVariables.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#' @importFrom forecast Arima
#' @importFrom forecast forecast


# Create environment ----
pkg.env <- new.env()

Expand Down Expand Up @@ -468,6 +472,7 @@ pkg.env$fcst <- function(object,
gk.order=c(1,1,0),
ckj.order=c(0,1,0)){


J=dim(object$Dxt)[2]

rates=array(.0,dim=c(J,J))
Expand All @@ -489,10 +494,10 @@ pkg.env$fcst <- function(object,

if(gk.fc.model=='a'){

gc.model <- forecast::Arima(object$gc[1:gc.nNA],
gc.model <- Arima(object$gc[1:gc.nNA],
order = gk.order,
include.constant = T)
gc.f <- forecast::forecast(gc.model,h=(length(object$cohorts)-gc.nNA))
gc.f <- forecast(gc.model,h=(length(object$cohorts)-gc.nNA))


}else{
Expand Down
16 changes: 8 additions & 8 deletions R/predictclmplusmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Predict the lower triangle with a \code{clmplus} model.
#'
#' @param clmplusmodel \code{clmplusmodel}, Model to predict from.
#' @param object \code{clmplusmodel}, Model to predict from.
#' @param gk.fc.model \code{character}, model to forecast the cohort component for the last accident period. It can be either arima ('a') or linear model ('l'). Disregarded for models that do not have a cohort effect.
#' @param ckj.fc.model \code{character}, model to forecast the calendar period effect. It can be either arima ('a') or linear model ('l'). Disregarded for models that do not have a period effect.
#' @param gk.order \code{integer}, order of the arima model with drift for the accident year effect extrapolation. Default to (1,1,0).
Expand Down Expand Up @@ -33,7 +33,7 @@
#'
#' @export
#'
predict.clmplusmodel <- function(clmplusmodel,
predict.clmplusmodel <- function(object,
gk.fc.model='a',
ckj.fc.model='a',
gk.order=c(1,1,0),
Expand All @@ -42,17 +42,17 @@ predict.clmplusmodel <- function(clmplusmodel,
...){

# forecasting horizon
J <- clmplusmodel$apc_input$J
J <- object$apc_input$J
# fitted model
model <- clmplusmodel$model.fit
model <- object$model.fit
# occurrences distribution
eta <- clmplusmodel$apc_input$eta
eta <- object$apc_input$eta
# hazard model
hazard.model <- clmplusmodel$apc_input$hazard.model
hazard.model <- object$apc_input$hazard.model
# diagonal
d <- clmplusmodel$apc_input$diagonal[1:J-1]
d <- object$apc_input$diagonal[1:J-1]
# cumulative payments
cumulative.payments.triangle <- clmplusmodel$apc_input$cumulative.payments.triangle
cumulative.payments.triangle <- object$apc_input$cumulative.payments.triangle

if(hazard.model %in% names(pkg.env$models)){

Expand Down
4 changes: 2 additions & 2 deletions man/predict.clmplusmodel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e05f30

Please sign in to comment.