nmecsys / nowcasting Goto Github PK
View Code? Open in Web Editor NEWR package for Dynamic Factor Models with mixed frequencies and unbalanced panel :chart_with_downwards_trend:
R package for Dynamic Factor Models with mixed frequencies and unbalanced panel :chart_with_downwards_trend:
Logo no início da função "nowcast" aparece esse código:
if(is.null(q) & is.null(r) & is.null(p)){
warnings('Parameters q, r and p must be specified.')
}
Do que eu entendi o texto do warning não condiz com o código escrito. Se para entrar no if statement vc exige que os parâmetros q e r e p sejam não nulos, significa que se um deles não for nulo o statement será pulado. Daí o texto que eu entendo que deveria acompanhar seria "Parameters q, r or p must be specified.'"
Depois dá uma olhada nisso. Valeu!
Thanks for the package!
Do you intend to bring this back to CRAN? The dependency 'matlab' is back on CRAN, so it should be easy enough?
Since you wrote a nice article for the r-Journal, it would be fantastic to have it back.
Hello,
I want to start by infinitely thanking the contributors/builders of this package! It has greatly smoothed the process of my application. However, I stumbled across a problem and I really hope that someone can help me with it!
I want to nowcast my dataset using the EM algorithm and only 1 factor without using the block structure sub-variable restrictions.
I really hope that someone can guide me through how to tweak the nowcast function into the matter, or if it is possible for me to achieve this through this package.
Thank you!
Best,
Carlos.
Hi,
It's great to finally see someone making a decent nowcasting package for R
. A few years ago I made this (there's a more up-to-date version on gitlab) but never took the time to package it into something nice.
One thing I recall is that R
was pretty slow in running EM, especially with long and large datasets, which led me to rewrite the Kalman filter and EM-algorithm in RcppArmadillo
instead. I guess there should be significant amount of overlap and some of the C++
code might still re-usable in your case.
You went much further in the implementation though. 👍
Not sure if this is a bug or my own ignorance, but I've noticed that the ordering of columns in the data seem to matter. Example:
library(nowcasting)
data(NYFED)
base <- NYFED$base
blocks <- NYFED$blocks$blocks
trans <- NYFED$legend$Transformation
frequency <- NYFED$legend$Frequency
#randomly generated reordering
shuffle <- c(7, 11, 24, 21, 10, 15, 2,1, 22, 25, 19, 5, 18, 17, 4, 12, 16, 6, 14, 23, 8, 9, 3, 13, 20)
base_shuffle <- base[,shuffle]
frequency_shuffle <- frequency[shuffle]
blocks_shuffle <- blocks[shuffle,]
trans_shuffle <- trans[shuffle]
x <- Bpanel(base = base, trans = trans, NA.replace = F, na.prop = 1)
x_shuffle <- Bpanel(base = base_shuffle, trans = trans_shuffle, NA.replace = F, na.prop = 1)
nowEM <- nowcast(formula = GDPC1 ~ ., data = x, r = 1, p = 1,
method = "EM", blocks = blocks, frequency = frequency)
nowEM_shuffle <- nowcast(formula = GDPC1 ~ ., data = x_shuffle, r = 1, p = 1,
method = "EM", blocks = blocks_shuffle, frequency = frequency_shuffle)
You can verify that nowEM$yfcst
and nowEM_shuffle$yfcst
are different. Why is this? Do you have any recommendations for a "correct" column order?
I was testing the nowcast function, only to find that there is a function called EM_DFM_SS_block_idioQARMA_restrMQ
in Nowcast.R
Line 221 in 7bf63f9
Reparei que os fatores dinâmicos apresentados não são os mesmo utilizados na regressão de y, por que isso ocorre?
The following code fails when rowSums(indNAN) is always <= N*0.8 because then nanLead is empty and therefore X[-nanLE,] contains no rows and t1 and t2 will be infinite and the function stats::spline() will fail.
Instead the code should work in all cases including when there is no rows full of NaNs.
I don't understand why there is this 80% threshold.
}else if(options$method == 2){ # replace missing values after removing leading and closing zeros
rem1 <- (rowSums(indNaN)>N*0.8)
nanLead <- which(rem1)
# nanEnd <- which(rem1[length(rem1):1])
# nanLE <- c(nanEnd,nanLead)
nanLE<-nanLead
X<-X[-nanLE,]
indNaN=is.na(X)
for (i in 1:N){
x = X[,i]
isnanx = is.na(x)
t1 = min(which(!isnanx))
t2 = max(which(!isnanx))
x1<-stats::spline(x[t1:t2],xout = 1:(t2-t1+1))
sorry in advance, But I honestly don't know where can I ask for help regarding this question.
I just want to ask for advice regarding using explanatory variables that are of frequency=4 to forecast gdp with frequency of 4, is that possible using 2s and 2s_agg method
thank you in advance any help will be much appreciated
Hi! I'm glad to have come across this library and I appreciate the work put into it. I was wondering how we could extend this to be more flexible with the frequencies of the time series. For example, having weekly independent variables. Thanks!
Hi!
First of all, thank you for this great package, it is a pleasure to see a lot of tools (especially vintages based on the delay) made in such a simple form.
I've been working with an NYFED-like model for several years for Ukraine, but I've done it in MATLAB (where the original model is coded). Then I was asked to replicate it in R, my primary language.
I've found several possible issues, one of which is that results from MATLAB and R codes don't correspond to each other. Databases are exactly the same. There was an issue with transformations (they're different in raw codes), but I've fixed it and have made the same transformations for both cases (yoy for all variables, I know that economically its nonsense, but I want to simplify the statistical part as strong as possible).
But still, the result isn't the same. The intriguing part is that not only a nowcast doesn't correspond, the missed/filtered observations (for example GDP) are different.
Thank you for your attention and help!
Please be so kind to check if tdata transformation "trans = 7: quarterly rate of change " is impelmented correctly in function Bpanel. I got e.g. 0.0051781328 instead of 0.051781328
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.