SMAC-Group/simts

Fix units in plot.gts/ACF/PACF

Closed this issue · 2 comments

There is a bug with the lags and xlab when freq != 1 for the functions mentioned in the title. Here is an example:

# Load savingrt dataset
data("savingrt")

# Simulate based on data
savingrt = gts(as.vector(savingrt), start = 1959, freq = 12, unit_ts = "%", 
            name_ts = "Saving Rates", data_name = "US Personal Saving Rates",
            unit_time = "month")

# Plot savingrt simulation
plot(savingrt)

# Compute ACF and plot result
savingrt_acf = ACF(savingrt)
plot(savingrt_acf)

I'm assuming Time can be NULL and will try to fix this issue by directly changing the gts() function.

Previously,

if (length(data) != length(Time)){
      stop('"data" and "Time" must have equal length.')
    } 

was contained outside of the if (!is.null(Time)) if loop since we did not consider when Time is NULL. Should we create a if case for when Time is NULL? Thanks.

Therefore, the problem did not lie because freq != 1 but was because of the stop() statement I included to error when the data and Time parameter were not of equal length. In the case about that you stated, our Time parameter is set to NULL. And NULL is not the same length as the length of our savingrt dataset.

Please close this issue if this bug seems to be fixed.