Skip to content
Prev 175762 / 398503 Next

Deriving Samples from specific, not implemented PDF for a QQ-Plot

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:

            
Reproducible examples should not be too much to expect, since that is  
requested in the posting guide and multiple other locations.
Rather hard to tell, since you haven't described what I understand to  
be a problem, nor described how you see it.
It seems to be going fine for us. Did you break it?
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