Answers.Body: <p>R supports logistic regression, which would seem to be the most efficient method for tackling this question. Assuming the "Chemo" variable is the type of chemo the  code would be something like:</p>
  
  <pre><code>glm( (response_to_chemo == "yes") ~  BMI + Chemo  + Predictor +  DJANGO + gender, 
          family="binomial")
  </code></pre>
  
  <p>EDIT: Corrected a typo (added a missing double quote)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-04T05:46:36.093Z
Answers.LastActivityDate: 2020-02-10T17:58:50.190Z
Answers.LastEditDate: 2020-02-10T17:58:50.190Z
Answers.UserDisplayName: 42-
Answers.Body: <p>The general approach would be to loop through every column starting at column 2. You can use numeric indexes to do that.</p>
  <p>For each column, check its type. If it is a factor, use your <code>chisq.test</code> method. If it is of numeric type, use your <code>t.test</code> approach. Write the results to a list so you can parse them later.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-31T19:35:12.220Z
Answers.LastActivityDate: 2023-04-12T20:40:51.597Z
Answers.LastEditDate: 2023-04-12T20:40:51.597Z
Answers.UserDisplayName: Ram RS
Answers.Body: <p>You have category-based variables as well as variables based on continuous data. The best-option could be linear Mixed- effects model for your research purpose. Chi-square test and t-test may be used to cross-validate or re-examine the outcome of LME  model.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T18:30:57.777Z
Answers.Text: Hi @subhash what mixed model would you consider?
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-10T15:48:27.867Z
Answers.Text: When using such a model, how do you decide which effects to be "fixed" and which to be "random"?
Answers.UserDisplayName: haci
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-12T02:58:36.877Z
Answers.Text: These are assumptions that pervade hierarchical modelling.Saying "which effects" here seems to reflect the variables! Please clarify.
Answers.UserDisplayName: Subhash C. Davar
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T17:15:12.610Z
Answers.LastActivityDate: 2020-03-09T17:15:12.610Z
Answers.UserDisplayName: Subhash C. Davar
Body: <p>I have a big clinical data file with 96 columns like age, gender, BMI, etc</p>
  
  <p>I want to see which of these clinical characteristics respond to chemotherapy. Response to chemotherapy divides patients to two groups as <code>yes</code> and <code>no</code>. Among these clinical characteristics, some are based on continuous data and some reflect `categorical data.  Is it possible to write a function to loop over these characteristics and test for relationship between response to chemotherapy? Something like Wilcox test for continuous values and chi square for categorical characteristics. By hand, it takes too much to do for all one by one !</p>
  
  <p>This is my data</p>
  
  <pre><code>ID  response_to_chemo   BMI Chemo   Predictor   DJANGO  gender
  AH/155  no  50  1   1   0   M
  RS/022  no  67  1   1   0   M
  RS/027  no  80  1   1   1   F
  ST/023  no  65  1   1   0   M
  SH/051  yes 47  1   1   0   M
  AH/075  yes 90  0   1   0   M
  RS/047  no  67  0   1   0   F
  ST/029  no  61  1   1   0   F
  </code></pre>
  
  <p>For instance </p>
  
  <pre><code>myTable &lt;- table(clin<span class="math-container">$gender, clin$</span>response_to_chemo)
  
  chisq.test(myTable)
  </code></pre>
  
  <p>Gives p-value for testing the relationship of gender (CATEGORICAL) in response to chemotherapy</p>
  
  <p>And</p>
  
  <pre><code>t.test(clin<span class="math-container">$BMI ~ clin$</span>response_to_chemo)
  </code></pre>
  
  <p>is for BMI</p>
  
  <p>I meant a function calculating these p-values for clinical characteristics one by one </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-31T15:53:58.877Z
Comments.Text: Did you triy anything yet ?
Comments.UserDisplayName: Paul Endymion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-31T15:56:40.703Z
Comments.Text: Actually in my mind I think about some for i in colnames of my data but can not go further as I am unable to tailor a function :(
Comments.UserDisplayName: Zizogolu
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-31T16:05:38.647Z
Comments.Text: Try to include some code that you would run on the data example you provided. Taking the time to make a good reproducible example often gives you the answer to the original question.
Comments.UserDisplayName: Paul Endymion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-03-10T15:35:12.720Z
Comments.Text: Don't forget to correct for multiple hypothesis testing at the end, too. With 20 completely random variables, you'd expect 1 of them to show a spurious association at p<0.05.
Comments.UserDisplayName: Nuclear Hoagie
Tags: <database><r><software-recommendation><correlation>
Title: Is it possible to do this in R?
ThreadText: # Is it possible to do this in R?
  
  (Asked by: username_0 on 2020-01-31)
  
  I have a big clinical data file with 96 columns like age, gender, BMI, etc
  
  I want to see which of these clinical characteristics respond to chemotherapy. Response to chemotherapy divides patients to two groups as `yes` and `no`. Among these clinical characteristics, some are based on continuous data and some reflect `categorical data. Is it possible to write a function to loop over these characteristics and test for relationship between response to chemotherapy? Something like Wilcox test for continuous values and chi square for categorical characteristics. By hand, it takes too much to do for all one by one !
  
  This is my data
  
  ```
  ID  response_to_chemo   BMI Chemo   Predictor   DJANGO  gender
  AH/155  no  50  1   1   0   M
  RS/022  no  67  1   1   0   M
  RS/027  no  80  1   1   1   F
  ST/023  no  65  1   1   0   M
  SH/051  yes 47  1   1   0   M
  AH/075  yes 90  0   1   0   M
  RS/047  no  67  0   1   0   F
  ST/029  no  61  1   1   0   F
  
  ```
  
  For instance
  
  ```
  myTable <- table(clin$gender, clin$response_to_chemo)
  
  chisq.test(myTable)
  
  ```
  
  Gives p-value for testing the relationship of gender (CATEGORICAL) in response to chemotherapy
  
  And
  
  ```
  t.test(clin$BMI ~ clin$response_to_chemo)
  
  ```
  
  is for BMI
  
  I meant a function calculating these p-values for clinical characteristics one by one
  
  **Tags:** database, r, software-recommendation, correlation
  
  > **Comments:**
  > **username_1**: Did you triy anything yet ?  
  > **username_0**: Actually in my mind I think about some for i in colnames of my data but can not go further as I am unable to tailor a function :(  
  > **username_1**: Try to include some code that you would run on the data example you provided. Taking the time to make a good reproducible example often gives you the answer to the original question.  
  > **username_2**: Don't forget to correct for multiple hypothesis testing at the end, too. With 20 completely random variables, you'd expect 1 of them to show a spurious association at p<0.05.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2020-02-04. Score: 6
  
  R supports logistic regression, which would seem to be the most efficient method for tackling this question. Assuming the "Chemo" variable is the type of chemo the code would be something like:
  
  ```
  glm( (response_to_chemo == "yes") ~  BMI + Chemo  + Predictor +  DJANGO + gender, 
          family="binomial")
  
  ```
  
  EDIT: Corrected a typo (added a missing double quote)
  
  
  ---
  
  ### Answer by username_4 on 2020-01-31. Score: 3
  
  The general approach would be to loop through every column starting at column 2. You can use numeric indexes to do that.
  
  For each column, check its type. If it is a factor, use your `chisq.test` method. If it is of numeric type, use your `t.test` approach. Write the results to a list so you can parse them later.
  
  
  ---
  
  ### Answer by username_5 on 2020-03-09. Score: 2
  
  You have category-based variables as well as variables based on continuous data. The best-option could be linear Mixed- effects model for your research purpose. Chi-square test and t-test may be used to cross-validate or re-examine the outcome of LME model.
  
  > **Comments:**
  > **username_6**: Hi @username_5 what mixed model would you consider?  
  > **username_7**: When using such a model, how do you decide which effects to be "fixed" and which to be "random"?  
  > **username_5**: These are assumptions that pervade hierarchical modelling.Saying "which effects" here seems to reflect the variables! Please clarify.  
  
  ---
  
  