Forecasting library plot - r

Im looking for the name of the library capable of making this plot.
The forecasting bit is I'm what I'm interested. Is it Forecast library?
Thanks.

Yes, the time-series plot is from the forecast library. You get that sort of plot when you plot a forecast object. Look at ?forecast. For example:
install.packages('forecast')
library(forecast)
fit <- StructTS(WWWusage,"level")
plot(forecast(fit))
The rest of the fancy stuff i.e. interactivity is most likely shiny magic, but I think you are interested only in the main plot.

Related

Phase plot in R

I want to make a phase plot like this https://en.wikipedia.org/wiki/Phase_portrait from an non-linear time series in R, Any ideas?
Thank you
you haven't given many details, but I suggest you look at the package phaseR.
I use it to draw isoclines and a flowfield of predator-prey models.
My graphs look like this (right one):

Shiny Plot interaction with chartseries

Is it possible to add plot interactions such as zooming as shown here and panning to charts plotted with the chartseries function from quantmod?
I am trying to find a decent yet simple solution for charting financial data (mainly candlesticks) with R. The standard chartseries plots are ok but severely lack a nice zooming functionality. I've use DYGRaphs and gvis packages but they struggle with plotting a non-continuous timeseries on the x-axis (i.e they have gaps in the data for weekends.) Gvis can over come this by using a discrete x-axis but then you lose the dates as labels. The other issue with these is that they dont have the nice integration of the indicators and trades on the plot that quantmod gives you.
I'm fairly new to R, but after spending several days exploring all the options for charting financial data and not finding a half decent solution, I think I'm barking up the wrong tree. Is there any sort of industry standard that I've completely missed?

Multiple partial dependence plots in one graph

I am using the randomForest package with the Partialplot function.
I want to make multiple partial dependence plots in one graph. My thesis promotor told me that it is possible to save them (in the environment, I did this and I got a list object with 'x' and 'y' variables in that list), but I don't know how to recall the graph after saving it.
What I want to do is:
1. Save PD plots
2. recall them
3. plot multiple PDP in one graph
Use the pdp package. Examples are given in the paper: https://journal.r-project.org/archive/2017/RJ-2017-016/RJ-2017-016.pdf.
Instead of using the partialPlot function, consider using the plotmo function in the plotmo package. This will draw plots for all variables and variable pairs on a single page. For example:
library(randomForest)
data(trees)
mod <- randomForest(Volume~., data=trees)
library(plotmo)
plotmo(mod, pmethod="partdep") # plot partial dependencies
which gives
You can specify exactly which variable and variable pairs get plotted using plotmo's all1, all2, degree1 and degree2 arguments. Additional examples are in the vignette for the plotmo package.
Perfect! Can save the plots as lattice objects and then recall. Plot together using gridArrange or CowPlot and pretty them up using ggplot. Great solution!

changing default colours when using the plot function of the R package mixtools

I have a plotting problem with curves when using mixtools
Using the following R code
require(mixtools)
x <- c(rnorm(10000,8,2),rnorm(10000,18,5))
xMix <- normalmixEM(x, lambda=NULL, mu=NULL, sigma=NULL)
plot(xMix, which = 2, nclass=25)
I get a nice histogram, with the 2 normal curves estimated from the model superimposed.
The problem is with the default colours (i.e. red and green), which I need to change for a publication to be black and grey.
One way I thought to doing this was first to produce the histogram
hist(xMix$x, freq=FALSE, nclass=25)
and then add the lines using the "curve" function.
....... but I lost my way, and couldn't solve it
I would be grateful for any pointers or the actual solution
thanks
PS. Note that there is an alternative work-around to this problem using ggplot:
Any suggestions for how I can plot mixEM type data using ggplot2
but for various reasons I need to keep using the base graphics
You can also edit the colours directly using the col2 argument in the mixtools plotting function
For example
plot(xMix, which = 2, nclass=25, col2=c("dimgrey","black"))
giving the problem a bit more thought, I managed to rephrase the problem and ask the question in a much more direct way
Using user-defined functions within "curve" function in R graphics
this delivered two nice solutions of how to use the "curve" function to draw normal distributions produced by the mixture modelling.
the overall answer therefore is to use the "hist" function to draw a histogram of the raw data, then the "curve" function (incorporating the sdnorm function) to draw each normal distribution. This gives total control of the colours (and potentially any other graphic parameter).
And not to forget - this is where I got the code for the sdnorm function - and other useful insights
Any suggestions for how I can plot mixEM type data using ggplot2
Thanks as always to StackOverflow and the contributors who provide such helpful advice.

how to use ggplot2 make recursive partitioning survival tree

can everyone tell me how to use ggplot2 make recursive partitioning survival tree?
I know " party " package can make a plot in R, however the plot is not looking good, and all the plots in the rest of my report are made by ggplot2.
for my plot, I printsreen and added labels manually. if there is a way to input data and plot in R also works, Thanks!!

Resources