Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable lengths differ (trend) #79

Open
Griffin97 opened this issue Jan 23, 2021 · 1 comment
Open

Variable lengths differ (trend) #79

Griffin97 opened this issue Jan 23, 2021 · 1 comment

Comments

@Griffin97
Copy link

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
Copy link
Member

vzemlys commented Aug 16, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants