Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack gmwm-results in a vector #184

Open
philippcla opened this issue Jun 2, 2016 · 2 comments
Open

stack gmwm-results in a vector #184

philippcla opened this issue Jun 2, 2016 · 2 comments

Comments

@philippcla
Copy link

philippcla commented Jun 2, 2016

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
Copy link
Contributor

coatless commented Jun 2, 2016

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants