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.
- Write an R function for computing the value of
f(x) = ex2
and test it for a vector x = c(0,1,100).
- 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.
- 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 Janes monthly payments, if the initial amount is $100,000, the interest rate is 1% and the number of interest conversions periods is 300.
- 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
n1
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.

![[Solved] STAT823 Homework 13-Writing R Functions](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] STAT823 Homework 11-Logistic Regression](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.