MIDAS回归(midasr包)

时间:2018-03-19 00:41:08

标签: r

我正在尝试使用窗口函数估计数据子样本的midas回归。但是,当我使用它时,midas_r函数会将我返回到prepmidas_r中的"错误(y,X,mt,Zenv,cl,args,start,Ofunction,weight_gradients,:   必须提供重量参数的起始值"错误

install.packages("midasr")
library(midasr)
yrs <- 10
x <- ts(rnorm(12*yrs),start=c(1900,1),frequency = 12)
y <- ts(rnorm(yrs),start=c(1900,1))

midas_r(y~fmls(x,3,12,nealmon),start=list(x=rep(0,3)))

x_est <- window(x,end=c(1910,0))
y_est <- window(y,end=(1910))

midas_r(y_est~fmls(x_est,3,12,nealmon)+1,start=list(x=rep(0,3)))

有谁知道这个问题是什么?提前谢谢!

1 个答案:

答案 0 :(得分:0)

问题出在library(tidyverse) ## pseudocode ## for the first set of files build a reference ref1 <- first_set %>% select(name1, name2, station_id) %>% distinct() %>% # unique combinations mutate(new_id = ....) # add regex or formattinf ## for the second set of files build a reference ref2 <- second_set %>% select(name1, name2, other_station_id) %>% distinct() %>% # unique combinations mutate(new__id = .... ) # add regex or formatting or whatever ## now join the reference to get a cross reference table ## missing entries wil have NA. ref <- full_join(ref1, ref2, by = "new_id") ## when your refernce table is looking clean then you can append the new ids ref1 <- ref1 %>% left_join(ref, by = c("name1", "name2", "station_id")) %>% select(- ) ## use - to drop values not needed ref2 <- ref2 %>% left_join(ref, by=c("name1", "name2", "other_station_id" )) %>% select(- ) ## use - to drop values not neede 。确实要列出此列表,但此名称需要与变量名称一致。因此,

list(x=rep(0, 3))

作品。