Ask any Statistics/Probability/Math Question
What is Stock Market Return?
Returns that are generated by the investors from the stock market are termed as Stock Market Returns. One of the sources of such return is the dividends of the companies. It is by means of trading in secondary market that one can generate stock market returns. Moreover, returns can be positive or negative and they vary and are subjected to market risks. Such return may change from one investor to another and this change depends on the quality of stock market analysis and also on the risk taken by the investor. Thus stock market returns are not homogeneous.
How do You Predict Stock Market Returns in R?
The most exciting thing in R is that it contains updated and extended libraries of scripts. The stats library is one such library that is present in R. The following is the statement which will help you to import the stats library:
library(stats)
help(stats)
After you are done with this, you need to import data in R. Consider an example: You may be interested to predict a 5 day forecast based on autoregressive integrated moving average model.
The Steps are As Follows:
>mydata<read.table( file.choose(), sep=",")
There are both linear and non linear models of different levels in time series analysis. Box Jenkins is linear model and the simplest one. Now , following is the non seasonal autoregressive moving average model with order p and q:
Y[t] = α[1]Y[t1] + ... + α[p]Y[tp] + e[t] + β[1]£[t1] + ... + β[q]£[tq]
Where Y denotes the time series of stock price.
t denotes time index.
α denotes the parameters of AR(p).
β denotes the parameter of MA(q.
£ denotes random error ~iid N(Ó,?^2)
Autoregressive Moving Average Models do not possess long term trend and are stationary. You need to choose appropriate p and q for making the model stationary. You can run a simulation for ARMA model and this is optional.
Step 2:
>Model1 <arima(mdata1, order=c(1,1,2))
Predictions:
>predict(Model1,5)
5 denotes the number of trading days.
You can now obtain the results or the output of 5 day predictions. So with the help of R language you can predict stock market returns.
