library(ZINARp)
library(ZINAR1)
library(ggplot2)
library(tscount)
library(bayescount)
###Loading the data set
data<-read.csv("C:\Users\sarah 2\Documents\PubMed1.csv")
data
#observed time series
count_time_series<-ts(data$Count)
count_time_series
Descriptive Analysis
summary(count_time_series)
sd(count_time_series)
Distribution
barplot(table(count_time_series), xlab = "Count", ylab = "Frequency")
Line plot
plot(count_time_series)
Histogram
hist(count_time_series, main = "Histogram")
Boxplot
boxplot(count_time_series, main = "Boxplot")
#gg plot
ggplot(data=data, aes(x = Year, y = Count)) +
geom_line(color="blue")+geom_point(color="red")+
labs(title = "Prevalence of Childhood Obesity",
x = "Year",
y = "No.of Obese Children")+theme(plot.title = element_text(color = "blue"))
acf(count_time_series, main="Autocorrelation Function", xlim=c(1.2,30)); axis(side=1,at=1,labels = "1")acf(count_time_series)
pacf(count_time_series,main="Partial Autocorrelation Function")
#FITTING INAR(1) MODEL
inar1_model<-EST_ZINAR(count_time_series,init = NULL,tol = 1e-05,iter = 5000,model="inar",innovation="Po",desc = FALSE)
inar1_model
##Properties of the model
x<-explore_zinarp(count_time_series)
x
#model diagnostic
residuals(inar1_model)
#####forecasting of the INAR MODEL
Forecasting
CAN SOMEONE PLEASE DO THAT AND HELP ME TO FORECAST AN INAR MODEL