Apologies, confidential dataset.
I'm looking for a string of code that would solve the problem described below. I have no idea where to start since deleting data won't work, and since the decrease in data 5 years later can still be above 0.5. Here ya go!
Assume there is a psychological study measuring a group of peoples emotional intelligence (EI) over time, rated on a scale from 0 to 1. From 0 to 1, there are 11 ratings (0, 0.1, 0.2, ... 0.9, 1). There are 200 people, with their EI reevaluated each year from 1960 to 2010. My objective is to find the person-years where the preceding 10 years had an EI consistently greater than 0.5 (all 10 years had EI>0.5), and 5 years later the EI had decreased by 0.2 or more.
Examples:
1.
1. EI of person A from 1960-1974 = 0.6, then 1975-1978 = 0.5, then 1979 = 0.4 would COUNT
2. Same 1960-1977 as above, but 1978 = 0.4, 1979 = 0.5 would COUNT
3. 1960-1969 = 0.6, 1970-1973 = 0.4, 1974 = 0.5 would NOT COUNT
#1 above would need to identify 1975, person A as the person-year.
#2 above would need to identify 1974 as the year, since the 5 year decrease occurred in 1978, but 1979 did not have the same result.
#3 above had no 10 year run greater than 0.5 where 5 years later there was a 0.2 decrease. The only year that could fit this qualification would be 1974 since there was exactly a 10 year run above 0.5 that ended exactly 5 years before.
2.
EI of person B from 1960-1969 = 0.8, 1970-1973 = 0.7, 1974 = 0.6
OR
1960-1969 = 0.8, 1970-1974 = 0.6
OR
1960-1969 = 0.8, 1970-1974 = 0.3
OR
1960-1969 = 0.8, 1970-1973 = 0.3, 1974 = 0.6
ALL WOULD COUNT. They should all return 1970, person B as the person-year.
Any advice on the code for this would be greatly appreciated!! Life of a research assistant.
I'm looking for a string of code that would solve the problem described below. I have no idea where to start since deleting data won't work, and since the decrease in data 5 years later can still be above 0.5. Here ya go!
Assume there is a psychological study measuring a group of peoples emotional intelligence (EI) over time, rated on a scale from 0 to 1. From 0 to 1, there are 11 ratings (0, 0.1, 0.2, ... 0.9, 1). There are 200 people, with their EI reevaluated each year from 1960 to 2010. My objective is to find the person-years where the preceding 10 years had an EI consistently greater than 0.5 (all 10 years had EI>0.5), and 5 years later the EI had decreased by 0.2 or more.
Examples:
1.
1. EI of person A from 1960-1974 = 0.6, then 1975-1978 = 0.5, then 1979 = 0.4 would COUNT
2. Same 1960-1977 as above, but 1978 = 0.4, 1979 = 0.5 would COUNT
3. 1960-1969 = 0.6, 1970-1973 = 0.4, 1974 = 0.5 would NOT COUNT
#1 above would need to identify 1975, person A as the person-year.
#2 above would need to identify 1974 as the year, since the 5 year decrease occurred in 1978, but 1979 did not have the same result.
#3 above had no 10 year run greater than 0.5 where 5 years later there was a 0.2 decrease. The only year that could fit this qualification would be 1974 since there was exactly a 10 year run above 0.5 that ended exactly 5 years before.
2.
EI of person B from 1960-1969 = 0.8, 1970-1973 = 0.7, 1974 = 0.6
OR
1960-1969 = 0.8, 1970-1974 = 0.6
OR
1960-1969 = 0.8, 1970-1974 = 0.3
OR
1960-1969 = 0.8, 1970-1973 = 0.3, 1974 = 0.6
ALL WOULD COUNT. They should all return 1970, person B as the person-year.
Any advice on the code for this would be greatly appreciated!! Life of a research assistant.
Comment