Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to establish case/control status based on first and last observations in R

$
0
0

I have a longitudinal dataset in R with mood scores over a period which starts on Day 1 for all IDs. The end day ranges for every ID (between 26 and 35 days). Based on the mood scores, I would like to assign every participant (ID) as a case if the average mood score on Days -3 to -1 is 30% higher than the average mood score on Days +3 to +5. If not, then the person is a control.

The data looks like this:

ID.    Day.    Mood_Score   
1.     1       5
1.     2.      3 
1.     3.      3
1.     4.      4 
1.     5.      5
...
1.     26      14      
1.     27.     10
1.     28.     18
2.     1       3
2.     2.      3
2.     3.      5
2.     4.      4
2.     5.      3 
...
2.     29.     9       
2.     30.     8
2.     31.     7

Based on the above, ID#1 should be a case, and ID#2 should be a control.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>