[R] plot positive predictive values

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Sep 4 13:15:33 CEST 2009


You could use a glm with the binomial family to model that.

A solution with ggplot2

library(ggplot2)
ggplot(dataset, aes(x = x, y = y, weights = n)) +
	geom_smooth(method = "glm", family = binomial)
	geom_point()


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
Namens r2L
Verzonden: vrijdag 4 september 2009 13:04
Aan: r-help at r-project.org
Onderwerp: [R] plot positive predictive values

Hi,

I'm trying to fit a smooth line in a plot(y ~ x) graph.

x is continuous variable
y is a proportion of success in sub-samples, 0 <= y <= 1, from a Monte
Carlo simulation.

For each x there may be several y-values from different runs. Each run
produces several sub-samples, where "0" mean no success in any sub-
sample, "0.5" means success in half of the sub-samples, and "1" means
success in all sub-samples, and so on.

As x is increased, the y-value approaches 1, and may reach it; it can,
of course never bypass it.

>From my understanding of the data at hand, each point along the x-axis
has its own beta-distribution of the y-values, then as 0 <= y <= 1,
which shift gradually through distributions similar to

curve(dbeta(x,2, 2), add=F, col="red", xlim=c(0,1), ylim=c(0,4))
curve(dbeta(x,4, 2), add=T, col="red", xlim=c(0,1), ylim=c(0,4))
curve(dbeta(x,4, 1), add=T, col="red", xlim=c(0,1), ylim=c(0,4))
curve(dbeta(x,4, .1), add=T, col="red", xlim=c(0,1), ylim=c(0,4))

as x increases.

If I plot my data using boxplot it shows also very nicely how the the
data approaches 1 and variation decreases. However, my x-axis data are
continuous.

Is there a way to produce a regression line which would smoothly follow
that trend?

It may well be easier than I believe, but my head is at a full-stop...

Thanks for any help!

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.




More information about the R-help mailing list