You are working with Matlab and want to link your workspace with gmwmx?
Here is the procedure to follow:
- Download the R package Rcall: https://github.com/kreutz-lab/Rcall
- Add the Rcall folder to the Matlab path.
- In your Matlab environment, use the following command:
Rclear
Rinit([],'/usr/bin/R'); %your path to R.exe (type which R for linux user, where R for windows)
Rinit('gmwmx')
filepath = 'filepathwiththedatatoanalyse'
Rpush('filepath',filepath)
Rrun('data_dobs <- read.gnssts(filename = filepath)')
Rrun('fit <- estimate_gmwmx(x = data_dobs, theta_0 = c(0.01,0.1,1.3),model_string = "matern", n_seasonal=0)')
Then extract only the information you are interested in, for instance:
Rrun('beta <- fit$beta_hat')
Rrun('theta <- fit$theta_hat')
and finally:
[beta,theta] = Rpull('beta','theta');
You have now beta and theta in your Matlab environment. For further information and example: https://github.com/kreutz-lab/Rcall/wiki
Rcall can be used in any Matlab script. Using Rcall involves passing all necessary data to R, performing computations according to the user input, and sending the results back to Matlab for further use.