I want to plot and generate new data based on my Regression Model which I created:
Trend <- seq(1:length(Daten$TSLAC))
TISPYNVDA_TSLA <- lm(TSLAC ~ Trend + SPYC * NVDAC, data = Daten)
summary(TISPYNVDA_TSLA)
plot(predict(TISPYNVDA_TSLA), type = "l",
xlab="geschätzte Werte der abh. Variablen",
ylab="geschätzte Residuen", main="Residuenplot", pch=20)
lines(Daten$TSLAC, col="red")
As seen above, I created a trend sequence for the creation of future data with:
newline <- data.frame(wt=predict(TISPYNVDA_TSLA))
The function:
TISPYNVDA_TSLA <- lm(TSLAC ~ Trend + SPYC * NVDAC, data = Daten)
creates the regression. After that, I plot the regression together with the real data on TSLAC (Tesla Close Price).
Then I want to predict further afterwards as a "future prediction".
How can I do that?
I tried the predict() function, but it's not working:
lines(252:350,predict(newline,newdata=newline))
252 because the data is going to 251, then it should predict in the future.
predict(newline, newdata=newline)
, I think you wantpredict(TISPYNVDA_TSLA, newdata=newline)
instead. - smanskinewdata
inpredict
needs to be a dataframe with columns for all variables used in your linear model. When you say "future predictions", you need to specify what these future X values are. - smanski