David, thank you very much for the quick response: The "sample" example helped and works fine for me. I'm sorry for not providing an example. In order to explain my problem see following example:
test<-rt(1000,df=5) ####====Repeat only the following code to see how the second and third plot changes par(mfrow=c(1,3)) qqnorm(test) sample.from.normal<-sample(seq(-3,3,by=0.0001), size=1000, prob=dnorm(seq(-3,3,by=0.0001)), replace=TRUE) qqplot(sample.from.normal,test, main = "Q-Q Plot with sample from dnorm") quanto<-quantile(test,seq(0,1,by=0.0001)) quanta2<-quantile(sample.from.normal,seq(0,1,by=0.0001)) plot(quanta2,quanto, main = "Plot of Quantiles with sample from dnorm") The first example shows the QQ-Plot against the normal (qqnorm), the second shows the QQ-Plot against a sample of the normal, the third one is a "self-made" QQ-Plot (not using the qqplot function). If you fix the data sample ("test") and repeat only the plotting, the second and third plot change a little bit every time. This is clearly because of the sample drawing from the theoretical distribution ("sample.from.normal"). Besides, this method seems to be circuitous and imprecisely. Why does the qqnorm plot not change? I guess it is due to the precisely calculated quantiles of the normal distribution. How can I derive the quantiles directly from the pdf (i.e. from dnorm(x) without sampling or how to get qnorm from dnorm without using qnorm)? Remember, I've got only the pdf for use. Best regards Arndt Zimmermann ================== 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 ______________________________________________ R-help@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.