Harmonic regression with independent variable

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Harmonic regression with independent variable

nnn1703
This post has NOT been accepted by the mailing list yet.
Hi guys,
Am trying to make prediction using harmonic regression.
Cowpertwait and Metcalfe make use of the same model to predict  air passenger in their book but mine is made up of an additional independent variable( X_t),i.e
Y_t= m_t+∑_(i=1)^([s/2])▒〖{s_i  〖sin 〗⁡〖(2πit/s)  〗 〗+c_i  cos⁡(2πit/s)} +a_i X_t+ z_t

Earnings.lm<- lm(log(Earnings) ~  TIME + I((TIME)^2)+I(TIME^4)+ SIN[,1] + COS[,1] + SIN[,3]  + COS[,5] + Tourist arrivals)
:
:
:
new.t1<-time(ts(frequency=12,start=c(2012,1), end=c(2012,12)))
 TIME <- (new.t1 - mean(time(Tourist arrivals )))/sd(time(Tourist arrivals))
SIN <- COS <- matrix(nr = length(new.t1), nc = 6)
 for (i in 1:6)
 { COS[, i] <- cos(2 * pi * i * new.t1)
 SIN[, i] <- sin(2 * pi * i * new.t1)
 }
 SIN <- SIN[, -6]
 new.dat <- data.frame(TIME = as.vector(TIME), Tourist arrivals =Tourist arrivals,SIN = SIN, COS = COS)
Earnings.pred.ts <- exp(ts(predict(Earnings.lm, new.dat), start = 2012, fr=12))

I am having the following error:
Error: variable ' Tourist arrivals ' was fitted with type "nmatrix.1" but type "numeric" was supplied
Please help!!
Thanks in advance.