Value for mixture distributions crossing using 'mixdist' in R - r

I have a plot (below) generated using the package "mixdist" and would like to know the exact value at which the two distributions cross one another rather than just estimating from the plot. I haven't come across this in any of the output information. Can this be obtained through mixdist?
Thanks for any help

use locator() function to click on the point in the graph, followed by 'esc' key to give the values

Related

cv.tree() in R, deviance

everyone!
I need help with one function in R (cv.tree). I created a regression tree, and now I need to find the optimal alpha parameter and its corresponding subtree for pruning. I know, that usually we use cross-validation, but I don't understand well what is shown on the graph on the y-axis. It says that on the x-axis is the size of each tree in the sequence. On the y-axis, cv.tree$dev is shown. And I don't understand what it is. I will be grateful for help. (Maybe you can also explain, how to calculate this value).

How to convert S3 objects with class roc for ggplot2?

I'm planning to use patchwork to assemble several ROC curves plotted with pROC. After constructing a pROC plot list (of S3: roc objects) and attempting to use wrap_plots(plots) to assemble, I came across the following error:
Error: Only know how to add ggplots and/or grobs
AFAIK, there may be several solutions:
Coerce S3:roc objects to ggplots. It seems the function fortify does this job for S3 objects generated by precrec package but I don't know if S3:roc objects can be done in the same way. Using ggplot2::fortify I ran into
`data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class roc.
Use precrec to streamline the conversion, instead. What curtails my migration is that I want to print Youden index point and confidence intervals of the Youden index point and area under curve (AUC) on the plot. It seems only pROC package meets all my needs so I don't quite want to move on. Also I need to adjust my codes to cater parameter demands from precrec. Too much to learn and try, so tutorials and simple codes are appreciated.
Whatever, my final purpose is being able to assemble all ROC curves programmatically, with automatic annotations. The ROC curves need to show their respective Youden index point and confidence intervals of the Youden index point and area under curve (AUC) on the plot.
Drawbacks exist in the pROC package, too. The text sizes of Youden index and confidence interval values are too small for the whole plot if all ROC plots are assembled. I can adjust them by specifying par(cex=<text size>) but there's ricks that the texts may overlap with the curves or get out of bound if the texts are too marginal. pROC is not smart enough to reconcile with text sizes, curves and text positions. A smarter package to meet all of my harsh demands mentioned above will strongly push me forward to adopt a new package to draw ROC curves. Therefore, solutions vary in my scenario (but please don't recommend using a graphical vector image editor to edit these curves by hand because it's time-consuming and error-prone, and lags changing demands from different journals). All insights from all perspectives are appreciated.
Have you tried the ggroc function from pROC? It does exactly what you're asking for: it creates a ggplot2 plot (class gg) which you can then manipulate as you wish.
However I think you are being slightly confused:
Coerce S3:roc objects to ggplots. It seems the function fortify does this job for S3 objects generated by precrec package
It makes sense that the precrec package would be able to convert its own objects. However, note that it doesn't generate a ggplot2 object, but a data.frame with the coordinates of the ROC curve (which can then be used as input for ggplot2).
In pROC, this exact operation is done with the coords function, which extracts the coordinates of the ROC curve to a data.frame (and that you can then use as input for ggplot2).

Cross-Recurrence plots in R (with or without ggplot)

I have different time-series corresponding to different individuals and their location within a building (a categorical variable -- more like a room name).
I would like to study the similarity in movement of different individuals by something like cross-recurrence plots, where the two time-series correspond to the two axes and the actual points correspond to the presence/absence of individuals in the same room.
Has anyone tried doing such plots in R or while using ggplot? Any help would be great!
I haven't used this routine. I used only d2 dimension and Lyapunov exponent for EEG but this package Tisean (RTisean for your case) has a routine ['recurr'] that returns the specific plot.
This link has a nice wrap up of tutorials and links
Edited:
In this link you can find a nice example of application of recurrence plot.
The return variables of function recur(and similar functions of other packages) you can access after putting $ after the dataset (like database)
and you can access them inside in ggplot function and applying the appropriate aes.

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 reproduce this graphical explanation (a scatter plot) of how covariance works?

I found this graphical intuitive explanation of covariance:
32 binormal points drawn from distributions with the given covariances, ordered from most negative (bluest) to most positive (reddest)
The whole material can be found at:
https://stats.stackexchange.com/questions/18058/how-would-you-explain-covariance-to-someone-who-understands-only-the-mean
I would like to recreate this sort of graphical illustration in R, but I'm not sufficiently familiar with R's plotting tools. I don't even know where to start in order to get those colored rectangles between each pair of data points, let alone make them semi-transparent.
I think this could make a very efficient teaching tool.
The cor.rect.plot function in the TeachingDemos package makes plots similar to what is shown. You can modify the code for the function to make the plot even more similar if you desire.

Resources