greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
528 stars 63 forks source link

DFA: Best way to handle missing data with greta #266

Closed APramov closed 5 years ago

APramov commented 5 years ago

First, appologies if posting in the wrong place, I can post on the greta forum if it would be more fitting.

Background: After trying out the MARSS package to fit a DFA model, I am eager to try out analyze my data in Greta. I am modeling a set of macroeconomic time series that have mixed sampling frequency (monthly and quarterly).

For now I have a small model and hence MARSS, albeit slow, is doing a fine job. However, I would like to scale up and add a lot more variables. I read that MARSS becomes slow in such a case and hence I am trying out Greta.

Question/Problem: The problem is that I get an errorError: cannot convert objects with missing or infinite values to greta_arrays when I use as_data to convert my observed data set. ( I was just following the default greta example and replacing the simulated data with mine, just to see what would happen).

This is not surprising, as e.g. unemployment rate is released monthly whereas GDP is released quarterly and thus, with my type of data, I would always have mixed data sampling. The MARSS package was able to handle that (I guess, by construction as it uses the Kalman filter), so my question is what should I do when using Greta?

I have read through a similar issue here , however I don't think it is quite applicable here, as my data is not independent (and hence splitting in missing and observed would break the temporal structure).

I guess the easiest solution would be to fill up the missing values with the last one observed but I am not too keen on doing that, so I am looking for some different guidance/ideas. I am not too familiar with Bayesian modeling, so I am not sure how to proceed.

Any ideas/suggestions would be very welcome!

goldingn commented 5 years ago

Hi @APramov. I think the forum might be a better place for this, since I think it's more a question of how to fit a specific model using greta than it is about adding a feature to greta (other than the existing feature request re. missing data).

If you could copy-paste your question over there, and ideally provide some example model code and data, that would be really helpful.

See also this worked example of a DFA analysis by MARSS author @mdscheuerell, which might be worth taking a look at: https://mdscheuerell.github.io/gretaDFA/

APramov commented 5 years ago

@goldingn , will do, thank you! I know about the example too, it is indeed my working template on which I was trying to run my data through. I am closing this now, appologies for posting it in the wrong place.

goldingn commented 5 years ago

No apologies needed, thank you for moving it!