0% found this document useful (0 votes)
44 views

Practical Test 1

The document discusses time series analysis of stock price data. It contains the following key points: 1. Stock price data from 2000-2021 is extracted and plotted. The data is stationary. 2. Moving averages of order 3 and 5 are calculated and plotted to smooth the data. 3. An ARIMA model is fitted to the data and found to be ARIMA(1,2,0). The model is used to forecast future stock prices over the next 5 years.

Uploaded by

vansh.sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Practical Test 1

The document discusses time series analysis of stock price data. It contains the following key points: 1. Stock price data from 2000-2021 is extracted and plotted. The data is stationary. 2. Moving averages of order 3 and 5 are calculated and plotted to smooth the data. 3. An ARIMA model is fitted to the data and found to be ARIMA(1,2,0). The model is used to forecast future stock prices over the next 5 years.

Uploaded by

vansh.sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

2140818.

R
2024-01-31
# 2140818 Vansh Sharma
# Practical Test

library(readxl)
data1<- read_excel("AXISBANK.xlsx")
View(data1)

library(astsa)
library(tseries)

## Registered S3 method overwritten by 'quantmod':


## method from
## as.zoo.data.frame zoo

library(forecast)

##
## Attaching package: 'forecast'

## The following object is masked from 'package:astsa':


##
## gas

#Q1)Comment on the structure of the data based on the time series components.

summary(data1)

## Date Symbol Series Prev Close

## Length:5306 Length:5306 Length:5306 Min. : 22.15

## Class :character Class :character Class :character 1st Qu.: 230.95

## Mode :character Mode :character Mode :character Median : 519.45

## Mean : 585.76

## 3rd Qu.: 877.31

## Max. :2023.35

##

## Open High Low Last


## Min. : 21.0 Min. : 23.7 Min. : 21.0 Min. : 22.15
## 1st Qu.: 232.0 1st Qu.: 235.1 1st Qu.: 227.1 1st Qu.: 230.55
## Median : 520.1 Median : 528.4 Median : 512.0 Median : 519.42
## Mean : 586.5 Mean : 596.5 Mean : 575.6 Mean : 585.90
## 3rd Qu.: 880.1 3rd Qu.: 898.0 3rd Qu.: 852.8 3rd Qu.: 877.27
## Max. :2034.4 Max. :2043.0 Max. :2002.6 Max. :2022.55
##
## Close VWAP Volume Turnover

## Min. : 22.15 Min. : 22.17 Min. : 2850 Min. :8.275e+09

## 1st Qu.: 230.97 1st Qu.: 231.12 1st Qu.: 284217 1st Qu.:5.869e+12

## Median : 519.50 Median : 519.50 Median : 1656966 Median :1.653e+14

## Mean : 585.89 Mean : 586.08 Mean : 4527938 Mean :2.740e+14

## 3rd Qu.: 877.31 3rd Qu.: 875.81 3rd Qu.: 5515245 3rd Qu.:3.457e+14

## Max. :2023.35 Max. :2020.31 Max. :120541914 Max. :7.180e+15

##

## Trades Deliverable Volume %Deliverble


## Mode:logical Min. : 5809 Min. :0.0750
## TRUE:2456 1st Qu.: 257313 1st Qu.:0.3475
## NA's:2850 Median : 768768 Median :0.4598
## Mean : 1990907 Mean :0.4670
## 3rd Qu.: 2652520 3rd Qu.:0.5739
## Max. :94901165 Max. :0.9830
## NA's :509 NA's :509

class(data1)

## [1] "tbl_df" "tbl" "data.frame"

ts.plot(data1$Close)
data3=ts(data1$Close,start = 2000,end=2021,frequency=1)
class(data3)

## [1] "ts"

ts.plot(data3)
acf(data3)
#Q2)Discuss the mathematical model for the chosen data sets. Is the data
stationary in nature? Comment.

#Q3)Calculate the moving average of order 3 and 5 and comment on the same.
ma3<-ma(data3,order=3)
ma5<-ma(data3,order=5)

par(mfrow = c(1, 2))


ts.plot(ma3, main = "3-Point Moving Average")
ts.plot(ma5, main = "5-Point Moving Average")
#Q4)Fit a suitable predictive model for the DAX index:

# Fit ARIMA model


fit <- auto.arima(data3)

# Summary of the ARIMA model


summary(fit)

## Series: data3
## ARIMA(1,2,0)
##
## Coefficients:
## ar1
## -0.6605
## s.e. 0.1551
##
## sigma^2 = 1.026: log likelihood = -28.41
## AIC=60.82 AICc=61.53 BIC=62.81
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.197092 0.9414755 0.7222051 0.6679452 2.815029 0.6651889
## ACF1
## Training set -0.1468044

predicted_values <- forecast(fit, h = 5)


# Print predicted values
print(predicted_values)

## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2022 39.51790 38.21959 40.81621 37.53230 41.50350
## 2023 42.22305 40.05279 44.39332 38.90392 45.54219
## 2024 44.87057 41.37028 48.37087 39.51734 50.22381
## 2025 47.55616 42.69077 52.42155 40.11519 54.99713
## 2026 50.21661 43.75012 56.68309 40.32697 60.10624

You might also like