Starting from:

$29.99

Assignment 9 Dipping your toes

MATLAB Assignment 9
, Section A
Please submit this homework as a .m file, with suppressed output. Remember that all lectures and
homeworks may be found at github.com/guybaryosef/ECE210-materials. Homework is due by the
end of the semester to guybymatlab@gmail.com.
1. Dipping your toes: In this question we will be attempting to predict stock prices. More
specifically we will download a csv file that contains Google’s stock value as a time series, for which
you will build an AR model and then use it for forecasting. Remember that an AR model has the
equation:
X(t) = δ +
X
p
n=1
αnr(t − n) + vt (1)
a. A csv file, which stands for ’comma separated variable’, is a file format used to store data
into a spreadsheet, with the columns separated by commas and the rows separated by newline characters. To begin this problem, download and import the file called GOOG.csv from:
github.com/guybaryosef/ECE210-materials/tree/master/homeworks/hw9. In this file you will
find the adjusted closing value of Alphabet’s stock (GOOG) over the past year. For simplicity,
you can ignore the dates associated with the values (weekends and certain holidays will result
in skipped days), and we will instead treat each day as an equal-distanced time step.
b. Run a least squares fit on the time series to find the AR coefficients of an AR model of order
10 (Hint: You can either check out MATLAB’s built-in functions or look back at lesson 10 for
a way to code this). Notice that to be able to do the linear regression, you will need to start
the model-parameters-count number of steps into the time series, thereby shrinking the actual
input by this number.
c. Using the AR model found in the previous section, use equation (1) to forecast the next 10 days
of activity. Unfortunately, if you look at the actual stock over those future 10 days, you will see
that your forecasting was... slightly less than accurate. Not to fret! This is was just an example;
an opprotunity to dip your toes into the world of quantitative finance.
2. Now walk it out... You can think of a random walk as a running (cumulative) sum of i.i.d.
random variables. In the 1-dimensional case, the next value in the series is the current value plus
or minus 1, based on a probability distrubtion.
a. Generate 50 1-D random walks, each with the probability of stepping 1 or −1 equal (50% - 50%),
each with a total of 300 steps.
b. Plot the random walks you generated all on top of one another. There is no need for a plot
legend.
1
c. Now repeat parts (a) and (b) for a random walk where the probability of +1 is 75% and the
probability of −1 is 25%. Is there a difference between these results and your previous plot?
2

More products