Skip to Content
Analysis of Financial Time Series, Third Edition
book

Analysis of Financial Time Series, Third Edition

by RUEY S. TSAY
August 2010
Intermediate to advanced
701 pages
18h 7m
English
Wiley
Content preview from Analysis of Financial Time Series, Third Edition

Appendix B: R and S-Plus Commands for Neural Network

The following commands are used in R or S-Plus to build the 3–2–1 skip-layer feed-forward network of Example 4.7. A line starting with # denotes a comment. The data file is m-ibmln.txt. The library used is nnet.

# load the data into R or S-Plus workspace.

x_scan(file=‘m-ibmln.txt’)

# select the output: r(t)

y_x[4:864]

# obtain the input variables: r(t-1), r(t-2), and r(t-3)

ibm.x_cbind(x[3:863]_,x[2:862],x[1:861])

# build a 3-2-1 network with skip layer connections

# and linear output.

ibm.nn_nnet(ibm.x,y,size=2,linout=T,skip=T,maxit=10000,

decay=1e-2,reltol=1e-7,abstol=1e-7,range=1.0)

# print the summary results of the network

summary(ibm.nn)

# compute \& print the residual sum of squares.

sse_sum((y-predict(ibm.nn,ibm.x))ˆ2)

print(sse)

#eigen(nnet.Hess(ibm.nn,ibm.x,y),T)$values

# setup the input variables in the forecasting subsample

ibm.p_cbind(x[864:887],x[863:886],x[862:885])

# compute the forecasts

yh_predict(ibm.nn,ibm.p)

# The observed returns in the forecasting subsample

yo_x[865:888]

# compute \& print the sum of squares of forecast errors

ssfe_sum((yo-yh)ˆ2)

print(ssfe)

# quit S-Plus or R

q()

Exercises

4.1 Consider the daily simple returns of Johnson & Johnson stock from January 1998 to December 2008. The data are in the file d-jnj9808.txt or can be obtained from CRSP. Convert the returns into log returns in percentage. (a) Build a GJR model for the log return series. Write down the fitted model. Is the leverage ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Time Series Analysis: Forecasting and Control, Fourth Edition

Time Series Analysis: Forecasting and Control, Fourth Edition

George E. P. Box, Gregory C. Reinsel, Gwilym M. Jenkins
Quantitative Finance

Quantitative Finance

Maria C. Mariani, Ionut Florescu

Publisher Resources

ISBN: 9781118017098Purchase book