ecor / RMAWGEN

Github version on RMAWGEN package (http://cran.r-project.org/web/packages/RMAWGEN/index.html)
GNU General Public License v3.0
3 stars 5 forks source link

ComprehensiveTemperatureGenerator(yearly = FALSE) always fails in eigen() #9

Open twest820 opened 4 years ago

twest820 commented 4 years ago

Doesn't seem to matter which years the simulation covers or whether the simulation is for a single year, several years, or a decade. This seems unfortunate as it appears the default yearly = TRUE results in repetition of a fixed spline which doesn't account for interannual variability and is discontinuous at the 31 December to 1 January boundary.

> modeledTemperatures = ComprehensiveTemperatureGenerator(station = c("HaneyUBC"),
+   Tx_all = TEMPERATURE_MAX, Tn_all = TEMPERATURE_MIN, 
+   year_min = 1962, year_max = 1990, year_min_sim = 1983, year_max_sim = 1985, extremes = FALSE,
+   p = 2, n_GPCA_iteration = 5, n_GPCA_iteration_residuals = 5,
+   sample = "monthly", yearly = FALSE)
Error in eigen(cor(x_gauss_prev, use = "pairwise.complete.obs")) : 
  infinite or missing values in 'x'
> traceback()
7: stop("infinite or missing values in 'x'")
6: eigen(cor(x_gauss_prev, use = "pairwise.complete.obs"))
5: t(eigen(cor(x_gauss_prev, use = "pairwise.complete.obs"))$vectors)
4: GPCA_iteration(x_prev = x_prev, extremes = extremes)
3: GPCA(x_prev = data, extremes = extremes, n = n_GPCA_iteration)
2: getVARmodel(data = param[["data_for_var"]], suffix = c("_T1", 
       "_T2"), sep = "", p = p, type = type, lag.max = lag.max, 
       ic = ic, activateVARselect = activateVARselect, exogen = exogen, 
       n_GPCA_iteration_residuals = n_GPCA_iteration_residuals, 
       n_GPCA_iteration = n_GPCA_iteration, extremes = extremes)
1: ComprehensiveTemperatureGenerator(station = c("HaneyUBC"), Tx_all = TEMPERATURE_MAX, 
       Tn_all = TEMPERATURE_MIN, year_min = 1962, year_max = 1990, 
       year_min_sim = 1983, year_max_sim = 1985, extremes = FALSE, 
       p = 2, n_GPCA_iteration = 5, n_GPCA_iteration_residuals = 5, 
       option = 2, sample = "monthly", yearly = FALSE)

Workaround: none known, problem persists through R restart and seems to have spread to ComprehensiveTemperatureGenerator() calls with the default value of yearly

Version: RMAWGEN 1.3.7 (current as of this writing)

ecor commented 3 years ago

Hi @twest820 , thank you for the message, it looks that data may have some NA values. Have you also tried with the latest version of RMAWGEN, 1.3.8 ? Thanks for the interest and tha feedback. Best @ecor

Remotsensei commented 10 months ago

i am using the newest version of the package and still get this error 1.3.9.2 the dataset does not have NA values per se and it appears to have the correct number of days in it for the range of years i have

ecor commented 10 months ago

Hi @Remotsensei ,

thanks for feedback. Please can you provide a reproducible scripts with your error?

It looks like (see @twest820 's post) that correlation matrix contains some NAs. (https://stackoverflow.com/questions/14674431/error-in-eigencorr-infinite-or-missing-values-in-x-when-making-a-correlat) but if I do not have any reproducible script, I cannot help you.

Thank you Best @ecor

ecor commented 9 months ago

In absence of feedback that can reproduce the error. I cannot evaluate the issue, and then I can solve it (if the issue exists).