4
I’m trying to make a relatively simple GDP forecast, but I’m finding the following mistake:
**Error in model.frame.default(formula = y ~ t2, drop.unused.levels = TRUE) :
comprimentos das variáveis diferem (encontradas em 't2')**
Follow 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 on my PC and is a CSV in the following format (example of the 5 first lines):
Data PIB
2002-01 112374,80
2002-02 111477,10
2002-03 118444,70
2002-04 120385,90
2002-05 123552,50
Data is imported as "Character" GDP as "Numeric".
Daniel, I set the variable to y = GDP$GDP and it worked. I think that was the problem...!
– Rodrigo Lobo