mpiktas / midasr

R package for mixed frequency time series data analysis.
http://mpiktas.github.io/midasr/
Other
72 stars 34 forks source link

Variable lengths differ (trend) #79

Open Griffin97 opened 3 years ago

Griffin97 commented 3 years ago

Hello , i need urgent solution on the following. Having read the midas JSS article, i improve my question . I realise if i add

for(i in ((length(FinQ)+1):length(Mvs)))+ { FinQ = c(FinQ, 0)} before

Simulated low-frequency series (e.g. yearly) the code runs and produce a graph of weights against high frequency lags which could not be produced before hoping i have done the right thing.

library(midasr) set.seed(4)

Number of low-frequency observations n<-146

Linear trend and higher-frequency explanatory variables (e.g. quarterly and monthly) trend<-c(1:n) Gdp <-ts(Gdp, start = c(1997, 1), frequency = 4) Mvs <- ts(Ftwn, start = c(1997, 1), frequency = 12) FinQ <- ts(FQrt[,-10], start = c(1997, 1), frequency = 4)

Exponential Almon polynomial constraint-consistent coefficients fn.FinQ<- nealmon(p=c(1,-0.5),d=9) fn.Mvs <- nealmon(p=c(2,0.5,-1),d=9) for(i in ((length(FinQ)+1):length(Mvs)))+ { FinQ = c(FinQ, 0)}

Simulated low-frequency series (e.g. yearly) Gdp<-2+0.1trend + mls(FinQ,2,3)%%fn.FinQ + mls(Mvs,2,3)%*%fn.Mvs + rnorm(n)

When i then try to run the below code, i am getting error which is below, anyone who can help here. I have tried all sorts of lag structure for mls(Gdp,..,2 nealmon) but can't manage to get it right to escape the error, what m i am doing wrong or how can i correct the issue here , thanks .

Gdp<- na.omit(Gdp) EQ <- midas_r(Gdp ~ trend + mls(FinQ,3,2, nealmon) + mls(Mvs,7:12,8, nealmon), start=list(Gdp=c(10,1,-0.1),Mvs=c(2,-0.1)))

Error in model.frame.default(formula = Gdp ~ trend + mls(FinQ, 3, 2, nealmon) + : variable lengths differ (found for 'trend')

vzemlys commented 1 year ago

This error usually indicates that frequency alignment was done incorrectly. Please provide the reproducible example.