The ccostr package includes a dataset called “hcost”. The dataset comes from the Stata package of the same name (Chen, Rolfes, and Zhao 2015), and we can therefore use it both as an example and to verify that the two packages reach similar estimates. First we look at the data:

```
head(hcost)
#> # A tibble: 6 x 7
#> id start stop cost trt delta surv
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 1 3694 0 0 575
#> 2 1 1 9 1 0 0 575
#> 3 1 1 9 12 0 0 575
#> 4 1 1 34 106 0 0 575
#> 5 1 1 237 68 0 0 575
#> 6 1 1 237 86 0 0 575
```

Now we use the ccmean function with a limit of 4 years (1461 days), we also add the interpolation term which affects the interpolation of cost between two observed time points. By default this parameter is set to zero, but to replicate the results of the Stata implementation we set it to 1.

```
est <- ccmean(hcost, L = 1461, addInterPol = 1)
est
#> ccostr - Estimates of mean cost with censored data
#>
#> Observations Individuals FullyObserved Limits TotalTime MaxSurvival
#> N 9704 160 61 1461 122401 2082
#>
#> Estimate Variance SE 0.95LCL 0.95UCL
#> AS 63725.42 19193502 4381.039 55138.59 72312.26
#> CC 74779.13 37572385 6129.632 62765.05 86793.21
#> BT 86175.16 51593885 7182.888 72096.70 100253.62
#> ZT 80134.84 23726332 4870.968 70587.74 89681.94
#>
#> Mean survival time: 1165.04 With SE: 41.94
```

These estimates are similar to what is found with the hcost Stata package. We can also plot these with the included generic plot function:

Chen, Shuai, Jennifer Rolfes, and Hongwei Zhao. 2015. “Estimation of Mean Health Care Costs and Incremental Cost-effectiveness Ratios with Possibly Censored Data.” *The Stata Journal: Promoting Communications on Statistics and Stata* 15 (3): 698–711. https://doi.org/10.1177/1536867X1501500305.