Re: [R] How do I print predicted effect sizes in forest plot?

2013-12-09 Thread Alma Wilflinger
Thank you very much Wolfgang and Michael for your help and information.
Now I know how to get the predicted values.

For information, my "mean" is the effect size for the one-sample-case. 
Obviously I used misleading labels, but I calculated the same with CMA and 
getting the same results, so it should be okay.

Best wishes,
Alma




On Friday, December 6, 2013 3:10 PM, Michael Dewey  
wrote:
 
At 21:05 05/12/2013, Alma Wilflinger wrote:
>Hi,
>
>I am struggling a bit with creating a forest plot containing the 
>predicted effect size. As seen in other studies these effect sizes 
>are shown per study usually as a light grey diamond - which is what 
>I want to achieve.
>
>The calls I use are:
>iat_result = rma(yi=Mean, vi=Variance_rounded, ni=N, sei=Std_error, 
>slab=Study_Name, subset=(Country == "AUT"), data=cma_iat, method="HS")

Alma
You do not need to specify both vi and sei as one is sufficient and 
you do not need ni as well.
I realise that is not the question you asked (which Wolfgang has 
already answered).


>summary.rma(iat_result)
>
>
>#not sure how to use it or if needed
>#predict(iat_result)
>
>forest(iat_result)
>
>
>At the end I am getting the forest plot as is without the predicted values.
>
>I am not sure if I need the predict function and how to use it? - 
>the predict function deliveres the same values as already computed 
>in the rma object.
>
>
>I checked the manual for package metafor but was not able to find 
>out how to print the predicted values per study.
>
>
>kind regards, Alma
>         [[alternative HTML version deleted]]

Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html
[[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] How do I print predicted effect sizes in forest plot?

2013-12-05 Thread Alma Wilflinger
Hi,

I am struggling a bit with creating a forest plot containing the predicted 
effect size. As seen in other studies these effect sizes are shown per study 
usually as a light grey diamond - which is what I want to achieve.

The calls I use are:
iat_result = rma(yi=Mean, vi=Variance_rounded, ni=N, sei=Std_error, 
slab=Study_Name, subset=(Country == "AUT"), data=cma_iat, method="HS")

summary.rma(iat_result)


#not sure how to use it or if needed
#predict(iat_result)

forest(iat_result)


At the end I am getting the forest plot as is without the predicted values. 

I am not sure if I need the predict function and how to use it? - the predict 
function deliveres the same values as already computed in the rma object.


I checked the manual for package metafor but was not able to find out how to 
print the predicted values per study.


kind regards, Alma
[[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] dummy encoding in metafor

2013-01-28 Thread Alma Wilflinger
Dear Wolfgang,

Thank you very much for answering!

1) No, I am doing a Meta Analysis and take the
 ds from existing studies. To be exactly, I do use D (Means of 
D-Measure which is not exactly d, but very similar) 
3) Yes CMA makes a new column with st. error and variance differ from 1.

for
 example my mean is 0,6, and I take 1 for the st. dev and 154 is my N, the new 
values are 0,080582 for the st. error and 6,49E-03 for the 
variance

So did I make a mistake by taking the parameters for R?
vi is my mean
yi is my variance. I took the uncalculated variance which is 1. is this wrong? 
do I have to take the variances from the new column from CMA?

kind regards,
alma



 From: Viechtbauer Wolfgang (STAT) 


t.co.uk>; "r-help@r-project.org"  
Sent: Monday, January 28, 2013 10:38 AM
Subject: RE: [R] dummy encoding in metafor

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 information did you supply to CMA for the computation of those 
d values? (means, standard deviations, and the sample sizes of the two groups?)
3) Did CMA then provide you with a column of values that are the corresponding 
sampling variances or standard errors? (those values should NOT all be equal to 
1!)

Best,
Wolfgang

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Alma Wilflinger
> Sent: Sunday, January 27, 2013 21:52
> To: Michael Dewey; r-help@r-project.org
> Subject: Re: [R] dummy encoding in metafor
> 
> Hi Michael!
> 
> Yes, I do use Cohens d. As a matter of fact my thesis supervisor told me
> to use 1 as the value for standard deviation for all of my studies.
> Unfortunately I am not totally sure myself why to do this have you ever
> used such an approach?
> 
> kind regards,
> Alma
> 
> 
>  From: Michael Dewey 
> 
> t.co.uk>; "r-help@r-project.org" 
> Sent: Thursday, January 24, 2013 6:57 PM
> Subject: Re: [R] dummy encoding in metafor
> 
> At 22:06 23/01/2013, Alma Wilflinger wrote:
> 
> > Hi Michael,
> >
> > The supervisor for my Master's Thesis told me that my means are the
> effect size and cause of this I have to take figure 1 for all standard
> deviations. So I hope that was the right information.
> 
> Alma
> There is a fairly comprehensive list of all the things which might be an
> effect size on
> http://en.wikipedia.org/wiki/Effect_size
> Is what you call Mean one of them?
> 
> 
> >
> > From: Michael Dewey 
> 
> wolfgang.viechtba...@maastrichtuniversity.nl>; Michael Dewey
> ; "r-help@r-project.org" 
> > Sent: Wednesday, January 23, 2013 10:22 AM
> > Subject: Re: [R] dummy encoding in metafor
> >
> > At 08:30 23/01/2013, Alma Wilflinger wrote:
> > > Dear Wolfgang and Michael,
> > >
> [[elided Yahoo spam]]
> > >
> > > Concerning the Variance: I took the variance I used for CMA (which
> is always 1), so I think it should be the right one.
> >
> > It seems unlikely to me that the variance from each study would be the
> same although I suppose it could be possible. Are you sure you are
> supplying the right values to CMA?
> >
> >
> > > Thank you for noticing and mentioning though :)
> > >
> > > I really appreciate how helpful you both are.
> > >
> > > best,
> > > Alma
[[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] dummy encoding in metafor

2013-01-27 Thread Alma Wilflinger
Hi Michael!

Yes, I do use Cohens d. As a matter of fact my thesis supervisor told me to use 
1 as the value for standard deviation for all of my studies.
Unfortunately I am not totally sure myself why to do this have you ever used 
such an approach?

kind regards,
Alma





 From: Michael Dewey 

t.co.uk>; "r-help@r-project.org"  
Sent: Thursday, January 24, 2013 6:57 PM
Subject: Re: [R] dummy encoding in metafor

At 22:06 23/01/2013, Alma Wilflinger wrote:

> Hi Michael,
> 
> The supervisor for my Master's Thesis told me that my means are the effect 
> size and cause of this I have to take figure 1 for all standard deviations. 
> So I hope that was the right information.

Alma
There is a fairly comprehensive list of all the things which might be an effect 
size on
http://en.wikipedia.org/wiki/Effect_size
Is what you call Mean one of them?


> 
> From: Michael Dewey 

wolfgang.viechtba...@maastrichtuniversity.nl>; Michael Dewey 
; "r-help@r-project.org" 
> Sent: Wednesday, January 23, 2013 10:22 AM
> Subject: Re: [R] dummy encoding in metafor
> 
> At 08:30 23/01/2013, Alma Wilflinger wrote:
> > Dear Wolfgang and Michael,
> >
[[elided Yahoo spam]]
> >
> > Concerning the Variance: I took the variance I used for CMA (which is 
> > always 1), so I think it should be the right one.
> 
> It seems unlikely to me that the variance from each study would be the same 
> although I suppose it could be possible. Are you sure you are supplying the 
> right values to CMA?
> 
> 
> > Thank you for noticing and mentioning though :)
> >
> > I really appreciate how helpful you both are.
> >
> > best,
> > Alma
> >
> >
> >
> > From: Viechtbauer Wolfgang (STAT) 
> > <<mailto:wolfgang.viechtba...@maastrichtuniversity.nl>wolfgang.viechtba...@maastrichtuniversity.nl>
> > To: Michael Dewey <<mailto:i...@aghmed.fsnet.co.uk>i...@aghmed.fsnet.co
"<mailto:r-help@r-project.org>r-help@r-project.org" 
<<mailto:r-help@r-project.org>r-help@r-project.org>
> > Sent: Monday, January 21, 2013 11:10 AM
> > Subject: RE: [R] dummy encoding in metafor
> >
> > 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 is "only" 94 (which is actually 
> > quite large for a meta-analysis). One options is to leave out some of the 
> > predictors. You can also try collapsing some of the levels of the factors. 
> > Of course, you lose some "details" that way, but apparently you don't have 
> > enough data in the first place to carry out such a detailed analysis.
> >
> > One other thing I noticed. You wrote:
> >
> > rma(yi=Mean, vi=Variance, ni=N.1, ...)
> >
> > I suspect that your variable "Variance" is actually the variance of the raw 
> > scores. However, the vi argument is used to pass the sampling variances of 
> > the yi values to the function -- not the variance of raw scores. The 
> > (estimated) sampling variance of a mean is s^2 / n, so if I am not 
> > mistaken, you really want to use:
> >
> > rma(yi=Mean, vi=Variance/N.1, ...)
> >
> > Best,
> > Wolfgang
> >
> > --
> > Wolfgang Viechtbauer, Ph.D., Statistician
> > Department of Psychiatry and Psychology
> > School for Mental Health and Neuroscience
> > Faculty of Health, Medicine, and Life Sciences
> > Maastricht University, P.O. Box 616 (VIJV1)
> > 6200 MD Maastricht, The Netherlands
> > +31 (43) 388-4170 | http://www.wvbauer.com
> >
> > > -Original Message-
> > > From: 
> > > <mailto:r-help-boun...@r-project.org><mailto:r-help-boun...@r-project.org>r-help-boun...@r-project.org
> > >  [mailto:r-help-boun...@r-project.org]
> > > On Behalf Of Michael Dewey
> > > Sent: Monday, January 21, 2013 10:40
> > > To: Alma Wilflinger; Michael Dewey; 
> > > <mailto:r-help@r-project.org><mailto:r-help@r-project.org>r-help@r-project.org
> > > Subject: Re: [R] dummy encoding in metafor
> > >
> > > At 14:48 20/01/2013, Alma Wilflinger wrote:
> > > >Hi,
> > > >
> > > >thank you very much for your kind answer.
> > > >
> > > > >If you look a bit further down the manual page you will see
> > > > >### using a model 

Re: [R] dummy encoding in metafor

2013-01-23 Thread Alma Wilflinger


Hi Michael, 


The supervisorfor my Master'sThesis told me that my means are the effect size 
and cause of this I have to take figure 1 for all standard deviations. So I 
hope that was the right information.




 From: Michael Dewey 

lfgang.viechtba...@maastrichtuniversity.nl>; Michael Dewey 
; "r-help@r-project.org"  
Sent: Wednesday, January 23, 2013 10:22 AM
Subject: Re: [R] dummy encoding in metafor

At 08:30 23/01/2013, Alma Wilflinger wrote:
> Dear Wolfgang and Michael,
> 
[[elided Yahoo spam]]
> 
> Concerning the Variance: I took the variance I used for CMA (which is always 
> 1), so I think it should be the right one.

It seems unlikely to me that the variance from each study would be the same 
although I suppose it could be possible. Are you sure you are supplying the 
right values to CMA?


> Thank you for noticing and mentioning though :)
> 
> I really appreciate how helpful you both are.
> 
> best,
> Alma
> 
> 
> 
> From: Viechtbauer Wolfgang (STAT) 
> 
> To: Michael Dewey ; Alma Wilflinger 
> ; "r-help@r-project.org" 
> Sent: Monday, January 21, 2013 11:10 AM
> Subject: RE: [R] dummy encoding in metafor
> 
> 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 is "only" 94 (which is actually quite 
> large for a meta-analysis). One options is to leave out some of the 
> predictors. You can also try collapsing some of the levels of the factors. Of 
> course, you lose some "details" that way, but apparently you don't have 
> enough data in the first place to carry out such a detailed analysis.
> 
> One other thing I noticed. You wrote:
> 
> rma(yi=Mean, vi=Variance, ni=N.1, ...)
> 
> I suspect that your variable "Variance" is actually the variance of the raw 
> scores. However, the vi argument is used to pass the sampling variances of 
> the yi values to the function -- not the variance of raw scores. The 
> (estimated) sampling variance of a mean is s^2 / n, so if I am not mistaken, 
> you really want to use:
> 
> rma(yi=Mean, vi=Variance/N.1, ...)
> 
> Best,
> Wolfgang
> 
> --
> Wolfgang Viechtbauer, Ph.D., Statistician
> Department of Psychiatry and Psychology
> School for Mental Health and Neuroscience
> Faculty of Health, Medicine, and Life Sciences
> Maastricht University, P.O. Box 616 (VIJV1)
> 6200 MD Maastricht, The Netherlands
> +31 (43) 388-4170 | http://www.wvbauer.com
> 
> > -Original Message-
> > From: <mailto:r-help-boun...@r-project.org>r-help-boun...@r-project.org 
> > [mailto:r-help-boun...@r-project.org]
> > On Behalf Of Michael Dewey
> > Sent: Monday, January 21, 2013 10:40
> > To: Alma Wilflinger; Michael Dewey; 
> > <mailto:r-help@r-project.org>r-help@r-project.org
> > Subject: Re: [R] dummy encoding in metafor
> >
> > At 14:48 20/01/2013, Alma Wilflinger wrote:
> > >Hi,
> > >
> > >thank you very much for your kind answer.
> > >
> > > >If you look a bit further down the manual page you will see
> > > >### using a model formula to specify the same model
> > > >rma(yi, vi, mods=~factor(alloc)+year+ablat, data=dat, method="REML",
> > > >btt=c(2,3))
> > >
> > > >which is much easier.
> > >
> > >I have seen the possibility of using a model formula for dummy
> > >encoding and you are right it is much easier than doing it by hand.
> > >Thing is that if I include some moderator variables into the
> > >parameters I get the error:
> > >
> > >Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve
> >
> > I suspect that you have a linear dependence between your moderator
> > variables. Depending on how many levels there are for country,
> > sample, and so on you do have a lot of predictors (you presumably
> > know that a factor counts as levels-1 for this purpose?)
> >
> >
> > >For example this call works:
> > >result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) +
> > >relevel(factor(Sample), ref="Students") + Gender + Age +
> > >factor(Category) + relevel(factor(Block), ref="c")+
> > >relevel(factor(order), ref="x"), data=csvDataCmaAll, method="REML")
> > >
> > >If I add the trials which is of type INT:
> > >result = rma(y

Re: [R] dummy encoding in metafor

2013-01-23 Thread Alma Wilflinger
Dear Wolfgang and Michael,

thank you very much for your help!

Concerning the Variance: I took the variance I used for CMA (which is always 
1), so I think it should be the right one.

Thank you for noticing and mentioning though :) 

I really appreciate how helpful you both are.

best,
Alma





 From: Viechtbauer Wolfgang (STAT) 

To: Michael Dewey ; Alma Wilflinger 
; "r-help@r-project.org"  
Sent: Monday, January 21, 2013 11:10 AM
Subject: RE: [R] dummy encoding in metafor

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 is "only" 94 (which is actually quite large 
for a meta-analysis). One options is to leave out some of the predictors. You 
can also try collapsing some of the levels of the factors. Of course, you lose 
some "details" that way, but apparently you don't have enough data in the first 
place to carry out such a detailed analysis.

One other thing I noticed. You wrote:

rma(yi=Mean, vi=Variance, ni=N.1, ...)

I suspect that your variable "Variance" is actually the variance of the raw 
scores. However, the vi argument is used to pass the sampling variances of the 
yi values to the function -- not the variance of raw scores. The (estimated) 
sampling variance of a mean is s^2 / n, so if I am not mistaken, you really 
want to use:

rma(yi=Mean, vi=Variance/N.1, ...)

Best,
Wolfgang

--  
Wolfgang Viechtbauer, Ph.D., Statistician  
Department of Psychiatry and Psychology  
School for Mental Health and Neuroscience  
Faculty of Health, Medicine, and Life Sciences  
Maastricht University, P.O. Box 616 (VIJV1)  
6200 MD Maastricht, The Netherlands  
+31 (43) 388-4170 | http://www.wvbauer.com  

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Michael Dewey
> Sent: Monday, January 21, 2013 10:40
> To: Alma Wilflinger; Michael Dewey; r-help@r-project.org
> Subject: Re: [R] dummy encoding in metafor
> 
> At 14:48 20/01/2013, Alma Wilflinger wrote:
> >Hi,
> >
> >thank you very much for your kind answer.
> >
> > >If you look a bit further down the manual page you will see
> > >### using a model formula to specify the same model
> > >rma(yi, vi, mods=~factor(alloc)+year+ablat, data=dat, method="REML",
> > >btt=c(2,3))
> >
> > >which is much easier.
> >
> >I have seen the possibility of using a model formula for dummy
> >encoding and you are right it is much easier than doing it by hand.
> >Thing is that if I include some moderator variables into the
> >parameters I get the error:
> >
> >Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve
> 
> I suspect that you have a linear dependence between your moderator
> variables. Depending on how many levels there are for country,
> sample, and so on you do have a lot of predictors (you presumably
> know that a factor counts as levels-1 for this purpose?)
> 
> 
> >For example this call works:
> >result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) +
> >relevel(factor(Sample), ref="Students") + Gender + Age +
> >factor(Category) + relevel(factor(Block), ref="c")+
> >relevel(factor(order), ref="x"), data=csvDataCmaAll, method="REML")
> >
> >If I add the trials which is of type INT:
> >result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) +
> >relevel(factor(Sample), ref="Students") + Gender + Age +
> >factor(Category) + relevel(factor(Block), ref="c")+
> >relevel(factor(order), ref="x") + trials, data=csvDataCmaAll,
> method="REML")
> >
> >I get the error and I was not able to find a definite reason for
> >this error or how to solve it I wanted to try it by doing it manually.
> >I think I have found out that it somehow relates to the
> >
> > >If you code them yourself R does not know. You know.
> >
> >Regarding this I think my question was not clear enough. If R does
> >the dummy encoding automatically via a model formula it leaves out
> >one of the factors and uses it as a baseline automatically. If I do
> >it by hand R is still able to execute the function but the baseline
> >is missing because I do not define it via a parameter.
> 
> You perhaps would benefit from rereading some of the introductory
> material about formulas. Also look for anything about the model
> matrix (also called the design matrix)
> 
&

Re: [R] dummy encoding in metafor

2013-01-20 Thread Alma Wilflinger
Hi, 

thank you very much for your kind answer.

>If you look a bit further down the manual page you will see
>### using a model formula to specify the same model
>rma(yi, vi, mods=~factor(alloc)+year+ablat, data=dat, method="REML", 
>btt=c(2,3))


>which is much easier.


I have seen the possibility of using a model formula for dummy encoding and you 
are right it is much easier than doing it by hand.
Thing is that if I include some moderator variables into the parameters I get 
the error:

Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve

For example this call works:
result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) + 
relevel(factor(Sample), ref="Students") + Gender + Age + factor(Category) + 
relevel(factor(Block), ref="c")+ relevel(factor(order), ref="x"), 
data=csvDataCmaAll, method="REML")


If I add the trials which is of type INT:
result = rma(yi=Mean, vi=Variance, ni=N.1, mods=~factor(Country) + 
relevel(factor(Sample), ref="Students") + Gender + Age + factor(Category) + 
relevel(factor(Block), ref="c")+ relevel(factor(order), ref="x") + trials, 
data=csvDataCmaAll, method="REML")

I get the error and I was not able to find a definite reason for this error or 
how to solve it I wanted to try it by doing it manually. 
I think I have found out that it somehow relates to the 

>If you code them yourself R does not know. You know.

Regarding this I think my question was not clear enough. If R does the dummy 
encoding automatically via a model formula it leaves out one of the factors and 
uses it as a baseline automatically. If I do it by hand R is still able to 
execute the function but the baseline is missing because I do not define it via 
a parameter.
I simply want to know how R is handling this and what I have to do by hand to 
get the correct results. Sorry, this may be a beginners question, but as stated 
I am new to this field.

>You say you have seven moderator variables. Unless you have a shed 

>load of studies you will not be able to look at them simultaneously. 
>Apologies if you already knew that.


No I have not known that. In total I have about 94 studies and want to test 
different sets of moderators. Do you think this is sufficient or do you suggest 
another approach?
I started in CMA (comprehensive meta analysis) but one of the benefits of R is 
that I am able to test multiple moderators at once - at least as I was told.

kind regards,
Alma



 From: Michael Dewey 

r-project.org> 
Sent: Sunday, January 20, 2013 12:52 PM
Subject: Re: [R] dummy encoding in metafor

At 17:14 19/01/2013, Alma Wilflinger wrote:
>Hi,
>
>I am quite new to R and in need of some advice. I am trying to 
>conduct a meta regression over a some studies with about 7 mod 
>variables which I have to dummy encode.

Alma, although you can generate your own dummy variables by hand you 
do not have to as R will do it for you. See below for more comments.


>I have found the following piece of code in the manual for the 
>metafor library:
>
>### manual dummy coding of the allocation factor
>alloc.random <- ifelse(dat$alloc == "random", 1, 0)
>alloc.alternate <- ifelse(dat$alloc == "alternate", 1, 0)
>alloc.systematic <- ifelse(dat$alloc == "systematic", 1, 0)

If you look a bit further down the manual page you will see
### using a model formula to specify the same model
rma(yi, vi, mods=~factor(alloc)+year+ablat, data=dat, method="REML",
btt=c(2,3))

which is much easier.

>### test the allocation factor (in the presence of the other moderators)
>### note: "alternate" is the reference level of the allocation factor
>### note: the intercept is the first coefficient, so btt=c(2,3)
>rma(yi, vi, mods=cbind(alloc.random, alloc.systematic, year, ablat), 
>data=dat, method="REML", btt=c(2,3))
>
>What I do not understand is the following:
>How does R know which columns in my data.frame are related to the 
>dummy encoded variables?

If you code them yourself R does not know. You know.


>It is clear that in the call of cbind I just do not use the 
>reference variable as a parameter but I do not get it how R knows 
>that alloc.random and alloc.systematic refer to the column alloc in 
>the data frame.
>
>Thank you very much in advance for your help,
>

You say you have seven moderator variables. Unless you have a shed 
load of studies you will not be able to look at them simultaneously. 
Apologies if you already knew that.

>kind regards,
>Alma
>         [[alternative HTML version deleted]]

Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html
[[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] dummy encoding in metafor

2013-01-19 Thread Alma Wilflinger
Hi,

I am quite new to R and in need of some advice. I am trying to conduct a meta 
regression over a some studies with about 7 mod variables which I have to dummy 
encode.

I have found the following piece of code in the manual for the metafor library:

### manual dummy coding of the allocation factor
alloc.random <- ifelse(dat$alloc == "random", 1, 0)
alloc.alternate <- ifelse(dat$alloc == "alternate", 1, 0)
alloc.systematic <- ifelse(dat$alloc == "systematic", 1, 0)

### test the allocation factor (in the presence of the other moderators)
### note: "alternate" is the reference level of the allocation factor
### note: the intercept is the first coefficient, so btt=c(2,3)
rma(yi, vi, mods=cbind(alloc.random, alloc.systematic, year, ablat), data=dat, 
method="REML", btt=c(2,3))

What I do not understand is the following: 
How does R know which columns in my data.frame are related to the dummy encoded 
variables?

It is clear that in the call of cbind I just do not use the reference variable 
as a parameter but I do not get it how R knows that alloc.random and 
alloc.systematic refer to the column alloc in the data frame.

Thank you very much in advance for your help,


kind regards, 
Alma
[[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.