Stat 255 Project 3 due Wednesday, April 22 Write R code to solve the following problems, Make sur...
Stat 255 Project 3 due Wednesday, April 22 Write R code to solve the following problems, Make sure to include descriptions and explanation in your cod Save them in a file named project3-yourname.R and email them to ysarolousi.edu be date. A model for stock prices Let S, be the closing price of a stock at the end of day j, where j model for the evolution of the future daily closing prices: 0,1,2,... Given So, we assume the following σ2 for j-1. 2. 3. . . ., where the parameters μ and σ are estimated from the historical prices and Z1,Z2.23-' . are independent, standard normal random variables. vector of daily closing prices So. S1,S2, SN simulated graphs and observe them. Explain the effect of the u parameter on the price curve. Problem 1. Simulating S. Write a function that takes as input So, μ.σ and N, then returns a simulated Problem 2. Understanding the μ parameter. Assume that So-1000, σ-0.01. plot the daily price vectors for μ-, 0.01, 0.005, 0.05 for N 200 on the same window using different colors. Generate several Problem 3. Understanding the σ parameter. Assume that So-1000, μ-0.01. plot the daily price vectors for a0.01,0.1,0.15 for N 200 on the same window using different colors. (Specify the y range to be from 0 to 8000 for a better view.) Generate several simulated graphs and observe them. Explain the effect of the σ parameter on the price curve. Problem 4. Estimating μ and σ from historical data. Suppose that we have the historical daily closing prices Si, S2, Sk of a certain stock. Define the sequence of daily log-returns by log(S2/Si). log(Ss/S2), log(Si/S3), ..., log(Sk/Sk-1). The mean and the standard deviation of this sequence can be used as the estimates of (μ-σ2/2) and σ, respectively. Write a function that takes as input a vector x of historical daily closing prices and returns μ and σ in a vector Test your function with the price vector created with the parameters So-100011-0.01, o-01,N-200 Note that you won't be able to recover the exact values of μ and σ but they should be close. Problem 5. The expected price on the last day. Get the file google3yr.csv from Blackboard and read it into R. One of the columns has the daily closing prices of the Google stock (GOOG) for the last 3 years. (We only consider the trading days.) Estimate the μ and σ in our inodel using the data and your function from the previous part. Use those parameters to simulate the daily price vector for the following 200 days. Plot the historical prices (black) and the simulated future prices (red) using types"h". Run your code several times to see different scenarios on the graph. the future prices and averaging the last day values. compare it to your simulated value. Finally, estimate the expected price of the Google stock 200 days later by creating 10.000 possible scenarios of Theoretically, the last day price has the expected value EISN] So exp(uN). Compute it with N 200 and
Stat 255 Project 3 due Wednesday, April 22 Write R code to solve the following problems, Make sure to include descriptions and explanation in your cod Save them in a file named project3-yourname.R and email them to ysarolousi.edu be date. A model for stock prices Let S, be the closing price of a stock at the end of day j, where j model for the evolution of the future daily closing prices: 0,1,2,... Given So, we assume the following σ2 for j-1. 2. 3. . . ., where the parameters μ and σ are estimated from the historical prices and Z1,Z2.23-' . are independent, standard normal random variables. vector of daily closing prices So. S1,S2, SN simulated graphs and observe them. Explain the effect of the u parameter on the price curve. Problem 1. Simulating S. Write a function that takes as input So, μ.σ and N, then returns a simulated Problem 2. Understanding the μ parameter. Assume that So-1000, σ-0.01. plot the daily price vectors for μ-, 0.01, 0.005, 0.05 for N 200 on the same window using different colors. Generate several Problem 3. Understanding the σ parameter. Assume that So-1000, μ-0.01. plot the daily price vectors for a0.01,0.1,0.15 for N 200 on the same window using different colors. (Specify the y range to be from 0 to 8000 for a better view.) Generate several simulated graphs and observe them. Explain the effect of the σ parameter on the price curve. Problem 4. Estimating μ and σ from historical data. Suppose that we have the historical daily closing prices Si, S2, Sk of a certain stock. Define the sequence of daily log-returns by log(S2/Si). log(Ss/S2), log(Si/S3), ..., log(Sk/Sk-1). The mean and the standard deviation of this sequence can be used as the estimates of (μ-σ2/2) and σ, respectively. Write a function that takes as input a vector x of historical daily closing prices and returns μ and σ in a vector Test your function with the price vector created with the parameters So-100011-0.01, o-01,N-200 Note that you won't be able to recover the exact values of μ and σ but they should be close. Problem 5. The expected price on the last day. Get the file google3yr.csv from Blackboard and read it into R. One of the columns has the daily closing prices of the Google stock (GOOG) for the last 3 years. (We only consider the trading days.) Estimate the μ and σ in our inodel using the data and your function from the previous part. Use those parameters to simulate the daily price vector for the following 200 days. Plot the historical prices (black) and the simulated future prices (red) using types"h". Run your code several times to see different scenarios on the graph. the future prices and averaging the last day values. compare it to your simulated value. Finally, estimate the expected price of the Google stock 200 days later by creating 10.000 possible scenarios of Theoretically, the last day price has the expected value EISN] So exp(uN). Compute it with N 200 and