[R] Deriving Samples from specific, not implemented PDF for a QQ-Plot
David Winsemius
dwinsemius at comcast.net
Wed Apr 1 05:15:24 CEST 2009
On Mar 31, 2009, at 11:53 AM, Arndt Zimmermann wrote:
> <trimmed superfluous white-space>
> this is my first post to the R-help, so please don't be too strict.
Reproducible examples should not be too much to expect, since that is
requested in the posting guide and multiple other locations.
> My problem concerns a QQ-Plot:
>
> I want to show how well empirical samples match with a theoretical
> distribution. The theoretical distribution has got several
> parameters, but I
> made it to fit via ML.
>
> Anyway, the theoretical function gives me the density for a given
> data point
> x. As far as I'm aware, the qqplot (generic) function in R does only
> take
> data samples as Input.
>
> How can I derive samples from the pdf? Am I right in the way I see the
> problem?
Rather hard to tell, since you haven't described what I understand to
be a problem, nor described how you see it.
> Or
> How can I modify the qqplot function, (or rebuild for myself) to get
> it
> going?
It seems to be going fine for us. Did you break it?
>
> I'm sure, this is very likely just a misunderstanding problem from
> myself,
> but anybody who can shed further light on this is very welcome.
Since you offer no examples, it is rather difficult to offer specific
advice. You should be able to use the sample function on a pdf by
assigning a vector of probabilities to the prob argument.
> mean(sample(seq(-2,2,by=0.2), size=100,
prob=dnorm(seq(-2,2,by=0.2)), replace=TRUE))
[1] -0.08
> sd(sample(seq(-2,2,by=0.2), siez=100, prob=dnorm(seq(-2,2,by=0.2)),
replace=TRUE))
[1] 0.911101
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list