R Shiny中的抵押贷款计算器

介绍 (Introduction)

I recently moved out and bought my first apartment. Of course, I could not pay it entirely with my own savings, so I had to borrow money from the bank. I visited a couple of banks operating in my country and asked for a mortgage.

我最近搬出去买了我的第一套公寓。 当然,我不能用自己的积蓄全部支付,所以我不得不从银行借钱。 我拜访了在我国经营的几家银行,并要求抵押。

If you already bought your house or apartment in the past, you know how it goes: the bank analyzes your financial and personal situation and make an offer based on your propensity to repay the bank. You then either accept the offer if you are satisfied with the rate and conditions, or visit another bank if you believe you could receive a better offer. Mortgages and loans are more complicated than that of course, but let’s keep it simple here.

如果您过去曾经购买过房屋或公寓,您就会知道情况如何:银行会分析您的财务和个人状况,并根据您的还款意愿提出要约。 然后,如果对价格和条件感到满意,则可以接受要约;如果您认为可以收到更好的要约,则可以去另一家银行。 抵押和贷款比当然要复杂得多,但是让我们在这里保持简单。

As I kind of like to control and keep a close eye on my personal finances (sometimes a bit too close I must admit), I knew precisely how much I could spend for my monthly mortgage repayment while still being able to cover my living expenses. However, I had no clue how much I could borrow in total for my new apartment given these housing repayments.

由于我喜欢控制并密切注意个人财务状况 (有时我必须承认,这有点太接近了),因此我确切地知道我可以每月花多少钱支付房贷,同时仍然能够支付生活费用。 但是,鉴于这些房屋还款,我不知道我可以为我的新公寓总共借多少钱。

I knew I was not the first person in this case, so I looked online if I could find a R script which would answer my question (and potentially also give me the total cost of the housing loan, including the loan amount and the accumulated interests). I finally found a R script created a while ago by Prof. Thomas Girke.

我知道我不是这种情况下的第一人,因此我在网上寻找是否可以回答我的问题的R脚本(并且还可能给我住房贷款的总成本,包括贷款金额和累计利息) )。 我终于找到了Thomas Girke教授不久前创建的R脚本。

抵押计算器 (Mortgage calculator)

The function in the script was functional and solved my main issue, but I wanted to be able to play more easily with the different settings such as the amount, the duration and the interest rate of the loan.

脚本中的功能可以正常工作并解决了我的主要问题,但是我希望能够在不同的设置(例如贷款的金额,期限和利率)下更轻松地播放。

For this reason, I created a R Shiny app which is available here:

基于这个原因,我创建了一个R Shiny应用程序可以在这里找到:

Mortgage calculator in R Shiny
Mortgage calculator in R Shiny
R Shiny中的抵押贷款计算器

In the meantime, I received an Excel file from a friend working in a Belgian bank which does precisely the same task. I am not an actuary nor a expert in mortgage loan, so with his file I was able to cross check the results and edit the code accordingly.

同时,我从一个在比利时的银行工作的朋友那里收到了一个Excel文件,该文件执行的任务完全相同。 我既不是精算师,也不是抵押贷款方面的专家,因此使用他的文件,我可以交叉检查结果并相应地编辑代码。

The app greatly helped me to know the maximum amount I could borrow from the bank by playing with the three main settings of a mortgage, so it gave me a precise price limit when looking for apartments online.

该应用程序极大地帮助我了解了按揭的三个主要设置,可以从银行借到的最高金额,因此在网上查找公寓时,它为我提供了精确的价格限制。

Note that the app can of course be used for any loan, not only for mortgage.

请注意,该应用程序当然可以用于任何贷款,不仅用于抵押。

如何使用抵押计算器? (How to use the mortgage calculator?)

First, you can find the mortgage calculator here.

首先,您可以在这里找到抵押计算器。

I try to keep all my Shiny apps easy to use for everyone. However, here is how to use it in case it is not intuitive enough:

我尝试使我所有的Shiny应用程序易于使用。 但是,如果它不够直观,可以使用以下方法:

  1. Enter the amount of the loan (i.e., the amount you would like to borrow, do not include downpayment)

    输入贷款金额(即您要借的金额,不包括首期付款)
  2. Enter the annual interest rate in %

    输入年利率(%)
  3. Enter the duration of the loan in years

    输入贷款期限(以年为单位)

On the right panel (or bottom if you use the app on mobile) you will see:

在右侧面板上(如果您在移动设备上使用该应用程序,则在底部),您将看到:

  • a summary repeating the settings you entered,

    重复您输入的设置的摘要,
  • the total cost of the loan (principal and interests included), and more importantly

    贷款的总费用(包括本金和利息),更重要的是
  • the amount of the monthly payments

    每月还款额

A plot representing the percentage attributed to the repayment of the interests and the capital is also displayed. You see that (especially in the first years of the loan), the higher the interest rate and the duration of the loan, the higher the percentage of the monthly repayments is attributed to the repayments of the interests.

还显示了代表归还利息和资本的百分比的图。 您会看到(尤其是在贷款的头几年),利率和贷款期限越高,则每月归还利息的比例就越高。

Finally, the amortization table showing the remaining balance month by month is displayed after the summary and the plot. You can copy, export (in PDF, CSV or Excel) or print this amortization table for further use.

最后,在摘要和绘图之后显示逐月显示剩余余额的摊销表。 您可以复制,导出(以PDF,CSV或Excel格式)或打印此摊销表以备将来使用。

应用程式码 (Code of the app)

Below the entire code in case you would like to enhance the app (feel free to send me your app if you happen to improve it!).

在整个代码下面,以防您想增强应用程序(如果您对它进行了改进,请随时向我发送您的应用程序!)。

Thanks for reading. I hope this mortgage calculator helped you to play with the different settings of a mortgage, and who knows, helped you to decide which house or apartment to buy.

谢谢阅读。 我希望这个抵押计算器可以帮助您使用抵押的不同设置,并且谁知道,可以帮助您确定要购买的房屋或公寓。

As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.

与往常一样,如果您对本文涉及的主题有疑问或建议,请将其添加为评论,以便其他读者可以从讨论中受益。

Disclosure: Note that this application does not include investment advice or recommendations, nor a financial analysis. This application is intended for information only and you invest at your own risks. I cannot be held liable for any decision made based on the information contained in this application, nor for its use by third parties.

披露:请注意,此应用程序不包括投资建议或建议,也不包括财务分析。 此应用程序仅供参考,您自担风险进行投资。 我不对基于本应用程序中包含的信息做出的任何决定或由第三方使用它承担任何责任。

相关文章 (Related articles)

Originally published at https://www.statsandr.com on August 14, 2020.

最初于 2020年8月14日 https://www.statsandr.com 发布

Gain Access to Expert View — Subscribe to DDI Intel

获得访问专家视图的权限- 订阅DDI Intel

翻译自: https://medium.com/datadriveninvestor/mortgage-calculator-in-r-shiny-f6fe1b1fc23b

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值