# Vehicle Depreciation

We can calculate the rate of depreciation for vehicles at any valuation. We assume that the `current_date` is some time after the vehicle purchase and that the model `year` of the vehicle was roughly when the vehicle was purchased (though a more exact purchase date would of course be more accurate. We also assume that when the model `year` is the same as the current year, that the vehicle was purchased 1 month ago.&#x20;

For more information on the calculation of annualized rate of deprecation, see, for example, <https://www.investopedia.com/terms/a/appreciation.asp>.

{% code overflow="wrap" lineNumbers="true" %}

```python
df['years_since_model_year'] = \
            (df['current_date'].map(lambda x: x.replace(tzinfo=None)) \
                    - pd.to_datetime(df['year'], format = '%Y'))/np.timedelta64(1,'Y')
                                          df['annualized_rate_of_appreciation'] = 100*((df['retail_price']/df['msrp']).pow(1/df['years_since_model_year'].replace(0,1.0/12.0)) - 1)

```

{% endcode %}

For aggregating rate of depreciation for DIMO-connected vehicles by `make` we only use vehicles assumed to be owned for at least one year (i.e. the model `year` ended at least one year ago), obtaining the following&#x20;

<figure><img src="https://3212476574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Foh9c3w7RI0Bl5tVCxcyz%2Fuploads%2F3XRSony8l1XcVM629qV5%2Favg_annualized_rate_depr_vs_msrp_make.png?alt=media&#x26;token=17e00edb-a2f4-4628-a0f3-363f535d8d1a" alt=""><figcaption><p>Average Rate of Depreciation by <code>make</code></p></figcaption></figure>
