Re: [R] Setting constraints in the glm package

2010-10-26 Thread Viechtbauer Wolfgang (STAT)
The constraint b1=b2 in a model such as b0 + b1 x1 + b2 x2 + b3 x3 implies that b0 + b1 (x1 + x2) + b3 x3, so just add x1 and x2 (call this x12) and fit the model b0 + b1 x12 + b3 x3 and you have imposed the constraint that b1=b2. To impose the constraint that b3=0, just fit the model without

Re: [R] Key combination that removes all R objects

2010-10-28 Thread Viechtbauer Wolfgang (STAT)
I am not aware of the existance of a shortcut that would do what you describe. On Windows, one could hit Ctrl-M, followed by R, but then one gets a prompt, asking for confirmation to remove all objects, but this can't be what you are referring to. Are you perhaps using Tinn-R and

Re: [R] metafor: including phylogenetic non-independence among species?

2010-11-12 Thread Viechtbauer Wolfgang (STAT)
Dear Scott, The short answer is: No, this is not possible. The longer answer is: In principle, this will be possible in the future. I am working on functions for the metafor package for multivariate meta-analyses (i.e., where we no longer assume that the observed outcomes or effect size

Re: [R] Breslow-Day test

2010-11-16 Thread Viechtbauer Wolfgang (STAT)
It's implemented in the metafor package. Using the example from the pdf that Marc pointed out: library(metafor) ai - c(53, 121, 95, 103, 64, 7, 0) bi - c(2, 3, 14, 27, 51, 29, 13) ci - c(61, 152, 114, 66, 81, 28, 0) di - c(1, 5, 7, 12,

Re: [R] txtProgressBar strange behavior in R 2.12.0

2010-11-22 Thread Viechtbauer Wolfgang (STAT)
I believe nobody has responded to far, so maybe this is not a wide-spread issue. However, I have also encountered this since upgrading to R 2.12.0 (Windows 7, 64-bit). In my simulations where I use txtProgressBar(), the problem usually disappears after the bar has progressed to a certain

Re: [R] metafor and meta-analysis at arm-level

2010-08-05 Thread Viechtbauer Wolfgang (STAT)
: Maastricht University, P.O. Box 616 Room B2.01 (second floor) 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck) Original Message From: Angelo Franchini [mailto:angelo.franch...@bristol.ac.uk] Sent: Wednesday, August 04, 2010 16:26 To: Viechtbauer Wolfgang (STAT) Cc

Re: [R] Metafor

2010-08-05 Thread Viechtbauer Wolfgang (STAT)
Correct. -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (0)43 388-2277 School for Public Health and Primary Care Office Location: Maastricht University, P.O. Box 616 Room B2.01 (second floor) 6200 MD

Re: [R] metafor and meta-analysis at arm-level

2010-08-09 Thread Viechtbauer Wolfgang (STAT)
Room B2.01 (second floor) 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck) Original Message From: Angelo Franchini [mailto:angelo.franch...@bristol.ac.uk] Sent: Sunday, August 08, 2010 13:09 To: Viechtbauer Wolfgang (STAT) Cc: r-help@r-project.org Subject: RE: [R

Re: [R] Fixed variance structure for lme

2010-10-05 Thread Viechtbauer Wolfgang (STAT)
If the sampling variances are known up to a proportionality constant, then you can use: weights = varFixed(~ vi) where vi is the vector of the 50 sampling variances (corresponding to the 50 values of the dependent variable). You may have to create the vi vector by repeating the 5 sampling

Re: [R] Highly significant intercept and large standard error

2010-10-06 Thread Viechtbauer Wolfgang (STAT)
I do not know about the details of the model, but the results are not all that strange. I'll assume that you are using family=gaussian(), so you are essentially running a model where (Intercept) reflects the mean of the dependent variable for that third category (MagMid) of the Mag factor and

Re: [R] Highly significant intercept and large standard error

2010-10-06 Thread Viechtbauer Wolfgang (STAT)
Debyeplein 1 (Randwyck) Original Message From: Chris Mcowen [mailto:sam_sm...@me.com] Sent: Wednesday, October 06, 2010 16:38 To: Viechtbauer Wolfgang (STAT) Cc: r-help@r-project.org Subject: Re: [R] Highly significant intercept and large standard error Hi Wolfgang, Thanks

Re: [R] Poisson Regression

2010-10-14 Thread Viechtbauer Wolfgang (STAT)
I think it's useful to realize that this approach still implies that the \phi_{i}'s are entered as fixed effects into the model (as opposed to treating the \phi_{i}'s as random effects); it's just that the iterative algorithm to obtain the maximum likelihood estimates is faster when using

Re: [R] structural equation modeling

2009-10-28 Thread Viechtbauer Wolfgang (STAT)
There is the 'sem' package: http://cran.r-project.org/web/packages/sem/index.html The task views (http://cran.r-project.org/web/views/) are often a good place to start when looking for particular techniques/methods. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/

Re: [R] how to fetch rows with certain characteristics

2009-10-29 Thread Viechtbauer Wolfgang (STAT)
tapply(x, y, min) where x is the vector of numbers and y the vector of class labels. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (0)43 388-2277 School for Public Health and Primary Care Office Location:

Re: [R] influence.measures(stats): hatvalues(model, ...)

2009-11-08 Thread Viechtbauer Wolfgang (STAT)
Not sure what you mean. yi - c(2,3,2,4,3,6) xi - c(1,4,3,2,4,5) res - lm(yi ~ xi) hatvalues(res) X - cbind(1, xi) diag( X%*%solve(t(X)%*%X)%*%t(X) ) Same result. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31

Re: [R] MCMC gradually slows down

2009-11-08 Thread Viechtbauer Wolfgang (STAT)
Try this: Instead of: theta = c() use: theta - rep(NA, 50) or however many iterations you want the algorithm to run. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (0)43 388-2277 School for Public Health

Re: [R] Finding covariance in a lmer mixed effects model

2009-11-11 Thread Viechtbauer Wolfgang (STAT)
The way you have specified the model implies that the covariance is 0. If you actually want to estimate the covariance, you need to use: fm1 - lmer(fpg ~ 1 + time + (time|ID), fpg_lme) Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and

Re: [R] multivariate meta-analysis with the metafor package

2009-11-15 Thread Viechtbauer Wolfgang (STAT)
Dear Antonio, Yes, I am currently working on these extensions. It will take some time before those functions are sufficiently tested and documented and can become part of the metafor package. My goal is to do so within the next year, but I cannot give any specific date for when this will be

Re: [R] creating a new corClass for lme()

2010-04-14 Thread Viechtbauer Wolfgang (STAT)
No idea if this helps, but if the optimizer (nlminb) is giving you problems, you could try switching to another optimizer (nlm) with: control=list(opt=nlm) Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (43)

[R] Writing methods for existing generic function

2010-04-19 Thread Viechtbauer Wolfgang (STAT)
Dear All, Suppose I want to write a method for the generic function confint(): args(confint) function (object, parm, level = 0.95, ...) So, it looks like the second and third argument have been predefined in the generic function. Suppose one or several of the predefined arguments don't apply

Re: [R] R crashing oddly

2010-04-22 Thread Viechtbauer Wolfgang (STAT)
A similar problem was mentioned before: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q3/001425.html There appears to be a bug in the C code leading to memory corruption. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and

Re: [R] Structural Equation Models(SEM)

2009-11-25 Thread Viechtbauer Wolfgang (STAT)
The model you have specified there is not an ordinary factor analysis model. This may be closer to what you are thinking of: model.RLIM - specify.model() f1 - R, laddR, NA f1 - L, laddL, NA f1 - I, laddI, NA f1 - M, laddM, NA R - R, dR, NA L - L, dL, NA

Re: [R] z to r transformation within print.rma.uni and forest from the package metafor

2009-12-04 Thread Viechtbauer Wolfgang (STAT)
Dear Sebastian, Glad to hear you find the package useful. Before I get to your questions, just as an aside - you can leave default arguments out of the call. So: MAergebnis-rma.uni(ri=PosOutc, ni=N, data=dm, slab=c(dm$Article, dm$StudyNo), measure=ZCOR, method=DL) would do exactly the same as

Re: [R] Forest Plot

2009-12-05 Thread Viechtbauer Wolfgang (STAT)
The figure that you linked to was produced with the metafor package. It can also be used to produce a forest plot if you have means and corresponding standard errors of the means. The standard error of a mean is equal to SD / sqrt(n), so as long as you also know the sample sizes (n), you can

Re: [R] Forest Plot

2009-12-07 Thread Viechtbauer Wolfgang (STAT)
Debyeplein 1 (Randwyck) Original Message From: Xin Ge [mailto:xingemaill...@gmail.com] Sent: Sunday, December 06, 2009 00:40 To: Viechtbauer Wolfgang (STAT) Cc: r-help@r-project.org Subject: Re: [R] Forest Plot Thanks for your reply. Which function I should explore in metafor package

Re: [R] help: forest plots

2009-12-14 Thread Viechtbauer Wolfgang (STAT)
If you have the bounds of a 95% CI in the form of: exponential(estimate +/- 1.96*SE) then it is easy to get the SE back: SE = (log(UL) - log(LL)) / (2*1.96) Then supply the estimates and the SEs to the forest() function: forest(estimate, sei=SE) You can use: forest(estimate, sei=SE,

Re: [R] metafor: using mixed models

2010-01-04 Thread Viechtbauer Wolfgang (STAT)
Dear Joris, When you call rma() with the (default) argument intercept=TRUE, then the intercept is added to the X matrix (a column of 1s is added). So, if you use: fac - c(1,1,2,3,3,4,4,5,5,5) X - model.matrix(~factor(fac))[,2:5] and then: rma(ai, bi, ci, di, mods=X, data=testdata, measure=OR)

[R] Is the Intercept Term always in First Position?

2010-01-05 Thread Viechtbauer Wolfgang (STAT)
Dear All, I have a question about formulas and model.matrix(). If one specifies a model via a formula, the corresponding design matrix can be obtained with the model.matrix() function. For example: x1 - c(1,4,2,3,5) x2 - c(1,1,2,2,2) myformula - ~ x1 + factor(x2) model.matrix(myformula) My

Re: [R] back transforming arcsine transformations in metafor

2010-06-10 Thread Viechtbauer Wolfgang (STAT)
Dear Chris, Just define the following function: transf.iasin - function(x) { z - sin(x)^2 return(z) } to give the inverse of the arcsine transformation. Then specify this function under the atransf argument. I will add the transf.iasin() function to the package. Best, -- Wolfgang

Re: [R] meta analysis with repeated measure-designs?

2010-06-12 Thread Viechtbauer Wolfgang (STAT)
Dear Gerrit, the most appropriate approach for data of this type would be a proper multivariate meta-analytic model (along the lines of Kalaian Raudenbush, 1996). Since you do not know the correlations of the reaction time measurements across conditions for the within-subject designs, a

Re: [R] Question on WLS (gls vs lm)

2010-06-24 Thread Viechtbauer Wolfgang (STAT)
The weights in 'aa' are the inverse standard deviations. But you want to use the inverse variances as the weights: aa - (attributes(summary(f1)$modelStruct$varStruct)$weights)^2 And then the results are essentially identical. Best, -- Wolfgang Viechtbauer

Re: [R] metafor and meta-analysis at arm-level

2010-07-09 Thread Viechtbauer Wolfgang (STAT)
With appropriate design matrix, I mean the X matrix in the mixed-effects model y = Xb + u + e, where y is the vector of outcomes, u is a vector of (possibly correlated) random effects, and e is a vector of (possibly) random errors. The X matrix is specified via the 'mods' argument in the rma()

Re: [R] Once again: Error: cannot allocate vector of size

2010-01-22 Thread Viechtbauer Wolfgang (STAT)
The problem I see here is not so much the 27136 observations, but the fact that the first two factors have up to 101 different levels and the third factor up to 1001 different levels. That means that lm() is essentially creating 100+100+1000 dummies for those factors, leading to a large (and

Re: [R] add points to 3D plot using p3d {onion}

2010-01-27 Thread Viechtbauer Wolfgang (STAT)
Just as an aside, the scatterplot3d package does things like this very cleverly. Essentially, when you create a plot with scatterplot3d, the function actually returns functions with values set so that points3d(), for example, knows the axis scaling. Best, -- Wolfgang Viechtbauer

Re: [R] metafor package: effect sizes are not fully independent

2010-02-08 Thread Viechtbauer Wolfgang (STAT)
Hello Gang, Mike has already given you some excellent advice and references. I just want to add some information about the metafor package. To be precise, the meta-analytic mixed-effects model is given by: y_i = X_i * beta_i + u_i + e_i where X_i and beta_i have the usual interpretation, u_i

Re: [R] tests for measures of influence in regression

2010-02-22 Thread Viechtbauer Wolfgang (STAT)
I don't think this information can be found in the documentation, but you can always just check the actual influence.measures() and print.infl() code to find out. Most importantly, influence.measures() incldues the following code: function (model) { is.influential - function(infmat, n) {

Re: [R] OLS standard errors

2008-02-26 Thread Viechtbauer Wolfgang (STAT)
Try multiplying var(e) by n-1 and dividing by n-3 (97 are the degrees of freedom for the sum of squares error in your example). Then it all matches up nicely. Best, -- Wolfgang Viechtbauer  Department of Methodology and Statistics  University of Maastricht, The Netherlands  

[R] Optional data argument for a function

2008-02-29 Thread Viechtbauer Wolfgang (STAT)
Dear All, I am working on a function that has an optional data argument, just like lm(). If the user sets the data argument equal to some dataframe, then the function should look inside the dataframe for the variables given to other arguments, otherwise the variables should be accessible from

Re: [R] Summarising Data for Forrest Plots

2009-07-29 Thread Viechtbauer Wolfgang (STAT)
Are n.FD and n.RD the number of people who received the full/reduced dose and surv.FD and surv.RD the number of people that survived? And are the people who received the full dose different from the people who received the reduced dose? And what exactly is it that you want to plot in the forest

[R] R on an Asus Eee PC (step-by-step guide)

2008-04-28 Thread Viechtbauer Wolfgang (STAT)
Dear All, A while back, the question was raised whether R would run on an Eee PC: http://tolstoy.newcastle.edu.au/R/e3/help/07/12/6564.html There were some positive responses and some suggestions for getting this to work: http://tolstoy.newcastle.edu.au/R/e3/help/07/12/7244.html For those

Re: [R] meta regression in R using lme function

2009-04-30 Thread Viechtbauer Wolfgang (STAT)
Hello Jan, As far as know, fixing sigma to 1 is not possible in R with lme. That is why I started to write my own functions to allow me to fit mixed-effects models in R. Quite some time ago, I put one of those functions on my website, which can be downloaded here:

[R] New Meta-Analysis Package (metafor)

2009-06-05 Thread Viechtbauer Wolfgang (STAT)
A new package is now available via CRAN, called metafor. The metafor package consists of a collection of functions for conducting meta-analyses in R. Fixed- and random-effects models (with and without moderators) can be fitted via the general linear (mixed-effects) model. For 2x2 table data,

Re: [R] LME as part of meta-analysis

2009-03-28 Thread Viechtbauer Wolfgang (STAT)
Don't worry Emmanuel, not even people in Germany can figure out how exactly my last name is spelled =) I am actually getting quite close to finishing and releasing a first version of the package. The mima function will become obsolete at that point. Regarding the original post -- I am not

Re: [R] p-values from bootstrap - what am I not understanding?

2009-04-15 Thread Viechtbauer Wolfgang (STAT)
Some useful comments have already been made. I would like to comment on the two definitions of the p-value under (4) -- since I thought exactly about this issue a while back. Maybe this will be useful ... Suppose the distribution of a test statistic Z under H0 is given by f(Z) and that the

Re: [R] metafor random effects meta-analysis

2009-08-13 Thread Viechtbauer Wolfgang (STAT)
Correct, it is not possible to fix the residual variance to 1 in the R version of lme(), which is what one (typically) wants to do in meta-analyses, where the sampling variances are assumed to be (approximately) known. This is however possible in S-Plus, if you have access to that. Adding:

Re: [R] Using anova(f1, f2) to compare lmer models yields seemingly erroneous Chisq = 0, p = 1

2009-09-07 Thread Viechtbauer Wolfgang (STAT)
Are the two models (f1 and f2) actually nested? Aside from that, it is strange that the output is exactly the same after you used REML=FALSE. The log likelihoods should have changed. Best, -- Wolfgang Viechtbauer Department of Methodology and Statistics School for Public Health and Primary

Re: [R] add a header to a forest plot (metafor)

2010-03-02 Thread Viechtbauer Wolfgang (STAT)
Hi Sebastian, Here is an example showing a forest plot with some column headings: library(metafor) data(dat.bcg) dat - dat.bcg res - rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat, measure=RR) windows(width=6.5,

Re: [R] Meta-analysis with zero values for mean and sd

2011-07-11 Thread Viechtbauer Wolfgang (STAT)
I know nothing about the biological background here, but I also wonder if the standard meta-analytic approach is meaningful here. I also see some confusion in terminology (these are not count data!). There appear to be only 3 observations per group in each of the studies -- the standard

Re: [R] Extract confidence intervals from rma object (metafor package)

2011-07-18 Thread Viechtbauer Wolfgang (STAT)
Dear Jokel, Right now, none of the functions return that information. But it's easy to calculate those CIs by hand (simply take yi +- 1.96 sqrt(vi) and apply, if needed, some appropriate transformation). For example: data(dat.bcg) dat - escalc(measure=RR, ai=tpos, bi=tneg, ci=cpos, di=cneg,

Re: [R] compute the mean of two (or more) correlations

2011-07-26 Thread Viechtbauer Wolfgang (STAT)
And at that point, one is essentially doing a meta-analysis. For example: library(metafor) ri - c(.5, .4) ni - c(40, 25) res - rma(ri=ri, ni=ni, measure=ZCOR, method=FE) predict(res, transf=transf.ztor, digits=2) pred se ci.lb ci.ub 0.46 NA 0.24 0.64 You also get the CI (in addition to

Re: [R] Converting F-value from ANOVA to cohen's d in meta-analysis (metafor-package)

2011-07-27 Thread Viechtbauer Wolfgang (STAT)
Dear Jokel, Unfortunately, this won't work. The derivation of the equation given in the Handbook shows why this is so. First of all, note that d = (m1 - m2) / sp, where m1 and m2 are the means of the two groups and sp is the pooled SD. The two independent samples t-test (assuming

Re: [R] Main-effect of categorical variables in meta-analysis (metafor)

2011-08-05 Thread Viechtbauer Wolfgang (STAT)
Dear Jokel, If a moderator has 4 levels, then you need 3 dummy variables (one of the levels will become your reference level, so you do not need a dummy for that one). You can do the dummy-coding yourself or let R handle it. For example, if the moderator is called catmod, then: rma(yi, vi,

Re: [R] questions about metafor package

2011-08-17 Thread Viechtbauer Wolfgang (STAT)
Dear Emilie, Regarding your questions: 1) It's not the weighting that is the main issue when you do not have the SDs. The problem is that you need the SDs to calculate the sampling variances of the mean differences (I assume that this is your outcome measure for the meta-analysis). Those are

Re: [R] metaplot

2011-04-07 Thread Viechtbauer Wolfgang (STAT)
Actually, Scott suggested ggplot2, which is available on CRAN: http://cran.r-project.org/web/packages/ggplot2/index.html Moreover, for the metafor package, you do not need (a,b,c,d) or standard errors for the effect estimates. rr - c(0.61, 0.35, 1.16, 0.94, 1.16, 0.46, 0.99, 1.05, 1.15, 0.27)

Re: [R] metaplot

2011-04-08 Thread Viechtbauer Wolfgang (STAT)
To: Viechtbauer Wolfgang (STAT) Cc: R-help@r-project.org Subject: Re: [R] metaplot Thank you for your reply. forest(log(rr), ci.lbhttp://ci.lb=lci, ci.ub=uci, xlab=Log Relative Risk) Error in sei^2 : 'sei' is missing Regards, Cheba 2011/4/7 Viechtbauer Wolfgang (STAT) wolfgang.viechtba

Re: [R] forest + igraph ?

2011-04-12 Thread Viechtbauer Wolfgang (STAT)
It is not clear (at least to me) what exactly you want. You want two forest plots in one graph but apparently not side-by-side or one on top and the other on the bottom. So, you want to superimpose them? How do you want to do that without creating an illegible mess? Or do you want one graph,

Re: [R] forest + igraph ?

2011-04-12 Thread Viechtbauer Wolfgang (STAT)
...@stat.math.ethz.ch; Viechtbauer Wolfgang (STAT) Subject: RE: [R] forest + igraph ? Thank you for your reply. I would like to have two forest plots one on top and the other on the bottom. I am using R version 2.12.2 (32-bit) Windows. The code you sent me still plotting two windows one after the other

Re: [R] forest + igraph ?

2011-04-13 Thread Viechtbauer Wolfgang (STAT)
616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com -Original Message- From: Samor Gandhi [mailto:samorgan...@yahoo.com] Sent: Tuesday, April 12, 2011 15:59 To: r-h...@stat.math.ethz.ch; Viechtbauer Wolfgang (STAT

Re: [R] simulations with very large number of iterations (1 billion)

2011-04-15 Thread Viechtbauer Wolfgang (STAT)
We do not know the details of the kinds of computations you intend to do within each iteration, but if, let's say, each iterations takes around 1 second, then your simulation will run for the next 30+ years (on a single core). Even if each iteration only takes a fraction of a second, you are

Re: [R] Change color in forest.rma (metafor)

2011-08-24 Thread Viechtbauer Wolfgang (STAT)
Thank you, Bernd, for looking into this. Yes, at the moment, the color of the summary estimate for models without moderators is hard-coded (as black). I didn't think people may want to change that. I guess I was wrong =) A dirty solution for the moment is to add: addpoly(dfs, efac=6, row=-1,

Re: [R] Change color in forest.rma (metafor)

2011-08-25 Thread Viechtbauer Wolfgang (STAT)
...@gmail.com] Sent: Thursday, August 25, 2011 10:57 To: Viechtbauer Wolfgang (STAT) Cc: r-help@r-project.org; Bernd Weiss Subject: Re: [R] Change color in forest.rma (metafor) Thank you for your attention and help! In this way I get the diamond coloured, but actually I would have the squares

Re: [R] Bivariate normal regression in R

2011-08-25 Thread Viechtbauer Wolfgang (STAT)
Another way would be to consider this as a path model and use the sem or lavaan package to fit this model. Here is an example: x - rnorm(1000) e1 - rnorm(1000) e2 - e1 + rnorm(1000) e1 - e1 + rnorm(1000) y1 - 2 + 1*x + e1 y2 - 4 + 2*x + e2 dat - data.frame(x, y1, y2) model - 'y1 ~ x

Re: [R] Change color in forest.rma (metafor)

2011-08-29 Thread Viechtbauer Wolfgang (STAT)
See ?par and its mar argument. Could you tell me also how to change the size of the chart? There is not enough space below the chart to add the arrows! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] suggestion for proportions

2011-09-07 Thread Viechtbauer Wolfgang (STAT)
Acutally, ?mcnemar.test since it is paired data. Best, Wolfgang -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Wednesday, September 07, 2011 15:34 To: John Sorkin Cc: r-help@r-project.org Subject: Re:

Re: [R] suggestion for proportions

2011-09-07 Thread Viechtbauer Wolfgang (STAT)
, 2011 16:47 To: Viechtbauer Wolfgang (STAT) Cc: r-help@r-project.org; John Sorkin Subject: Re: [R] suggestion for proportions Wolfgang: On Wed, Sep 7, 2011 at 7:28 AM, Viechtbauer Wolfgang (STAT) wolfgang.viechtba...@maastrichtuniversity.nl wrote: Acutally, ?mcnemar.test since

Re: [R] suggestion for proportions

2011-09-08 Thread Viechtbauer Wolfgang (STAT)
I assume you mean Cohen's kappa. This is not what the OP is asking about. The OP wants to know how to test for a difference in the proportions of 1's. Cohen's kappa will tell you what the level of agreement is between the two tests. This is something different. Also, the OP has now clarified

Re: [R] predict.rma (metafor package)

2011-09-08 Thread Viechtbauer Wolfgang (STAT)
Hello Andrew, Take a look at the following: predict(model1, addx=T) predict(model2, addx=T) predict(model3, addx=T) As you can see, the factor was turned into dummy variables. However, the predict.rma() function does not expand a factor passed via newmods into the corresponding dummy

Re: [R] Metafor: Moderator variables for each study arm

2012-02-21 Thread Viechtbauer Wolfgang (STAT)
Dear Faiz, in principle, you can include whatever moderators you want in a meta-regression model. A technical issue here is that the two follow-up variables are probably strongly correlated, so this may create issues with the model fitting and it also complicates the interpretation of the

Re: [R] using metafor for meta-analysis of before-after studies

2012-04-05 Thread Viechtbauer Wolfgang (STAT)
To add to Michael's response: There are several things you can do: 1) If the dependent variable is the same in each study, then you could conduct the meta-analysis with the (raw) mean changes, i.e., yi = m1i - m2i, where m1i and m2i are the means at time 1 and 2, respectively. The sampling

Re: [R] meta-analysis, outcome = OR associated with a continuous independent variable

2012-04-05 Thread Viechtbauer Wolfgang (STAT)
I do not see any major difficulties with this case either. Suppose you have OR = 1.5 (with 95% CI: 1.19 to 1.90) indicating that the odds of a particular outcome (e.g., disease) is 1.5 times greater when the (continuous) exposure variable increases by one unit. Then you can back-calculate the

Re: [R] meta-analysis, outcome = OR associated with a continuous independent variable

2012-04-05 Thread Viechtbauer Wolfgang (STAT)
...@gmail.com [mailto:mp.sylves...@gmail.com] Sent: Thursday, April 05, 2012 15:23 To: Viechtbauer Wolfgang (STAT); Marie-Pierre Sylvestre Cc: r-help@r-project.org; Thomas Lumley Subject: Re: RE: [R] meta-analysis, outcome = OR associated with a continuous independent variable For some reason I

Re: [R] Using Metafor package: how to backtransform model coefficients when Freeman Tukey double arcine transformation is used

2010-12-16 Thread Viechtbauer Wolfgang (STAT)
Dear Patricia, I was recently asked the exact same question, so the answer is yes, but it takes a little bit of extra work and the newest version of the metafor package (version 1.5-0, which was submitted to CRAN yesterday and which should hopefully be ready for download in a few days). I'll

Re: [R] sample() issue

2010-12-20 Thread Viechtbauer Wolfgang (STAT)
See FAQ 7.31: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f And try this: 25000*(1-.55) - 11250 25000*.45 - 11250 Notice a difference? Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and

Re: [R] sample() issue

2010-12-20 Thread Viechtbauer Wolfgang (STAT)
Trying to make the fastest referal to FAQ 7.31 is becoming quite a sport around here. David beat us all to it on this round. Chances are there will be many more rounds to come. Best, Wolfgang Original Message From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On

Re: [R] Metafor package

2010-12-20 Thread Viechtbauer Wolfgang (STAT)
Dear Mario, 1) Whether to use 1/2* or not is arbitary. It's just a multiplicative constant. 2) vi - 1/(4*ni + 2) If one leave off the 1/2* part, then it would be vi - 1/(ni + 1/2). 3) Yes, but it takes a bit more work. Fortunately, the same issue was raised not very long ago, so the following

Re: [R] Metafor vs Meta vs Spreadsheet: wrong numbers

2011-01-13 Thread Viechtbauer Wolfgang (STAT)
Dear Serge-Étienne, Try: res - rma.uni(yi, vi, data=dat, method=DL) for the random-effects model when using the metafor package. You used method=HE -- this will give you a different estimator of tau^2 then the one used in the meta package. Best, -- Wolfgang Viechtbauer Department of

Re: [R] metafor/ meta-regression

2011-01-13 Thread Viechtbauer Wolfgang (STAT)
Dear Fernanda, Currently, there is no option in metafor that will automatically give you standardized coefficients for meta-regression models. The question is also how you would like to standardize those coefficients. In the usual regression models, the standardized coefficients are those that

Re: [R] Random Effects Meta Regression

2011-01-16 Thread Viechtbauer Wolfgang (STAT)
If b is the coefficient from the meta-regression model that indicates the (average) change in the outcome measure for a one-unit increase in the corresponding explanatory variable, then 5*b is the (average) change in the outcome measure for a 5-unit increase in the explanatory variable. Or

Re: [R] Sensitivity and Specificity Forest Plots

2011-11-22 Thread Viechtbauer Wolfgang (STAT)
Essentially, this is a side-by-side forest plot, where the plot on the left is for sensitivity and the plot on the right is for specificity. For 2x2 table data from diagnostic studies, it is easy to calculate the sensitivity and specificity values (and corresponding sampling variances) by hand.

Re: [R] Overlaying density plot on forest plot

2011-12-12 Thread Viechtbauer Wolfgang (STAT)
Here is an example. It requires a bit of extra work, but that's the beauty of R -- you can essentially customize a graph to your taste with low-level functions. I also added the prediction interval using the addcred argument (as suggested by Michael), since it gives the same information as that

Re: [R] metafor: weights computation in Mantel-Haenszel method

2012-01-15 Thread Viechtbauer Wolfgang (STAT)
Yes, I forgot to divide the weights by the sum of the weights (and multiply by 100) for weights.rma.mh(). This bug was pointed out to me a few weeks ago and this will be changed in the next version of the package. Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of

Re: [R] meta-analysis normal quantile plot metafor

2012-01-16 Thread Viechtbauer Wolfgang (STAT)
I do not know how Metawin calculates the confidence interval for the QQ-plot. The manual lists Chambers, Cleveland, Kleiner, and Tukey (1983) as a reference for the method used. Not sure whether that is the classical confidence interval. The method used in metafor is based on Cook and Weisberg

Re: [R] Metafor: Differences between two categories of a moderator

2011-05-31 Thread Viechtbauer Wolfgang (STAT)
Dear Holger, Actually, the omnibus test (QM-test) will give you the same result regardless of which category you make the reference category (try it out!). So, it will pick up all of the differences, whether they are to the reference category or between any of the other categories. If the

Re: [R] Metafor: Differences between two categories of a moderator

2011-06-02 Thread Viechtbauer Wolfgang (STAT)
Well, that's a good question. It actually applies to many different contexts (not just meta-analysis). Think of the ANOVA F-test and post-hoc/planned contrasts. It's essentially the same situation. And if you would ask 10 different statisticians about this, you may get 11 different answers. My

Re: [R] dummy encoding in metafor

2013-01-21 Thread Viechtbauer Wolfgang (STAT)
As Michael already mentioned, the error: Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve indeed indicates that your design matrix is not of full rank (i.e., there are linear dependencies among your predictors). With this many factors in the same model, this is not surprising if k

Re: [R] mixed effects meta-regression: nlme vs. metafor

2013-01-23 Thread Viechtbauer Wolfgang (STAT)
Hello Christian, First of all, it's good to see that you are well aware of the fact that lme() without lmeControl(sigma=1) will lead to the estimation of the residual variance component, which implies that the sampling variances specified via varFixed() are only assumed to be known up to a

Re: [R] dummy encoding in metafor

2013-01-28 Thread Viechtbauer Wolfgang (STAT)
Dear Alma, either there is a whole lot of miscommunicaton here, or you (and your supervisor) are way in over your head. You say that you are working with Cohen's d values. And you mentioned CMA. So, let me ask you some questions: 1) Has CMA computed those d values for you? 2) If yes, what

Re: [R] metafor - interpretion of QM in mixed-effects model with factor moderator

2013-02-27 Thread Viechtbauer Wolfgang (STAT)
Please see my comments below. Best, Wolfgang -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rachel Slatyer Sent: Wednesday, February 27, 2013 06:00 To: R-help@r-project.org Subject: [R] metafor - interpretion of QM in

Re: [R] Metafor SMCR Pre-Post Effect sizes

2013-03-04 Thread Viechtbauer Wolfgang (STAT)
Absolutely correct. The documentation wasn't clear on that. Changed for the next version of the package. And the escalc() function now no longer checks for sd2i, since it is not needed anyway (for SMCR). For now, you will just have to set sd2i to something (e.g., 0). Thanks for bringing this

[R] Broken Links on http://www.r-project.org

2012-09-26 Thread Viechtbauer Wolfgang (STAT)
I was not sure who I should contact about this, so I am posting this here. There are a few broken links on the R website. 1) http://www.r-project.org/search.html - link to the Nabble R Forum. I belive the correct/new URL should be: http://r.789695.n4.nabble.com/ 2)

Re: [R] What to use for ti in back-transforming summary statistics from F-T double square-root transformation in 'metafor'

2012-09-28 Thread Viechtbauer Wolfgang (STAT)
Dear Chunyan, One possibility would be to use the harmonic mean of the person-time at risk values. You will have to do this manually though at the moment. Here is an example: ### let's just use the treatment group data from dat.warfarin data(dat.warfarin) dat - escalc(xi=x1i, ti=t1i,

Re: [R] combine unadjusted and adjusted forest plots

2012-10-18 Thread Viechtbauer Wolfgang (STAT)
Dear Romita, It is not quite clear to me what exactly you want the graph to look like. What do you mean by plots of the unadjusted and adjusted models? In general though, it sounds to me as if the graph you have in mind is rather complex. It may be possible to accomplish this with the forest()

Re: [R] using metafor for meta-analysis of before-after studies (escalc, SMCC)

2013-05-21 Thread Viechtbauer Wolfgang (STAT)
Please see my answers below. Best, Wolfgang -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Moon Qiang Sent: Thursday, May 16, 2013 19:12 To: r-help Subject: [R] using metafor for meta-analysis of before-after studies

Re: [R] metafor matrix error

2013-05-22 Thread Viechtbauer Wolfgang (STAT)
Dear Branwen, This means that your design matrix is not of full rank (in a more recent version of the metafor package, the error message is a bit more informative; i.e., please upgrade). Since continent is a factor, this should imply that one of the levels never actually occurs, leading to a

Re: [R] using metafor for meta-analysis of before-after studies (escalc, SMCC)

2013-05-23 Thread Viechtbauer Wolfgang (STAT)
...@gmail.com] Sent: Wednesday, May 22, 2013 20:38 To: Viechtbauer Wolfgang (STAT); r-help Subject: Re: RE: [R] using metafor for meta-analysis of before-after studies (escalc, SMCC) Dear Dr. Viechtbauer: Thank you very much for sparing your precious time to answer my question. I still want

Re: [R] Strange behaviour of R graphics copied to PowerPoint

2013-06-03 Thread Viechtbauer Wolfgang (STAT)
I have come across this issue many times. I have yet to find a pattern in what causes this. At least I can offer a workaround. Instead of using Save As to create the pdf, what I do is Print with Adobe PDF as the printer. This gets rid of those lines and the resulting pdf looks just as nice.

Re: [R] Meta-analysis on a repeated measures design with multiple trials per subject using metafor

2013-07-04 Thread Viechtbauer Wolfgang (STAT)
Dear Marc, Let me see if I understand the type of data you have. You say that you have 5 experiments. And within each experiment, you have n subjects and for each subject, you have data in the form described in your post. Now for each subject, you want to calculate some kind of measure that

Re: [R] Meta-analysis on a repeated measures design with multiple trials per subject using metafor

2013-07-08 Thread Viechtbauer Wolfgang (STAT)
Wolfgang (STAT); r-help@r-project.org Subject: Re: [R] Meta-analysis on a repeated measures design with multiple trials per subject using metafor Dear Michael and other readers, Please see below for my answers to your questions about my data. On 07/06/2013 02:56 PM, Michael Dewey wrote

Re: [R] tweaking forest plot (metafor package)

2012-07-19 Thread Viechtbauer Wolfgang (STAT)
I think Michael already gave you some really good hints. To add a bit more details to this, first of all, I suggest to use: q2 - rma(yi, vi, mods=cbind(grupo), data=qim) forest(q2, transf=transf.ztor, digits=3, alim=c(0,1), refline=.5, addfit=FALSE) so that the fitted values for that

Re: [R] Annotate forest plot 'forest.rma()' for meta-analysis with metafor package

2012-07-25 Thread Viechtbauer Wolfgang (STAT)
Just replace the fixed y coordinate values in the text() calls with something that will change appropriately with the number of studies/effects included in the plot. For example: text(c(-9.5,-8,-6,-4.5), res$k+2, c(TB+, TB-, TB+, TB-)) text(c(-8.75,-5.25), res$k+3, c(Vaccinated, Control))

  1   2   >