Regression R中的混合数据采样(midas_R)

Regression R中的混合数据采样(midas_R),regression,midasr,Regression,Midasr,我有下面的代码,其中我有一个每周时间序列(变量x),我想使用它来预测我的每月时间序列(变量y) 因此,基本上我想预测当前月份的数据(变量y),包括当前月份的1周、2周、3周或全部4周(变量New_值) 但是,我不确定是否使用了正确的滞后(我想是的),而且我不确定如何解释midas_r函数(start=list())中的起始值 任何帮助都将不胜感激 ###################### # MIDAS REGRESSION #################### x <- stru

我有下面的代码,其中我有一个每周时间序列(变量x),我想使用它来预测我的每月时间序列(变量y)

因此,基本上我想预测当前月份的数据(变量y),包括当前月份的1周、2周、3周或全部4周(变量New_值)

但是,我不确定是否使用了正确的滞后(我想是的),而且我不确定如何解释midas_r函数(start=list())中的起始值

任何帮助都将不胜感激

######################
# MIDAS REGRESSION
####################
x <- structure(c(1.19, 1.24 , 1.67 , 1.67 , 1.55 , 1.67 , 1.39 , 2.01 , 2.14 , 1.71 , 1.59 , 1.49 , 1.68 , -0.37 , -0.44 , -7.87 , -7.79 , -31.22 , -31.05 , -30.47 , -35.53 , -25.48 , -25.9 , -19.03 , -16.33 , 
                 10.09 , 13.19 , 13.31 , 16.85 , 14.58 , 14.78 , 14.62 , 15.27 , 15.58 , 15.63 , 14.27 , 14.09 , 4.82 , 3.55 , 3.46 , 3.24 , 2.86 , 2.86 , 2.86 , 2.82),
               .Tsp = c(2020, 2020.846154, 52), class = "ts")
x <- diff(x)

y <- structure(c(2.30, 2.64 , 2.77 , 2.83 , -43.91 , 12.32 , 26.68 , 12.06 , 10.08 , 12.01 , 4.71 , 3.85),
               .Tsp = c(2020, 2020.91667, 12), class = "ts")
y <- diff(y)

trend <- c(1:length(y))

#RUNNING THE MIDAS REGRESSION
reg <- midas_r(y ~ mls(y, 1, 1) + mls(x, 4:7, m = 4, nealmon), start = list(x = c(1, 1, -1, -1)))
summary(reg)
hAh_test(reg)

#forecast(reg, newdata = list(y = c(NA), x =c(rep(NA, 4))))

#FORECAST WITH WEEKLY VALUES
reg <- midas_r(y ~ mls(y, 1, 1) + mls(x, 3:7, m = 4, nealmon), start = list(x = c(1, 1, -1, -1)))
new_value <- 2.52
#new_value <- c(2.52, 3.12)
forecast(reg, newdata = list(x = c(new_value, rep(NA, 4-length(new_value)))))
######################
#迈达斯回归
####################

x看起来您在缩进方面有问题,还有一些不必要的复杂性

尝试类似的方法,看看是否有效:

for i in range(1, 20):
    url = 'https://www.boliga.dk/salg/resultater?propertyType=4&street=&municipality=326&salesDateMin=2020&page=' + str(i)
    page = requests.get(url)
    soup = BeautifulSoup(page.text, 'html.parser')    
    table = soup.find('table', {'class': 'table generic-table m-0 mb-3'})
    df = pd.read_html(str(table))[0]
    df = pd.DataFrame(df) #if it all works otherwise, try running the code w/out this line; it may be unnecessary
    df