sinhrks / ggfortify

Define fortify and autoplot functions to allow ggplot2 to handle some popular R packages.
Other
527 stars 65 forks source link

how to change the confidence level #199

Open FelipeCarrillo opened 4 years ago

FelipeCarrillo commented 4 years ago

I am trying to change the confidence level but conf.int.value gets ignored. Is there a workaround? No matter what level I put, it gets ignored.

library(forecast) library(ggfortify) d.arima <- auto.arima(AirPassengers) autoplot(d.arima, predict=predict(d.arima,n.ahead=3),ts.colour = 'blue', predict.colour = 'blue', predict.linetype = 'dashed', conf.int = TRUE,conf.int.value=0.99)

terrytangyuan commented 4 years ago

Thanks for filing the issue! Have you observed similar behavior for other arguments as well?

MonicaFialho commented 4 years ago

Hi

I'm having the same issue with the parameter conf.int.type.

autoplot(acf(AirPassengers, plot = FALSE), conf.int.type = 'ma')

returns the following warning message: Ignoring unknown parameters: conf.int.type

FelipeCarrillo commented 3 years ago

Any update on this question?

terrytangyuan commented 3 years ago

@MonicaFialho I am not able to reproduce your issue. autoplot(acf(AirPassengers, plot = FALSE), conf.int.type = 'ma') works as expected. Could you try again and share the version of ggfortify and related packages if this is still an issue?

terrytangyuan commented 3 years ago

@FelipeCarrillo Looks like the confidence interval cannot be specified as part of autoplot(). Instead, it should be specified in level argument as part of forecast::forecast(level=c(85)), for example:

d.arima <- forecast::auto.arima(AirPassengers)
# Use different (confidence) levels
autoplot(forecast::forecast(d.arima, level = c(85), h = 10))
autoplot(forecast::forecast(d.arima, level = c(99), h = 10))

You should be able to see different plots by modifying the confidence levels through level argument.

MonicaFialho commented 3 years ago

@terrytangyuan , I tried again, with ggfortify v0.4.10 and v0.4.11, and the result now is:

autoplot(acf(AirPassengers, plot = FALSE), conf.int.type = 'ma') Warning message: In confint.acf(model, ci = conf.int.value, ci.type = conf.int.type) : can use ci.type="ma" only if first lag is 0

terrytangyuan commented 3 years ago

@MonicaFialho I guess the issue is that your model does not work with that particular confidence type then as it requires to have first lag that's equal to 0.