Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate arcsin(sgn(x)√|x|)?

I'm trying to arcsine squareroot data lying on [-1,1]. Using transf.arcsine from the metafor package produces NaNs when trying to squareroot the negative datapoints. Conceptually, I want to use arcsin(sgn(x)√|x|) i.e. square the absolute value, apply its previous sign, then arcsine transform it. The trouble is I have no idea how to begin doing this in R. Help would be appreciated.

like image 541
gisol Avatar asked Jul 23 '12 21:07

gisol


2 Answers

x <- seq(-1, 1, length = 20)
asin(sign(x) * sqrt(abs(x)))

or as a function

trans.arcsine <- function(x){
  asin(sign(x) * sqrt(abs(x)))
}
trans.arcsine(x)
like image 95
Thierry Avatar answered Sep 20 '22 17:09

Thierry


Help in R is just help() or help.search(). So, let's try the obvious,

> help(arcsin)
No documentation for ‘arcsin’ in specified packages and libraries:

OK, that's not good. But it must be able to trig... let's try something even simpler.

help(sin)

There's all the trig functions. And I note, there's a link to Math on the page. Clicking that seems to provide all of the functions you need. It turns out that I could have just typed..

help(Math)

also,

help.search('trigonometry')
like image 29
John Avatar answered Sep 21 '22 17:09

John