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

David Winsemius dwinsemius at comcast.net
Thu Apr 2 02:04:20 CEST 2009


I am puzzled to hear that repeating only plotting give different
results, if there were no further simulations. Both rt() and sample()
should give different results from call to call, so if either of those
functions were repeated, then varying results *should* occur. If that
is not the source of the variation then, I am hoping that someone else
can step in. I am traveling and not at a computer with R installed.

On Apr 1, 12:31 pm, "Arndt Zimmermann" <bobb... at gmx.de> wrote:
> 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.

If you did not repeat the assignment to test, then it stays the same.

> 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.

If you want the quantiles from the pdf without simulation, then
integrate.

--

David Winsemius




More information about the R-help mailing list