Project Title:
NAME: ASWATHY GUNADEEP
EMAIL: aswathygunadeep@gmail.com
COLLEGE / COMPANY: NATIONAL INSTITUTE OF TECHNOLOGY KARNATAKA
setwd("C:/Users/user/Desktop/tarsha systems summer internship/project/data_3plants")
met1.df <- read.csv(paste("plant1-time sort.csv", sep=""))
str(met1.df)
## 'data.frame': 1048575 obs. of 10 variables:
## $ dataid : int 52733463 52728738 52761108 52758796 52719389 52763320 52765532 52751860 52754172 52756484 ...
## $ paramrefid : int 45831866 45831867 45831868 45831869 45831870 45831871 45831872 45831873 45831874 45831875 ...
## $ timestamp : Factor w/ 16760 levels "2017-10-27 18:15:00+00",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ rawvalue : num 0.00011 0 0.00173 0 49.91 ...
## $ processedvalue: num 0.00011 0 0.00173 0 49.91 ...
## $ meterid : int 45830385 45830385 45830385 45830385 45830385 45830385 45830385 45830385 45830385 45830385 ...
## $ tagid : int 3006 3002 3306 3302 2252 2210 2213 2004 2005 2006 ...
## $ interval : int 15 15 15 15 15 15 15 15 15 15 ...
## $ profileid : int 1008 1008 1008 1008 1008 1008 1008 1008 1008 1008 ...
## $ tagname : Factor w/ 30 levels "Active Energy Export Time Integral 5",..: 1 2 3 4 5 6 7 16 17 18 ...
attach(met1.df)
sub1.df <- subset(met1.df[,c(3,4)],tagname=="Avg Power Factor")
View(sub1.df)
sub.df <- subset(sub1.df[,c(2)], sub1.df$rawvalue>"0")
View(sub.df)
The average power factor is 0.41(it has a maximum value of 1).
TIME SERIES ANALYSIS
powerfactor <- as.ts(sub.df)
class(powerfactor)
## [1] "ts"
start(powerfactor)
## [1] 1 1
end(powerfactor)
## [1] 22923 1
plot(powerfactor)
abline(reg=lm(powerfactor~time(powerfactor)))
plot(log(powerfactor))
plot(diff(log(powerfactor)))
The mean and variance does not vary with time and hence it is a stationary series. Since we differentiated it once to make it a stationary time series, d=1.
ARIMA MODEL
library(tseries)
adf.test(diff(log(powerfactor)), alternative=c("stationary","explosive"), k=0)
## Warning in adf.test(diff(log(powerfactor)), alternative = c("stationary", :
## p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: diff(log(powerfactor))
## Dickey-Fuller = -193.68, Lag order = 0, p-value = 0.01
## alternative hypothesis: stationary
We see that the series is stationary enough to do any kind of time series modelling.
par(mfrow=c(1,2))
acf(powerfactor)
pacf(powerfactor)
par(mfrow=c(1,1))
The blue line above shows significantly different values than zero. Clearly, the graph above has a cut off on PACF curve after 3rd lag which means this is mostly an AR(3) process.
acf(log(powerfactor))
par(mfrow=c(1,2))
acf(diff(log(powerfactor)))
pacf(diff(log(powerfactor)))
fit <- arima(log(powerfactor), c(0, 1, 0),seasonal = list(order = c(0, 1, 0),period=4))
pred <- predict(fit, n.ahead = 5*4)
ts.plot(powerfactor,2.718^pred$pred, log = "y", lty = c(1,3))
library(forecast)
forecast(powerfactor,50)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 22924 0.9966992 0.9002354832 1.093163 0.84917070 1.144228
## 22925 0.9961690 0.8818505194 1.110487 0.82133399 1.171004
## 22926 0.9957341 0.8538624789 1.137606 0.77876016 1.212708
## 22927 0.9953775 0.8202883977 1.170467 0.72760182 1.263153
## 22928 0.9950851 0.7840247351 1.206145 0.67229615 1.317874
## 22929 0.9948452 0.7467711997 1.242919 0.61544876 1.374242
## 22930 0.9946485 0.7094923226 1.279805 0.55853977 1.430757
## 22931 0.9944872 0.6727363960 1.316238 0.50241183 1.486562
## 22932 0.9943548 0.6368123504 1.351897 0.44754079 1.541169
## 22933 0.9942463 0.6018868937 1.386606 0.39418435 1.594308
## 22934 0.9941573 0.5680398578 1.420275 0.34246689 1.645848
## 22935 0.9940844 0.5352971160 1.452872 0.29242982 1.695739
## 22936 0.9940245 0.5036509021 1.484398 0.24406280 1.743986
## 22937 0.9939754 0.4730727199 1.514878 0.19732349 1.790627
## 22938 0.9939352 0.4435217119 1.544349 0.15215043 1.835720
## 22939 0.9939021 0.4149501525 1.572854 0.10847148 1.879333
## 22940 0.9938751 0.3873070707 1.600443 0.06620937 1.921541
## 22941 0.9938529 0.3605406318 1.627165 0.02528539 1.962420
## 22942 0.9938346 0.3345996844 1.653070 -0.01437822 2.002048
## 22943 0.9938197 0.3094347399 1.678205 -0.05285678 2.040496
## 22944 0.9938075 0.2849985663 1.702616 -0.09022220 2.077837
## 22945 0.9937974 0.2612465162 1.726348 -0.12654250 2.114137
## 22946 0.9937892 0.2381366766 1.749442 -0.16188159 2.149460
## 22947 0.9937824 0.2156298982 1.771935 -0.19629916 2.183864
## 22948 0.9937769 0.1936897446 1.793864 -0.22985080 2.217405
## 22949 0.9937723 0.1722823912 1.815262 -0.26258811 2.250133
## 22950 0.9937686 0.1513764934 1.836161 -0.29455895 2.282096
## 22951 0.9937655 0.1309430379 1.856588 -0.32580761 2.313339
## 22952 0.9937630 0.1109551868 1.876571 -0.35637506 2.343901
## 22953 0.9937610 0.0913881208 1.896134 -0.38629922 2.373821
## 22954 0.9937593 0.0722188865 1.915300 -0.41561514 2.403134
## 22955 0.9937579 0.0534262492 1.934090 -0.44435526 2.431871
## 22956 0.9937568 0.0349905542 1.952523 -0.47254963 2.460063
## 22957 0.9937558 0.0168935973 1.970618 -0.50022604 2.487738
## 22958 0.9937551 -0.0008814965 1.988392 -0.52741030 2.514920
## 22959 0.9937545 -0.0183503843 2.005859 -0.55412632 2.541635
## 22960 0.9937539 -0.0355276076 2.023035 -0.58039635 2.567904
## 22961 0.9937535 -0.0524266866 2.039934 -0.60624104 2.593748
## 22962 0.9937532 -0.0690602061 2.056567 -0.63167963 2.619186
## 22963 0.9937529 -0.0854398936 2.072946 -0.65673005 2.644236
## 22964 0.9937527 -0.1015766913 2.089082 -0.68140903 2.668914
## 22965 0.9937525 -0.1174808205 2.104986 -0.70573219 2.693237
## 22966 0.9937523 -0.1331618412 2.120666 -0.72971416 2.717219
## 22967 0.9937522 -0.1486287055 2.136133 -0.75336862 2.740873
## 22968 0.9937521 -0.1638898069 2.151394 -0.77670841 2.764213
## 22969 0.9937520 -0.1789530244 2.166457 -0.79974556 2.787250
## 22970 0.9937519 -0.1938257632 2.181330 -0.82249142 2.809995
## 22971 0.9937519 -0.2085149913 2.196019 -0.84495662 2.832460
## 22972 0.9937518 -0.2230272729 2.210531 -0.86715122 2.854655
## 22973 0.9937518 -0.2373687992 2.224872 -0.88908467 2.876588
plot(forecast(powerfactor,50))