Forecasting and visualization R

I set a polynomial for my data and visualized the results. I am trying to expand my plot to the future and predict the value of x (date) when y is less than 70. My data is replicated HERE . My current code is below.

data <- read.table("data.txt", sep="\t", header=T)

data$date<- as.Date(data$date)
data$y <- as.numeric(data$y)

attach(data)

x <- 1:88 # vector for formula coordinates. I haven't found a way to plot polynomial formula with dates..

p <- qplot(date, y, data=data , geom="line", xlab="Time", ylab="y")
p+ geom_smooth(method = "lm", formula = y ~ poly(x, 3))


fit <- lm(y~poly(x,3)) 
summary(fit) #Fit is adequate

      

What are the results of this graph:

enter image description here

The third order polynomial was made with a numeric vector x because I didn't know how to use dates as "coordinates" for the formula. I would like to predict, that is, extend this graph to the future and find out at which date y is below 70 using this formula.

+3
r ggplot2


source to share


No one has answered this question yet

Check out similar questions:

165
Most underutilized data
28
Hyperlink text as ggplot2
13
Predicted logistic regression values ​​from glm and stat_smooth in ggplot2 are different
five
Stop extrapolation when forecasting using two variables
2
adding a legend to a scatter plot with an embedded line and prediction interval
1
Making discrete predictions with probability intervals - ggplot2
1
R creates a different result after putting IO into the file
1
Time series with zero values
0
Tweak the title on the plot (ggplot2) with the label of another file
-1
Time prediction model



All Articles
Loading...
X
Show
Funny
Dev
Pics