helske / KFAS

KFAS: R Package for Exponential Family State Space Models
64 stars 17 forks source link

space and time prediction #55

Closed sue-shine closed 3 years ago

sue-shine commented 3 years ago

hi, helske Whether the KFAS package can be used for two-dimensional variations in space and time, the examples given here are only time series of variations in time. If I want to show the pattern of location changes at different times on the map (add latitude and longitude to represent the geographical location), What should I do? Looking forward to your reply, Thanks!

sue-shine commented 3 years ago

hi, helske Whether the KFAS package can be used for two-dimensional variations in space and time, the examples given here are only time series of variations in time. If I want to show the pattern of location changes at different times on the map (add latitude and longitude to represent the geographical location), What should I do? Looking forward to your reply, Thanks!

helske commented 3 years ago

If I understand your question correctly, you can think of having bivariate time series where the first element corresponds to latitude and second to longitude, and then it is just a matter defining appropriate state structure related to these.

sue-shine commented 3 years ago

Hi, sorry to bother you, I uploaded a sample data to express the problem I want to solve. I looked up many related information about the package, but but still seems unable to solve my problem. Would you mind using the sample data to help me out. The data included sample points of known latitude and longitude in an area (two years), each with a population and number of cases, assuming that te number of cases follows the Poisson distribution. Now I want to use these sample point data to predict the incidence in whole region so that trends can be plotted. The data is attached, I will appreciate your help! with best wishes! sample_data.xlsx example.docx

helske commented 3 years ago

Oh now I see, you seem to have spatio-temporal problem, so you probably need to use something else than state space modelling with KFAS. You might try something like INLA for this kind of data.

sue-shine commented 3 years ago

But I have read your article named KFAS: Exponential Family State Space Models in R, and it has this formula: yt,i= Zt,iαt,i+?t,i, i = 1, . . . , pt, t = 1, . . . , n, αt,i+1= αt,i, i = 1, . . . , pt− 1, αt+1,1= Ttαt,pt+ Rt*ηt, t = 1, . . . , n, Can the letter i here be thought of as a different latitude and longitude position, and y is a vector, so can it represent the observations at different places at different times. Now I want to do this in a more dynamic way than INLA, I wonder if KFAS might be a good choice.

helske commented 3 years ago

Oh yes, sorry, I just quickly glanced your attachments, you are right that is, of course, possible if you have fixed locations.

sue-shine commented 3 years ago

I wonder if you've ever worked with similar data before, I am very sorry that I have encountered difficulties in processing data.

helske commented 3 years ago

Not really, but as said, the modelling itself does not care what the data represents so in that sense it is just a matter of defining the relevant system matrices according to your needs.

sue-shine commented 3 years ago

yeah, That's the point. Would it be convenient for you to run the code with the sample data if you have time?

helske commented 3 years ago

Sorry, I do not have time for such. Besides, the model needed and the corresponding codes depend entirely on what your assumed data generating model is, of which I have no clue.

In general, the GitHub issue tracker is meant mainly for reporting bugs and feature requests, for general questions about the state space modelling I suggest for example Cross Validated.

sue-shine commented 3 years ago

Ok, thanks for your feedback!