# Example: Replicating st0399 results

```
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

`library(ccostr)`

The ccostr package includes a dataset called "hcost". The dataset comes from the Stata package of the same name [@Chen2015], 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)`

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
```

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

`plot(est)`