I'm trying to make a relatively simple GDP forecast, but I'm finding the following error:
**Error in model.frame.default(formula = y ~ t2, drop.unused.levels = TRUE) :
comprimentos das variáveis diferem (encontradas em 't2')**
Here's the script I'm doing:
scan=(~pib)
#Previsão
tspib = ts(pib[,2],start = c(2002,1), frequency = 12)
tspib
plot(tspib, xlab='Years', ylab = "Pib")
plot(forecast(tspib))
summary(forecast(tspib))
#Regressão
length(tspib)
t=(1:182)
t2=t^2
#Erro aqui
reg=lm(y~t+t2)
summary(reg)
The file is in my PC and is a CSV in the following format (example of the first 5 lines):
Data PIB
2002-01 112374,80
2002-02 111477,10
2002-03 118444,70
2002-04 120385,90
2002-05 123552,50
Date is imported as "character" PIB as "numeric".