R Language loan Monthly data analysis

Source: Internet
Author: User

#================================================================#----------------------------------------------------------------# Step0: Assigning values to individual variables # P: Principal # M: Total month of repayment # I: Annual interest rate # s: Monthly interest rate P=25000I=0.05m= -s=i/ A# Step1: Calculates the month vector T=1: m# Step2: Calculates the monthly repayment amount Monthly.payment= (1+s) ^m*s*p/((1+s) ^m-1) # Step3: Calculates the principal amount to be repaid per month principal.paid.money.t= (1+s) ^ (t1) *s*p/(1+s) ^m-1) # Step4: Calculates the monthly outstanding principal amount Vector principal.remaining= p* (1-((1+s) ^t-1)/((1+s) ^m-1)) # step5: The monthly repayment amount is deducted from the monthly principal quota, and the interest interest.paid.month.t per month is calculated .= Monthly.payment-principal.paid.money.t# Step6: Accumulate the interest paid per month and calculate the total interest Total.interest.paid=sum(interest.paid.month.t) # step7: Displays calculation results monthly.paymenttotal.interest.paidtprincipal.paid.money.tinterest.paid.month.tprincipal.remaining the console # Step8: Plots plot (T,principal.remaining,type) with the non-repaid principal amount vector as the vertical axis for the month vector .="L")

Selected from the "R Language Beginner's Guide"

R Language loan Monthly data analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.