[SOLVED] STAT823 Homework 13-Writing R Functions

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon HW13-5fnyjg.zip (2266.6 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Using R Markdown in R Studio, complete the following questions. Launch RStudio and open a new RMarkdown file or use the class RMarkdown template provided and save it on your working directory as a .Rmd file. At the end of the activity, save your pdf generated from RMarkdown+Knitr and submit your homework on the Blackboard.

 

  1. Write an R function for computing the value of

f(x) = e−x2

and test it for a vector x = c(0,1,100).

  1. Write an R function to compute the sample excess kurtosis given by

1 Pni=1(xi − x¯)4

g2 = 1nPn (xi − x¯)22 − 3

i=1 n

for a given vector x = (x1,··· ,xn), where x¯ is the average of the elements of x. Test the function for a vector x = 1:10.

  1. Suppose Jane wishes to take out a mortgage on a house. She wants to know what her periodic payments will be. If P is the initial amount mortgaged, r is the effective interest rate, and n is the length of the mortgage, then the periodic payment R is given by

Pr

R =

1 − (1 + r)−n

  • Construct a function which employs this formular
  • Calculate Jane’s monthly payments, if the initial amount is $100,000, the interest rate is 1% and the number of interest conversions periods is 300.
  1. Suppose payments of P dollars are deposited annually into a bank account which earns constant interest r per year. What is the accumulated value of the account at the end

Page -1- of 2

Lesson 13: Homework                                                             STAT/BIOS 823: Writing R functions

of n years, supposing deposits are made at the end of each year? The total amount at the end of n years is given by the expression (1 + r)n − 1

n−1

Amount = P(1 + r)               + ··· + P(1 + r) + P = P

r

(a) Write an R function to compute the accumulated amounts after n = 10 years, with periodic payments P = $400 with a vector of interest rates r ranging from

0.01 to 0.2 by increments of 0.01.

  • Produce a line plot of the amounts (y-axis) against the interest rates (x-axis)
  • Optional question: Write a single function to perfom both parts (a) and (b) above.
  • HW13-5fnyjg.zip