Quantcast

function for inverse normal transformation

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

function for inverse normal transformation

carol white
Hi,
What is the function for inverse normal transformation?

Thanks,

Carol

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

Duncan Murdoch-2
On 12-07-20 6:21 AM, carol white wrote:
> Hi,
> What is the function for inverse normal transformation?

qnorm

Duncan Murdoch

> Thanks,
>
> Carol
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

arun kirshna
In reply to this post by carol white
HI,

Probably this might be helpful for you.

http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=fBasics:dist-nigFit
A.K.



----- Original Message -----
From: carol white <[hidden email]>
To: "[hidden email]" <[hidden email]>
Cc:
Sent: Friday, July 20, 2012 6:21 AM
Subject: [R] function for inverse normal transformation

Hi,
What is the function for inverse normal transformation?

Thanks,

Carol

    [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

carol white
In reply to this post by Duncan Murdoch-2
Thanks for your reply.

So to derive it from a given data set, is the following correct to do?

my_data.p =2*pnorm(abs(my_data),lower.tail=FALSE)

my_data.q = qnorm(my_data.p)

Cheers,


________________________________
 From: Duncan Murdoch <[hidden email]>

Cc: "[hidden email]" <[hidden email]>
Sent: Friday, July 20, 2012 1:23 PM
Subject: Re: [R] function for inverse normal transformation

On 12-07-20 6:21 AM, carol white wrote:
> Hi,
> What is the function for inverse normal transformation?

qnorm

Duncan Murdoch

> Thanks,
>
> Carol
>
>     [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

Duncan Murdoch-2
On 12-07-20 7:36 AM, carol white wrote:
> Thanks for your reply.
>
> So to derive it from a given data set, is the following correct to do?
>
> my_data.p =2*pnorm(abs(my_data),lower.tail=FALSE)
>
> my_data.q = qnorm(my_data.p)

I don't know what you're trying to do, but that doesn't look like it
does something sensible.  It would take a value like 2, compute the p to
be 0.045, and return the corresponding quantile of the normal
distribution, i.e. -1.69 or so.  I don't know why you'd want to do that.

Duncan Murdoch

>
> Cheers,
>
>
> ________________________________
>   From: Duncan Murdoch <[hidden email]>
> To: carol white <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>
> Sent: Friday, July 20, 2012 1:23 PM
> Subject: Re: [R] function for inverse normal transformation
>
> On 12-07-20 6:21 AM, carol white wrote:
>> Hi,
>> What is the function for inverse normal transformation?
>
> qnorm
>
> Duncan Murdoch
>
>> Thanks,
>>
>> Carol
>>
>>      [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] 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.
>>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

carol white
I have a continuous data. So to calculate the inverse normal transformation, I thought that I should first calculate the Z-score normalized data and then, calculate the p-value et the quantile transformation. Does this seem to be more sensible


my_data.p =2*pnorm(abs(scale(my_data)),lower.tail=FALSE)
my_data.q= qnorm(my_data.p)


The attached file shows the histogram of a small data set before transformation, the p-value generated from the Z-score normalized data and then, the qnorm-transformed data.

Thanks for your feedback,


________________________________
 From: Duncan Murdoch <[hidden email]>
To: carol white <[hidden email]>
Cc: "[hidden email]" <[hidden email]>
Sent: Friday, July 20, 2012 1:42 PM
Subject: Re: [R] function for inverse normal transformation
 
On 12-07-20 7:36 AM, carol white wrote:
> Thanks for your reply.
>
> So to derive it from a given data set, is the following correct to do?
>
> my_data.p =2*pnorm(abs(my_data),lower.tail=FALSE)
>
> my_data.q = qnorm(my_data.p)

I don't know what you're trying to do, but that doesn't look like it
does something sensible.  It would take a value like 2, compute the p to
be 0.045, and return the corresponding quantile of the normal
distribution, i.e. -1.69 or so.  I don't know why you'd want to do that.

Duncan Murdoch

>
> Cheers,
>
>
> ________________________________
>   From: Duncan Murdoch <[hidden email]>
> To: carol white <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>
> Sent: Friday, July 20, 2012 1:23 PM
> Subject: Re: [R] function for inverse normal transformation
>
> On 12-07-20 6:21 AM, carol white wrote:
>> Hi,
>> What is the function for inverse normal transformation?
>
> qnorm
>
> Duncan Murdoch
>
>> Thanks,
>>
>> Carol
>>
>>      [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] 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.
>>
______________________________________________
[hidden email] 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.

tmp.png (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

Rui Barradas
In reply to this post by carol white
Hello,

No it's not correct, you are computing a what seems to be a two-tailed
probabiity, so the inverse should account for it. Look closely: you take
the absolute value, then the upper tail probability, then multiply 2
into it. Reverse these steps to get the correct value.

# Helper function
equal <- function(x, y, tol=.Machine$double.eps^0.5) all(abs(x - y)  < tol)

m <- rnorm(5)
p <- 2*pnorm(abs(m), lower.tail=FALSE)
m2 <- qnorm(p/2, lower.tail=FALSE)*sign(m)

equal(m, m2)

(The helper function is just to test floating point values computed
differently for equality.)

Hope this helps,

Rui Barradas

Em 20-07-2012 12:36, carol white escreveu:

> Thanks for your reply.
>
> So to derive it from a given data set, is the following correct to do?
>
> my_data.p =2*pnorm(abs(my_data),lower.tail=FALSE)
>
> my_data.q = qnorm(my_data.p)
>
> Cheers,
>
>
> ________________________________
>   From: Duncan Murdoch <[hidden email]>
>
> Cc: "[hidden email]" <[hidden email]>
> Sent: Friday, July 20, 2012 1:23 PM
> Subject: Re: [R] function for inverse normal transformation
>
> On 12-07-20 6:21 AM, carol white wrote:
>> Hi,
>> What is the function for inverse normal transformation?
> qnorm
>
> Duncan Murdoch
>
>> Thanks,
>>
>> Carol
>>
>>      [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] 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.
>>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> [hidden email] 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.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

carol white
Thanks Rui.
I changed my scripts to the followings and I think that it still is not correct. See also the attached file.

Thanks for your help,


 tmp
 [1]  2.502519  1.828576  3.755778 17.415000  3.779296  2.956850  2.379663
 [8]  1.103559  8.920316  2.744500  2.938480  7.522174 10.629200  8.552259
[15]  5.425938  4.388906  0.000000  0.723887 11.337860  3.763786


 tmp.p =2*pnorm(abs(scale(tmp)),lower.tail=FALSE)
>  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)
>  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)*sign(tmp)
> equal(tmp, tmp.qnorm)
[1] FALSE
> par(mfrow = c(1,3))
> hist(tmp)
> hist(tmp.p)
> hist(tmp.qnorm)



________________________________
 From: Rui Barradas <[hidden email]>
To: carol white <[hidden email]>
Cc: r-help <[hidden email]>
Sent: Friday, July 20, 2012 2:02 PM
Subject: Re: [R] function for inverse normal transformation
 

Hello,

No it's not correct, you are computing a what seems to be a
    two-tailed probabiity, so the inverse should account for it. Look
    closely: you take the absolute value, then the upper tail
    probability, then multiply 2 into it. Reverse these steps to get the
    correct value.

# Helper function
equal <- function(x, y, tol=.Machine$double.eps^0.5) all(abs(x -
    y)  < tol)

m <- rnorm(5)
p <- 2*pnorm(abs(m), lower.tail=FALSE)
m2 <- qnorm(p/2, lower.tail=FALSE)*sign(m)

equal(m, m2)

(The helper function is just to test floating point values computed
    differently for equality.)

Hope this helps,

Rui Barradas


Em 20-07-2012 12:36, carol white escreveu:

Thanks for your reply. So to derive it from a given data set, is the following correct to do? my_data.p =2*pnorm(abs(my_data),lower.tail=FALSE) my_data.q = qnorm(my_data.p) Cheers, ________________________________ From: Duncan Murdoch <[hidden email]> Cc: "[hidden email]" <[hidden email]> Sent: Friday, July 20, 2012 1:23 PM
Subject: Re: [R] function for inverse normal transformation On 12-07-20 6:21 AM, carol white wrote:
>Hi,
What is the function for inverse normal transformation?
>qnorm Duncan Murdoch
>Thanks, Carol     [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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.
>[[alternative HTML version deleted]]
>
>
>______________________________________________ [hidden email] 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.
______________________________________________
[hidden email] 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.

tmp.png (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

Duncan Murdoch-2
On 20/07/2012 8:28 AM, carol white wrote:
> Thanks Rui.
> I changed my scripts to the followings and I think that it still is not correct.

You haven't told us clearly what you are trying to achieve, and you
don't tell us what is wrong with what you have.  How do you expect
anyone to help?

Duncan Murdoch


> See also the attached file.
>
> Thanks for your help,
>
>
>   tmp
>   [1]  2.502519  1.828576  3.755778 17.415000  3.779296  2.956850  2.379663
>   [8]  1.103559  8.920316  2.744500  2.938480  7.522174 10.629200  8.552259
> [15]  5.425938  4.388906  0.000000  0.723887 11.337860  3.763786
>
>
>   tmp.p =2*pnorm(abs(scale(tmp)),lower.tail=FALSE)
> >  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)
> >  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)*sign(tmp)
> > equal(tmp, tmp.qnorm)
> [1] FALSE
> > par(mfrow = c(1,3))
> > hist(tmp)
> > hist(tmp.p)
> > hist(tmp.qnorm)
>
>
>
> ________________________________
>   From: Rui Barradas <[hidden email]>
> To: carol white <[hidden email]>
> Cc: r-help <[hidden email]>
> Sent: Friday, July 20, 2012 2:02 PM
> Subject: Re: [R] function for inverse normal transformation
>  
>
> Hello,
>
> No it's not correct, you are computing a what seems to be a
>      two-tailed probabiity, so the inverse should account for it. Look
>      closely: you take the absolute value, then the upper tail
>      probability, then multiply 2 into it. Reverse these steps to get the
>      correct value.
>
> # Helper function
> equal <- function(x, y, tol=.Machine$double.eps^0.5) all(abs(x -
>      y)  < tol)
>
> m <- rnorm(5)
> p <- 2*pnorm(abs(m), lower.tail=FALSE)
> m2 <- qnorm(p/2, lower.tail=FALSE)*sign(m)
>
> equal(m, m2)
>
> (The helper function is just to test floating point values computed
>      differently for equality.)
>
> Hope this helps,
>
> Rui Barradas
>
>
> Em 20-07-2012 12:36, carol white escreveu:
>
> Thanks for your reply. So to derive it from a given data set, is the following correct to do? my_data.p =2*pnorm(abs(my_data),lower.tail=FALSE) my_data.q = qnorm(my_data.p) Cheers, ________________________________ From: Duncan Murdoch <[hidden email]> Cc: "[hidden email]" <[hidden email]> Sent: Friday, July 20, 2012 1:23 PM
> Subject: Re: [R] function for inverse normal transformation On 12-07-20 6:21 AM, carol white wrote:
> >Hi,
> What is the function for inverse normal transformation?
> >qnorm Duncan Murdoch
> >Thanks, Carol     [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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.
> >[[alternative HTML version deleted]]
> >
> >
> >______________________________________________ [hidden email] 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.
>
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

David Carlson
In reply to this post by carol white
Rui's example included z-score data (drawn from rnorm). You converted your
data to z-scores so you need to compare your results to the z-scores not
the original data.

Change these lines:

tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)*sign(scale(tmp))
# sign is of scale(tmp) not tmp
equal(scale(tmp), tmp.qnorm)
# compare to scale(tmp) not tmp

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@r-
> project.org] On Behalf Of carol white
> Sent: Friday, July 20, 2012 7:29 AM
> To: Rui Barradas
> Cc: [hidden email]
> Subject: Re: [R] function for inverse normal transformation
>
> Thanks Rui.
> I changed my scripts to the followings and I think that it still is not
> correct. See also the attached file.
>
> Thanks for your help,
>
>
>  tmp
>  [1]  2.502519  1.828576  3.755778 17.415000  3.779296  2.956850
> 2.379663
>  [8]  1.103559  8.920316  2.744500  2.938480  7.522174 10.629200
> 8.552259
> [15]  5.425938  4.388906  0.000000  0.723887 11.337860  3.763786
>
>
>  tmp.p =2*pnorm(abs(scale(tmp)),lower.tail=FALSE)
> >  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)
> >  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)*sign(tmp)
> > equal(tmp, tmp.qnorm)
> [1] FALSE
> > par(mfrow = c(1,3))
> > hist(tmp)
> > hist(tmp.p)
> > hist(tmp.qnorm)
>
>
>
> ________________________________
>  From: Rui Barradas <[hidden email]>
> To: carol white <[hidden email]>
> Cc: r-help <[hidden email]>
> Sent: Friday, July 20, 2012 2:02 PM
> Subject: Re: [R] function for inverse normal transformation
>
>
> Hello,
>
> No it's not correct, you are computing a what seems to be a
>     two-tailed probabiity, so the inverse should account for it. Look
>     closely: you take the absolute value, then the upper tail
>     probability, then multiply 2 into it. Reverse these steps to get
> the
>     correct value.
>
> # Helper function
> equal <- function(x, y, tol=.Machine$double.eps^0.5) all(abs(x -
>     y)  < tol)
>
> m <- rnorm(5)
> p <- 2*pnorm(abs(m), lower.tail=FALSE)
> m2 <- qnorm(p/2, lower.tail=FALSE)*sign(m)
>
> equal(m, m2)
>
> (The helper function is just to test floating point values computed
>     differently for equality.)
>
> Hope this helps,
>
> Rui Barradas
>
>
> Em 20-07-2012 12:36, carol white escreveu:
>
> Thanks for your reply. So to derive it from a given data set, is the
> following correct to do? my_data.p
> =2*pnorm(abs(my_data),lower.tail=FALSE) my_data.q = qnorm(my_data.p)
> Cheers, ________________________________ From: Duncan Murdoch
> <[hidden email]> Cc: "[hidden email]" <r-
> [hidden email]> Sent: Friday, July 20, 2012 1:23 PM
> Subject: Re: [R] function for inverse normal transformation On 12-07-20
> 6:21 AM, carol white wrote:
> >Hi,
> What is the function for inverse normal transformation?
> >qnorm Duncan Murdoch
> >Thanks, Carol     [[alternative HTML version deleted]]
> ______________________________________________ [hidden email]
> 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.
> >[[alternative HTML version deleted]]
> >
> >
> >______________________________________________ [hidden email]
> 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

Rui Barradas
Hello,

Yes, Carol is comparing what can't be compared. Your code should do it,
I hope.

Rui Barradas

Em 20-07-2012 15:12, David L Carlson escreveu:

> Rui's example included z-score data (drawn from rnorm). You converted your
> data to z-scores so you need to compare your results to the z-scores not
> the original data.
>
> Change these lines:
>
> tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)*sign(scale(tmp))
> # sign is of scale(tmp) not tmp
> equal(scale(tmp), tmp.qnorm)
> # compare to scale(tmp) not tmp
>
> ----------------------------------------------
> David L Carlson
> Associate Professor of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
>> -----Original Message-----
>> From: [hidden email] [mailto:r-help-bounces@r-
>> project.org] On Behalf Of carol white
>> Sent: Friday, July 20, 2012 7:29 AM
>> To: Rui Barradas
>> Cc: [hidden email]
>> Subject: Re: [R] function for inverse normal transformation
>>
>> Thanks Rui.
>> I changed my scripts to the followings and I think that it still is not
>> correct. See also the attached file.
>>
>> Thanks for your help,
>>
>>
>>   tmp
>>   [1]  2.502519  1.828576  3.755778 17.415000  3.779296  2.956850
>> 2.379663
>>   [8]  1.103559  8.920316  2.744500  2.938480  7.522174 10.629200
>> 8.552259
>> [15]  5.425938  4.388906  0.000000  0.723887 11.337860  3.763786
>>
>>
>>   tmp.p =2*pnorm(abs(scale(tmp)),lower.tail=FALSE)
>>>    tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)
>>>    tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)*sign(tmp)
>>> equal(tmp, tmp.qnorm)
>> [1] FALSE
>>> par(mfrow = c(1,3))
>>> hist(tmp)
>>> hist(tmp.p)
>>> hist(tmp.qnorm)
>>
>>
>> ________________________________
>>   From: Rui Barradas <[hidden email]>
>> To: carol white <[hidden email]>
>> Cc: r-help <[hidden email]>
>> Sent: Friday, July 20, 2012 2:02 PM
>> Subject: Re: [R] function for inverse normal transformation
>>
>>
>> Hello,
>>
>> No it's not correct, you are computing a what seems to be a
>>      two-tailed probabiity, so the inverse should account for it. Look
>>      closely: you take the absolute value, then the upper tail
>>      probability, then multiply 2 into it. Reverse these steps to get
>> the
>>      correct value.
>>
>> # Helper function
>> equal <- function(x, y, tol=.Machine$double.eps^0.5) all(abs(x -
>>      y)  < tol)
>>
>> m <- rnorm(5)
>> p <- 2*pnorm(abs(m), lower.tail=FALSE)
>> m2 <- qnorm(p/2, lower.tail=FALSE)*sign(m)
>>
>> equal(m, m2)
>>
>> (The helper function is just to test floating point values computed
>>      differently for equality.)
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>>
>> Em 20-07-2012 12:36, carol white escreveu:
>>
>> Thanks for your reply. So to derive it from a given data set, is the
>> following correct to do? my_data.p
>> =2*pnorm(abs(my_data),lower.tail=FALSE) my_data.q = qnorm(my_data.p)
>> Cheers, ________________________________ From: Duncan Murdoch
>> <[hidden email]> Cc: "[hidden email]" <r-
>> [hidden email]> Sent: Friday, July 20, 2012 1:23 PM
>> Subject: Re: [R] function for inverse normal transformation On 12-07-20
>> 6:21 AM, carol white wrote:
>>> Hi,
>> What is the function for inverse normal transformation?
>>> qnorm Duncan Murdoch
>>> Thanks, Carol     [[alternative HTML version deleted]]
>> ______________________________________________ [hidden email]
>> 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.
>>> [[alternative HTML version deleted]]
>>>
>>>
>>> ______________________________________________ [hidden email]
>> 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

John Fox
In reply to this post by carol white
Dear Carol,

> -----Original Message-----
> From: carol white [mailto:[hidden email]]
> Sent: July-20-12 2:45 PM
> To: John Fox
> Subject: Re: inverse normal transformation
>
> Thanks John for your quick reply.
>
> The purpose of applying inverse normal transformation is to reduce the
> impact of outliers and deviations from normality on statistical
> analysis.

In other words, you're forcing the variable to follow a normal distribution
and making the units of measurement uninterpretable. I'll assume that this
somehow makes sense.

>
> Indeed, it includes the steps that you went through. However, I don't
> know why you calculated  (rank - 0.5)/20 to get the p-value. Then, how
> could we convert the quantiles (Q) into normal deviates?

They *are* quantiles on the standard normal scale -- that's what qnorm()
provides (with the default mean of 0 and standard deviation of 1). The
cumulative probabilities (not p-values) are calculated from the order
statistics of your data, where subtracting 0.5 avoids cumulative
probabilities of 0 or 1. This (or something close to it) is standard for
computing comparison quantiles.

I'm copying this message to r-help (with the original subject line) since
the discussion there continues.

Best,
 John

>
> Many thanks,
>
> Carol
>
>
> ________________________________
>
> From: John Fox <[hidden email]>
> To: 'carol white' <[hidden email]>
> Sent: Friday, July 20, 2012 4:43 PM
> Subject: RE: inverse normal transformation
>
>
> Dear Carol,
>
> Like the people on r-help list who tried to help you, I have no idea
> why you
> want to do this. If you're trying to get the corresponding standard
> normal
> quantiles for your data, as for a QQ plot (and why else you might want
> them
> isn't clear to me), you can simply compute
>
> rank <- rank(tmp)
> P <- (rank - 0.5)/20
> Q <- qnorm(P)
>
> Then, the QQ plot is
>
> plot(Q, tmp)
>
> Best,
> John
>
> --------------------------------
> John Fox
> Senator William McMaster
>   Professor of Social Statistics
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox
>
>
>
>
> > -----Original Message-----
> > From: carol white [mailto:[hidden email]]
> > Sent: July-20-12 9:08 AM
> > To: [hidden email]
> > Subject: inverse normal transformation
> >
> > Dear John,
> >
> >
> > Are the following scripts correct to get the inverse normal
> > transformation of a data set?
> >
> >
> > Thanks for your help,
> >
> >
> > Carol
> > -----------------------------------------------
> >
> >  tmp
> >  [1]  2.502519  1.828576  3.755778 17.415000  3.779296  2.956850
> > 2.379663  [8]  1.103559  8.920316  2.744500  2.938480  7.522174
> > 10.629200  8.552259 [15]  5.425938  4.388906  0.000000  0.723887
> > 11.337860  3.763786
> >
> >
> >  tmp.p =2*pnorm(abs(scale(tmp)),lower.tail=FALSE)
> > >  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)  tmp.qnorm =
> > > qnorm(tmp.p/2,lower.tail=FALSE)
> >
> > > par(mfrow = c(1,3))
> > > hist(tmp)
> > > hist(tmp.p)
> > > hist(tmp.qnorm)
> >
>
>
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: function for inverse normal transformation

Bert Gunter
The nature of her inquiries suggests to me that Carol strongly needs
to consult a local statistician rather than fooling around with this
list.

-- Bert

On Fri, Jul 20, 2012 at 11:56 AM, John Fox <[hidden email]> wrote:

> Dear Carol,
>
>> -----Original Message-----
>> From: carol white [mailto:[hidden email]]
>> Sent: July-20-12 2:45 PM
>> To: John Fox
>> Subject: Re: inverse normal transformation
>>
>> Thanks John for your quick reply.
>>
>> The purpose of applying inverse normal transformation is to reduce the
>> impact of outliers and deviations from normality on statistical
>> analysis.
>
> In other words, you're forcing the variable to follow a normal distribution
> and making the units of measurement uninterpretable. I'll assume that this
> somehow makes sense.
>
>>
>> Indeed, it includes the steps that you went through. However, I don't
>> know why you calculated  (rank - 0.5)/20 to get the p-value. Then, how
>> could we convert the quantiles (Q) into normal deviates?
>
> They *are* quantiles on the standard normal scale -- that's what qnorm()
> provides (with the default mean of 0 and standard deviation of 1). The
> cumulative probabilities (not p-values) are calculated from the order
> statistics of your data, where subtracting 0.5 avoids cumulative
> probabilities of 0 or 1. This (or something close to it) is standard for
> computing comparison quantiles.
>
> I'm copying this message to r-help (with the original subject line) since
> the discussion there continues.
>
> Best,
>  John
>
>>
>> Many thanks,
>>
>> Carol
>>
>>
>> ________________________________
>>
>> From: John Fox <[hidden email]>
>> To: 'carol white' <[hidden email]>
>> Sent: Friday, July 20, 2012 4:43 PM
>> Subject: RE: inverse normal transformation
>>
>>
>> Dear Carol,
>>
>> Like the people on r-help list who tried to help you, I have no idea
>> why you
>> want to do this. If you're trying to get the corresponding standard
>> normal
>> quantiles for your data, as for a QQ plot (and why else you might want
>> them
>> isn't clear to me), you can simply compute
>>
>> rank <- rank(tmp)
>> P <- (rank - 0.5)/20
>> Q <- qnorm(P)
>>
>> Then, the QQ plot is
>>
>> plot(Q, tmp)
>>
>> Best,
>> John
>>
>> --------------------------------
>> John Fox
>> Senator William McMaster
>>   Professor of Social Statistics
>> Department of Sociology
>> McMaster University
>> Hamilton, Ontario, Canada
>> http://socserv.mcmaster.ca/jfox
>>
>>
>>
>>
>> > -----Original Message-----
>> > From: carol white [mailto:[hidden email]]
>> > Sent: July-20-12 9:08 AM
>> > To: [hidden email]
>> > Subject: inverse normal transformation
>> >
>> > Dear John,
>> >
>> >
>> > Are the following scripts correct to get the inverse normal
>> > transformation of a data set?
>> >
>> >
>> > Thanks for your help,
>> >
>> >
>> > Carol
>> > -----------------------------------------------
>> >
>> >  tmp
>> >  [1]  2.502519  1.828576  3.755778 17.415000  3.779296  2.956850
>> > 2.379663  [8]  1.103559  8.920316  2.744500  2.938480  7.522174
>> > 10.629200  8.552259 [15]  5.425938  4.388906  0.000000  0.723887
>> > 11.337860  3.763786
>> >
>> >
>> >  tmp.p =2*pnorm(abs(scale(tmp)),lower.tail=FALSE)
>> > >  tmp.qnorm = qnorm(tmp.p/2,lower.tail=FALSE)  tmp.qnorm =
>> > > qnorm(tmp.p/2,lower.tail=FALSE)
>> >
>> > > par(mfrow = c(1,3))
>> > > hist(tmp)
>> > > hist(tmp.p)
>> > > hist(tmp.qnorm)
>> >
>>
>>
>>
>>
>
> ______________________________________________
> [hidden email] 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.



--

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

______________________________________________
[hidden email] 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.
Loading...