SMAC-Group / gmwm

Generalized Method of Wavelet Moments (GMWM) is an estimation technique for the parameters of time series models. It uses the wavelet variance in a moment matching approach that makes it particularly suitable for the estimation of certain state-space models.
Other
28 stars 14 forks source link

stack gmwm-results in a vector #184

Open philippcla opened 8 years ago

philippcla commented 8 years ago

Hello

I have the following code:

gmwm_values = gmwm(model = my_gmwm_model, data = vector_of_interest)

This works fine.

Now, if I have a for-loop, where I have multiple "vector_of_interests" I will not be able to store the "gmwm_values" in a vector-like-manner. The code would be something like this

for (i in seq(1,length,1))
{
       gmwm_values[i] = gmwm(model = my_gmwm_model, data = vector_of_interest[,i])
}

Is there some other way to assemble the gmwm-results? Thanks

coatless commented 8 years ago

To aggregate multiple results, we have no built in GMWM function that achieves this presently. Primarily because the gmwm() function was designed to iterate over only one signal vs. multiple signals each with their own model (c.f. gmwm.imu() is restricted to 1 signal). The initial design reason for this was simplicity of the gmwm estimation command.

Though, I can definitely see benefits to this approach. One primarily being that this model limitation is a bit relaxed with both rank.models() and auto.imu() with similar options. So being able to add in a batch estimation procedure should be fine.

In the interim, to aggregate values, use:

# Assume that `data.set` is a matrix that contains all `vector_of_interest`
nsignals = ncol(data.set)

# Define a model (my_gmwm_model)
model = AR1() + WN()

# Create a matrix that stores parameters by signal
mat = matrix(NA,                    # Create a matrix filled with NA (missing values)
             nrow =  nsignals,      # Each signal has its own row
             ncol = model$plength ) # Each parameter has its own column

for (i in seq_len(nsignals))
{
       gmwm_values[i,] = t(gmwm(model = model, data = data.set[,i])$estimate)
}

The above assumes the same model at each turn.

philippcla commented 8 years ago

ok, for the time being this is a nice workaround. I would just need to store all the different informations (estimate, theo, ..) from the gmwm_variable (in your example denoted as "t") thanks