[R] function for inverse normal transformation
Hi, What is the function for inverse normal transformation? Thanks, Carol [[alternative HTML version deleted]] __ 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.
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]] __ 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. __ 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.
Re: [R] function for inverse normal transformation
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 murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. [[alternative HTML version deleted]] __ 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.
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 murdoch.dun...@gmail.com To: carol white wht_...@yahoo.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. __ 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.
Re: [R] function for inverse normal transformation
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 wht_...@yahoo.com To: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. __ 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.
Re: [R] function for inverse normal transformation
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 murdoch.dun...@gmail.com To: carol white wht_...@yahoo.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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 murdoch.dun...@gmail.com To: carol white wht_...@yahoo.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. attachment: tmp.png__ 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.
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 murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. [[alternative HTML version deleted]] __ 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. [[alternative HTML version deleted]] __ 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.
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.00 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 ruipbarra...@sapo.pt To: carol white wht_...@yahoo.com Cc: r-help r-help@r-project.org 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 murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. [[alternative HTML version deleted]] __ 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. attachment: tmp.png__ 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.
Re: [R] function for inverse normal transformation
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 AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of carol white Sent: Friday, July 20, 2012 7:29 AM To: Rui Barradas Cc: r-help@r-project.org 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.00 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 ruipbarra...@sapo.pt To: carol white wht_...@yahoo.com Cc: r-help r-help@r-project.org 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 murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch r- h...@stat.math.ethz.ch 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]] __ 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. [[alternative HTML version deleted]] __ 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. __ 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.
Re: [R] function for inverse normal transformation
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.00 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 ruipbarra...@sapo.pt To: carol white wht_...@yahoo.com Cc: r-help r-help@r-project.org 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 murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch 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]] __ 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. [[alternative HTML version deleted]] __ 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. __ 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. __ 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.
Re: [R] function for inverse normal transformation
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 AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of carol white Sent: Friday, July 20, 2012 7:29 AM To: Rui Barradas Cc: r-help@r-project.org 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.00 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 ruipbarra...@sapo.pt To: carol white wht_...@yahoo.com Cc: r-help r-help@r-project.org 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 murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch r- h...@stat.math.ethz.ch 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]] __ 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. [[alternative HTML version deleted]] __ 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. __ 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.
Re: [R] function for inverse normal transformation
Dear Carol, -Original Message- From: carol white [mailto:wht_...@yahoo.com] 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 j...@mcmaster.ca To: 'carol white' wht_...@yahoo.com 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:wht_...@yahoo.com] Sent: July-20-12 9:08 AM To: j...@mcmaster.ca 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.00 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) __ 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.
Re: [R] function for inverse normal transformation
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 j...@mcmaster.ca wrote: Dear Carol, -Original Message- From: carol white [mailto:wht_...@yahoo.com] 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 j...@mcmaster.ca To: 'carol white' wht_...@yahoo.com 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:wht_...@yahoo.com] Sent: July-20-12 9:08 AM To: j...@mcmaster.ca 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.00 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) __ 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. -- 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 __ 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.