[R-sig-eco] how to standardize one variable to control for another confounding variable

Bede-Fazekas Ákos bfalevlist at gmail.com
Sat May 21 07:01:29 CEST 2016


Hello Baoping,

I think that's the solution proposed by Thierry.

 > df <- data.frame(size = runif(20) * 10, stage = c(rep("stage1", 7), 
rep("stage2", 7), rep("stage3", 6)))
 > df
         size  stage
1  3.4074887 stage1
2  8.4906095 stage1
3  9.4942578 stage1
4  5.8881368 stage1
5  8.8361620 stage1
6  0.7794099 stage1
7  1.1040311 stage1
8  9.2610258 stage2
9  2.8905632 stage2
10 4.1408304 stage2
11 2.8982138 stage2
12 2.9397847 stage2
13 2.6144625 stage2
14 4.9374664 stage2
15 8.6828374 stage3
16 0.2172812 stage3
17 4.8933184 stage3
18 5.2880694 stage3
19 1.8981373 stage3
20 5.5865985 stage3

 > df$size <- unlist(tapply(X = df$size, INDEX = df$stage, FUN = scale, 
simplify = TRUE))
 > df
           size  stage
1  -0.54627592 stage1
2   0.82762513 stage1
3   1.09889813 stage1
4   0.12421080 stage1
5   0.92102343 stage1
6  -1.25661121 stage1
7  -1.16887036 stage1
8   2.11969642 stage2
9  -0.56986326 stage2
10 -0.04201016 stage2
11 -0.56663322 stage2
12 -0.54908230 stage2
13 -0.68643082 stage2
14  0.29432335 stage2
15  1.42580094 stage3
16 -1.41082143 stage3
17  0.15601616 stage3
18  0.28828858 stage3
19 -0.84760338 stage3
20  0.38831913 stage3

HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences,
Centre for Ecological Research
Institute of Ecology and Botany

2016.05.21. 3:13 keltezéssel, 李保平 írta:
> Dera Thierry,
>       Thanks for the sugestion. Would you please give me more information about how to standardize one variable
> to control for the effect of another confounding one? it would be much helpful to expalin it with a example, as my statistic knowledge is limited.
>
>      I am looking for your reply.
>
>      with best wishes,
>
>       Baoping
>
>
>> -----原始邮件-----
>> 发件人: r-sig-ecology-request at r-project.org
>> 发送时间: 2016年5月19日 星期四
>> 收件人: r-sig-ecology at r-project.org
>> 抄送:
>> 主题: R-sig-ecology Digest, Vol 98, Issue 10
>>
>> Send R-sig-ecology mailing list submissions to
>> 	r-sig-ecology at r-project.org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> 	https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>> or, via email, send a message with subject or body 'help' to
>> 	r-sig-ecology-request at r-project.org
>>
>> You can reach the person managing the list at
>> 	r-sig-ecology-owner at r-project.org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of R-sig-ecology digest..."
>>
>>
>> Today's Topics:
>>
>>     1. help (lbp at njau.edu.cn)
>>     2. Re: help (Thierry Onkelinx)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Thu, 19 May 2016 08:39:33 +0800
>> From: "lbp at njau.edu.cn" <lbp at njau.edu.cn>
>> To: r-sig-ecology <r-sig-ecology at r-project.org>
>> Subject: [R-sig-eco] help
>> Message-ID: <201605190839272047103 at njau.edu.cn>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> Now I have difficulty to choose between two modelling approach. Here is th story. To examine the clutch size laid by a parasitic wasp into caterpillar hosts which varies in age and size, we exposed individual larvae of  three stages, after individually weighed, to parasitism, and the number of wasps emerged from each host (brood size) was recorded. Because host size and stage are mutually counfounding factors, the older the bigger, I have two modelling choices to separate the effect of stage and size. One is to make separate analyses, first analyzing the effct of stages in a model without the variable size, and then analyze the effect of the size under each stgae (several models); another approach is to make one analysis, put stage and size together in the same model to evaluate their separate and interacted effects on brood size.  For the later approach, the variable size actualy contains the inflormation about the stage, thus violating the independence assumation. I am won!
>>   dering which appraoch is approriate.
>>     
>>     Thanks for any help.
>>
>>    Baoping
>>
>>
>>
>>
>> E-mail: lbp at njau.edu.cn
>> Phone: 86 (25) 84396394
>>
>> 	[[alternative HTML version deleted]]
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Thu, 19 May 2016 09:55:16 +0200
>> From: Thierry Onkelinx <thierry.onkelinx at inbo.be>
>> To: "lbp at njau.edu.cn" <lbp at njau.edu.cn>
>> Cc: r-sig-ecology <r-sig-ecology at r-project.org>
>> Subject: Re: [R-sig-eco] help
>> Message-ID:
>> 	<CAJuCY5wP7bdpDX6pPm2t6us1Zgsm0OnhDK0Z_Ji=EBr_BmX+Sg at mail.gmail.com>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> Dear Baoping,
>>
>> You could standardize the weight by stage. That would remove the
>> confounding between weight and stage.
>>
>> Best regards,
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
>> Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of data.
>> ~ John Tukey
>>
>> 2016-05-19 2:39 GMT+02:00 lbp at njau.edu.cn <lbp at njau.edu.cn>:
>>
>>> Now I have difficulty to choose between two modelling approach. Here is th
>>> story. To examine the clutch size laid by a parasitic wasp into caterpillar
>>> hosts which varies in age and size, we exposed individual larvae of  three
>>> stages, after individually weighed, to parasitism, and the number of wasps
>>> emerged from each host (brood size) was recorded. Because host size and
>>> stage are mutually counfounding factors, the older the bigger, I have two
>>> modelling choices to separate the effect of stage and size. One is to make
>>> separate analyses, first analyzing the effct of stages in a model without
>>> the variable size, and then analyze the effect of the size under each stgae
>>> (several models); another approach is to make one analysis, put stage and
>>> size together in the same model to evaluate their separate and interacted
>>> effects on brood size.  For the later approach, the variable size actualy
>>> contains the inflormation about the stage, thus violating the independence
>>> assumation. I am won!
>>>   dering which appraoch is approriate.
>>>
>>>     Thanks for any help.
>>>
>>>    Baoping
>>>
>>>
>>>
>>>
>>> E-mail: lbp at njau.edu.cn
>>> Phone: 86 (25) 84396394
>>>
>>>          [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-ecology mailing list
>>> R-sig-ecology at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>>
>> 	[[alternative HTML version deleted]]
>>
>>
>>
>> ------------------------------
>>
>> Subject: Digest Footer
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
>> ------------------------------
>>
>> End of R-sig-ecology Digest, Vol 98, Issue 10
>> *********************************************
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



More information about the R-sig-ecology mailing list