Re: [R] arcsine transformation with metafor

2014-11-24 Thread Viechtbauer Wolfgang (STAT)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Antonello Preti
 Sent: Monday, November 24, 2014 00:35
 To: r-help@r-project.org
 Subject: [R] arcsine transformation with metafor
 
 # I'm trying to adapt to my own data the double arcsine transformation
 according to Miller (1978) as described in the metafor site
 # I've understood all passages (I think)
 # I'm able to build a forest plot with the correct data
 # I would like to build a funnel plot and a radial plot
 # However, the rule that is helpful to build a forest plot does not work
 for the radial or the funnel plot
 # When I use the results of the fixed (or random) effects model, as
 expected, the estimates are wrong (about two times the correct estimates)
 # How can the radial and funnel plot be built for the double arcsine
 transformation?
 
 # Thank you in advance, Antonello
 
 # Here the code I've used
 
 library(metafor)
 
 # The data used by Miller (1978) to illustrate the transformation and its
 inversion can be re-created with:
 
 dat - data.frame(xi=c(3, 6, 10, 1), ni=c(11, 17, 21, 6))
 dat$pi - with(dat, xi/ni)
 dat - escalc(measure=PFT, xi=xi, ni=ni, data=dat)

[SNIP]

 res - rma(yi, vi, method=FE, data=dat)

[SNIP]
 
 ### However, this is wrong
 
 radial(res)
 funnel(res)

They are not wrong. The double arcsine transformed values are used for the 
plotting, not the raw proportions. In particular, the plots are based on 'yi' 
in:

 dat
  xi nipi yi vi
1  3 11 0.2727273 0.5695 0.0217
2  6 17 0.3529412 0.6444 0.0143
3 10 21 0.4761905 0.7626 0.0116
4  1  6 0.167 0.4758 0.0385

Best,
Wolfgang

__
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] arcsine transformation with metafor

2014-11-23 Thread Antonello Preti
# I'm trying to adapt to my own data the double arcsine transformation
according to Miller (1978) as described in the metafor site
# I've understood all passages (I think)
# I'm able to build a forest plot with the correct data
# I would like to build a funnel plot and a radial plot
# However, the rule that is helpful to build a forest plot does not work
for the radial or the funnel plot
# When I use the results of the fixed (or random) effects model, as
expected, the estimates are wrong (about two times the correct estimates)
# How can the radial and funnel plot be built for the double arcsine
transformation?

# Thank you in advance, Antonello

# Here the code I've used

library(metafor)

# The data used by Miller (1978) to illustrate the transformation and its
inversion can be re-created with:

dat - data.frame(xi=c(3, 6, 10, 1), ni=c(11, 17, 21, 6))
dat$pi - with(dat, xi/ni)
dat - escalc(measure=PFT, xi=xi, ni=ni, data=dat)

dat

# The yi values are the Freeman-Tukey (double arcsine) transformed
proportions,
# while the vi values are the corresponding sampling variances.

# We can check whether the back-transformation works for individual values
with:

transf.ipft(dat$yi, dat$ni)


#  As described by Miller (1978), we can aggregate the transformed values,
# either by computing an unweighted or a weighted mean (with
inverse-variance weights).
# The unweighted mean can be obtained with:

res - rma(yi, vi, method=FE, data=dat, weighted=FALSE)
res


# The value reported by Miller for the unweighted mean is again twice as
large as the value given above,
# which we can confirm with:

predict(res, transf=function(x) x*2)



# To back-transform the average, a value for the sample size is needed.
# Miller suggests to use the harmonic mean of the individual sample sizes
in the inversion formula.
# This can be accomplished with:

predict(res, transf=transf.ipft.hm, targs=list(ni=dat$ni))


# Since the true proportions appear to be homogeneous (e.g., Q(3)=2.18,
p=.54),
# a more efficient estimate of the true proportion can be obtained by using
inverse-variance weights.
# For this, we first synthesize the transformed values with:

res - rma(yi, vi, method=FE, data=dat)
res


# Again, the value reported by Miller is twice as large.
# We can back-transform the estimated transformed average with:

predict(res, transf=transf.ipft.hm, targs=list(ni=dat$ni))


# When using the Freeman-Tukey transformation,
# an additional complication arises when using the back-transformation.



# To back-transform the individual proportions, we need the individual
sample sizes:

transf.ipft(dat$yi, dat$ni)


# To back-transform the estimated average transformed proportion,
# we need to use the harmonic mean of the sample sizes:

res - rma(yi, vi, method=FE, data=dat)
pred - predict(res, transf=transf.ipft.hm, targs=list(ni=dat$ni))
pred



# To build  a forest plot we need to first obtain the CI bounds of the
individual studies with:

dat.back - summary(dat, transf=transf.ipft, ni=dat$ni)



# Now the back-transformation is applied to each transformed proportion
with the study-specific sample sizes.
# The yi values are now the back-transformed values (i.e., the raw
proportions)
# and the ci.lb and ci.ub values are the back-transformed 95% CI bounds.1)

# Finally, we can create the forest plot by directly passing the observed
outcomes (i.e., proportions)
# and the CI bounds to the function. Then the back-transformed average with
the corresponding CI bounds obtained earlier
# can be added to the plot with the addpoly() function. We add a couple
tweaks to make the final forest plot look nice:


forest(dat.back$yi, ci.lb=dat.back$ci.lb, ci.ub=dat.back$ci.ub,
   xlim=c(-.5,1.8), alim=c(0,1), ylim=c(-1,8), refline=NA, digits=3,
xlab=Proportion)
addpoly(pred$pred, ci.lb=pred$ci.lb, ci.ub=pred$ci.ub, row=-0.5, digits=3,
mlab=FE Model, efac=1.3)
abline(h=0.5)
text(-0.5, 7, Study,   pos=4)
text( 1.8, 7, Proportion [95% CI], pos=2)


### However, this is wrong

radial(res)
funnel(res)

##  sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Italian_Italy.1252  LC_CTYPE=Italian_Italy.1252
[3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] metafor_1.9-3 Matrix_1.1-0  Formula_1.1-1

loaded via a namespace (and not attached):
[1] grid_3.0.2  lattice_0.20-24

[[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] Arcsine transformation

2013-09-24 Thread Michael Dewey

At 02:26 23/09/2013, peake wrote:

Thanks for the advice. Like I said, I am still pretty new to R, and stats
in general. I tried wading through the search results on google, but I
didn't really find anything that I could understand. I am working with
percentages as my dependent variable, and I am trying to get my
distribution as close to normal as possible. Is an arcsine transformation
even the correct choice for my data? Querying R for help usually leaves me
even more confused, so I was hoping someone could help me out by walking me
through the process.


Transforming proportions is something which people involved in 
meta-analysis of non-comparative studies often do. You might like to 
look in the manual for metafor (on CRAN) and the function escalc 
which has a range of options under non-comparative studies. You might 
also look at betareg (on CRAN).


I think you also need to find some local statistical support as your 
question is now less about R and more about statistics.





On Sun, Sep 22, 2013 at 8:00 PM, chuck.01 [via R] 
ml-node+s789695n4676708...@n4.nabble.com wrote:

 ?asin

 also, try Googling anything you might want to do in R... it is there

 also, google... R cheatsheet  you will find several helpful sheets of
 useful functions.



 peake wrote
 I am tryin to perform an arcsine transformation on my data containig
 percentages as the dep. variable. Does anyone have a code that I could use
 to do that? I am relatively new to R. Thanks for your help!



 --
  If you reply to this email, your message will be added to the discussion
 below:
 http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706p4676708.html
  To unsubscribe from Arcsine transformation, click 
herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4676706code=cGVha2UuMTlAb3N1LmVkdXw0Njc2NzA2fDE4MjEzMDk3MTU=

 .
 
NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml






--
View this message in context: 
http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706p4676712.html

Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]


Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

__
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] Arcsine transformation

2013-09-22 Thread peake
I am tryin to perform an arcsine transformation on my data containig
percentages as the dep. variable. Does anyone have a code that I could use
to do that? I am relatively new to R. Thanks for your help!



--
View this message in context: 
http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Arcsine transformation

2013-09-22 Thread Ben Bolker
peake peake.19 at osu.edu writes:

 
 I am tryin to perform an arcsine transformation on my data containig
 percentages as the dep. variable. Does anyone have a code that I could use
 to do that? I am relatively new to R. Thanks for your help!

asin(x/100)

? or

asin(x/100)*2/pi if you want the results rescaled to (0,1)

curve(asin(x/100)*2/pi,from=0,to=100)

__
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] Arcsine transformation

2013-09-22 Thread Peter Alspach
Tena koe

I think you'll find the arcsine transformation is asin(sqrt(x/100)) where × is 
the percentage.  However, it might be better to ask whether the data wouldn't 
be better analysed using generalised models (e.g., glm).

HTH 

Peter Alspach

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ben Bolker
Sent: Monday, 23 September 2013 12:54 p.m.
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] Arcsine transformation

peake peake.19 at osu.edu writes:

 
 I am tryin to perform an arcsine transformation on my data containig 
 percentages as the dep. variable. Does anyone have a code that I could 
 use to do that? I am relatively new to R. Thanks for your help!

asin(x/100)

? or

asin(x/100)*2/pi if you want the results rescaled to (0,1)

curve(asin(x/100)*2/pi,from=0,to=100)

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

The contents of this e-mail are confidential and may be ...{{dropped:14}}

__
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] Arcsine transformation

2013-09-22 Thread Ben Bolker
On 13-09-22 09:25 PM, Peter Alspach wrote:
 Tena koe
 
 I think you'll find the arcsine transformation is asin(sqrt(x/100))
 where × is the percentage.  However, it might be better to ask
 whether the data wouldn't be better analysed using generalised models
 (e.g., glm).
 
 HTH 
 

  Good point about arcsine-sqrt, and about GLMs: specifically see

Warton, David I., and Francis K. C. Hui. 2011. “The Arcsine Is Asinine:
The Analysis of Proportions in Ecology.” Ecology 92 (1) (January): 3–10.
doi:10.1890/10-0340.1.
http://www.esajournals.org/doi/full/10.1890/10-0340.1.

  I think the title is a little silly, but it's worth reading.

 Peter Alspach
 
 -Original Message- From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker Sent:
 Monday, 23 September 2013 12:54 p.m. To: r-h...@stat.math.ethz.ch 
 Subject: Re: [R] Arcsine transformation
 
 peake peake.19 at osu.edu writes:
 
 
 I am tryin to perform an arcsine transformation on my data
 containig percentages as the dep. variable. Does anyone have a code
 that I could use to do that? I am relatively new to R. Thanks for
 your help!
 
 asin(x/100)
 
 ? or
 
 asin(x/100)*2/pi if you want the results rescaled to (0,1)
 
 curve(asin(x/100)*2/pi,from=0,to=100)
 
 __ 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.
 
 The contents of this e-mail are confidential and may be subject to
 legal privilege. If you are not the intended recipient you must not
 use, disseminate, distribute or reproduce all or any part of this
 e-mail or attachments.  If you have received this e-mail in error,
 please notify the sender and delete all material pertaining to this 
 e-mail.  Any opinion or views expressed in this e-mail are those of
 the individual sender and may not represent those of The New Zealand
 Institute for Plant and Food Research Limited.


__
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] Arcsine transformation

2013-09-22 Thread peake
Thanks for the advice. Like I said, I am still pretty new to R, and stats
in general. I tried wading through the search results on google, but I
didn't really find anything that I could understand. I am working with
percentages as my dependent variable, and I am trying to get my
distribution as close to normal as possible. Is an arcsine transformation
even the correct choice for my data? Querying R for help usually leaves me
even more confused, so I was hoping someone could help me out by walking me
through the process.


On Sun, Sep 22, 2013 at 8:00 PM, chuck.01 [via R] 
ml-node+s789695n4676708...@n4.nabble.com wrote:

 ?asin

 also, try Googling anything you might want to do in R... it is there

 also, google... R cheatsheet  you will find several helpful sheets of
 useful functions.



 peake wrote
 I am tryin to perform an arcsine transformation on my data containig
 percentages as the dep. variable. Does anyone have a code that I could use
 to do that? I am relatively new to R. Thanks for your help!



 --
  If you reply to this email, your message will be added to the discussion
 below:
 http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706p4676708.html
  To unsubscribe from Arcsine transformation, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4676706code=cGVha2UuMTlAb3N1LmVkdXw0Njc2NzA2fDE4MjEzMDk3MTU=
 .
 NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://r.789695.n4.nabble.com/Arcsine-transformation-tp4676706p4676712.html
Sent from the R help mailing list archive at Nabble.com.
[[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] arcsine transformation

2008-04-30 Thread Claire Sheller
I have been trying to preform both a bartlett's test and an arcsine
transformation on some average percentage data. I've tried inputting it
different ways and I keep getting the same error message:

 head(workingdata)
   DYAD   BEFORE AFTER
1 BG-FL 4.606772  5.787520
2 BG-LL 5.467503  7.847395
3 AD-MV 5.333735 11.107380
4 MM-FL 5.578708 12.063500
5 MM-MV 2.037605  6.415303
6 MM-RM 6.158885 11.911080
 bartlett.test(BEFORE ~ AFTER)
Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735, 5.578708,  :
  there must be at least 2 observations in each group
 asin(BEFORE)
[1] NaN NaN NaN NaN NaN NaN NaN
Warning message:
In asin(BEFORE) : NaNs produced

I'm at a loss here and I would greatly appreciate any guidance that could be
given me. Thank you!

-- 
Claire Sheller
Department of Anthropology
Tulane University
New Orleans, LA 70118
615-210-9129

[[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] arcsine transformation

2008-04-30 Thread Michael Kubovy
Perhaps you need
with(workingdata, asin(BEFORE))
or
asin(workingdata$BEFORE)
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

On Apr 30, 2008, at 4:52 PM, Claire Sheller wrote:

 I have been trying to preform both a bartlett's test and an arcsine
 transformation on some average percentage data. I've tried inputting  
 it
 different ways and I keep getting the same error message:

 head(workingdata)
   DYAD   BEFORE AFTER
 1 BG-FL 4.606772  5.787520
 2 BG-LL 5.467503  7.847395
 3 AD-MV 5.333735 11.107380
 4 MM-FL 5.578708 12.063500
 5 MM-MV 2.037605  6.415303
 6 MM-RM 6.158885 11.911080
 bartlett.test(BEFORE ~ AFTER)
 Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735,  
 5.578708,  :
  there must be at least 2 observations in each group
 asin(BEFORE)
 [1] NaN NaN NaN NaN NaN NaN NaN
 Warning message:
 In asin(BEFORE) : NaNs produced

 I'm at a loss here and I would greatly appreciate any guidance that  
 could be
 given me. Thank you!

 -- 
 Claire Sheller
 Department of Anthropology
 Tulane University
 New Orleans, LA 70118
 615-210-9129


[[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] arcsine transformation

2008-04-30 Thread Chuck Cleland

On 4/30/2008 4:52 PM, Claire Sheller wrote:

I have been trying to preform both a bartlett's test and an arcsine
transformation on some average percentage data. I've tried inputting it
different ways and I keep getting the same error message:


head(workingdata)

   DYAD   BEFORE AFTER
1 BG-FL 4.606772  5.787520
2 BG-LL 5.467503  7.847395
3 AD-MV 5.333735 11.107380
4 MM-FL 5.578708 12.063500
5 MM-MV 2.037605  6.415303
6 MM-RM 6.158885 11.911080

bartlett.test(BEFORE ~ AFTER)

Error in bartlett.test.default(c(4.606772, 5.467503, 5.333735, 5.578708,  :
  there must be at least 2 observations in each group


  bartlett.test() expects the second argument to be a vector or factor 
object giving the group for the corresponding elements of x.  You seem 
to have paired samples instead.



asin(BEFORE)

[1] NaN NaN NaN NaN NaN NaN NaN
Warning message:
In asin(BEFORE) : NaNs produced


  You might divide the values by 100 prior to asin().


I'm at a loss here and I would greatly appreciate any guidance that could be
given me. Thank you! 


--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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