'Multiple conditions to determine status
I am working with diagnostic criteria, therefore several conditions must be met, it is essential for my purpose to get prevalence. What I am trying to detect is:
- Number of individuals at the BEGINNING of the study meeting certain conditions (3/5)
- Number of individuals at the END of the study meeting certain conditions (3/5)
- How many individuals have improved their status
- How many individuals have worsened their status
My database
data <-
structure(list(paciente = structure(c(6186, 6287, 6002, 6007,
6345, 6539, 6112, 6526, 6227, 6271, 6215, 6350, 6065, 6096, 6062,
6119, 6290, 6293, 6372, 6036, 6434, 6463, 6506, 6004, 6147, 6026,
6188, 6252, 6081, 6223, 6191, 6553, 6492, 6410, 6447, 6009, 6221,
6260, 6452, 6066, 6368, 6181, 6051, 6208, 6502, 6158, 6059, 6379,
6233, 6099), label = "Paciente", format.spss = "F6.0"), sexo_s1 = structure(c(2L,
2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L,
2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L,
1L), .Label = c("Hombre", "Mujer"), label = "Sexo", class = "factor"),
edad_s1 = structure(c(66, 63, 70, 62, 64, 72, 66, 66, 69,
60, 70, 63, 60, 68, 66, 65, 66, 73, 63, 61, 66, 55, 69, 73,
65, 73, 58, 62, 72, 71, 67, 67, 61, 75, 67, 72, 70, 58, 62,
61, 71, 71, 63, 74, 60, 69, 72, 75, 67, 63), label = "Edad", format.spss = "F3.0"),
grupo_int_v00 = structure(c(1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L,
2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L,
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L), .Label = c("A",
"B"), label = "Grupo de intervención", class = "factor"),
glucosa_v00 = structure(c(87, 101, 95, 136, 104, 108, 97,
107, 89, 85, 104, 99, 100, 127, 118, 109, 109, 108, 110,
100, 112, 103, 98, 100, 99, 182, 93, 148, 116, 128, 116,
133, 101, 112, 182, 165, 94, 142, 108, 112, 156, 181, 120,
126, 150, 93, 102, 161, 124, 152), label = "Analítica: Glucosa en mg/dL", format.spss = "F4.0"),
hdl_v00 = structure(c(72, 43, 90, 45, 50, 44, 81, 56, 68,
38, 47, 42, 69, 65, 52, 60, 50, 40, 47, 71, 52, 53, 69, 56,
55, 45, 51, 47, 68, 62, 71, 55, 64, 48, 35, 72, 45, 36, 52,
44, 72, 54, 59, 63, 57, 53, 59, 57, 50, 43), label = "Analítica: Colesterol HDL en mg/dL", format.spss = "F4.0"),
trigli_v00 = structure(c(284, 282, 126, 58, 153, 105, 138,
243, 102, 204, 189, 70, 160, 124, 191, 164, 205, 149, 152,
90, 151, 109, 135, 80, 136, 95, 217, 117, 116, 207, 217,
123, 100, 110, 648, 106, 204, 197, 95, 166, 88, 429, 101,
90, 87, 155, 143, 107, 98, 93), label = "Analítica: Triglicéridos en mg/dL", format.spss = "F5.0"),
tasis2_e_v00 = structure(c(146, 147, 130, 151, 145, 144,
138, 145, 138, 139, 146, 144, 117, 145, 126, 115, 148, 167,
131, 125, 123, 140, 146, 120, 123, 152, 146, 130, 100, 147,
139, 131, 145, 137, 151, 176, 138, 138, 122, 146, 139, 156,
137, 146, 149, 122, 145, 123, 161, 123), label = "TA: tensión arterial 2: sistólica", format.spss = "F4.0"),
tadias2_e_v00 = structure(c(60, 82, 64, 88, 84, 78, 82, 84,
72, 85, 65, 76, 61, 71, 67, 72, 58, 85, 87, 81, 68, 82, 60,
53, 57, 71, 80, 64, 50, 82, 74, 84, 85, 71, 71, 110, 78,
77, 68, 88, 78, 89, 69, 84, 65, 68, 75, 54, 71, 65), label = "TA: tensión arterial 2: diastólica", format.spss = "F4.0"),
cintura1_v00 = structure(c(101.5, 97, 105.5, 126, 106.5,
108.5, 115, 94, 106, 126.5, 119, 106, 116.2, 94, 130.7, 101.5,
116.5, 112, 100, 111.6, 116.5, 115, 110.2, 109, 126, 94,
116.5, 112, 98, 126.5, 120, 119.5, 118.5, 112, 124, 102.5,
106, 135, 113.5, 113, 97.5, 123, 136.2, 103.5, 108, 109,
103, 103, 102.5, 123.2), label = "Cintura: 1a determinación", format.spss = "F5.1")), row.names = c(NA,
-50L), class = "data.frame")
ID variable: paciente Sex: sexo_s1 Age: edad_s1 Treatment group: grupo_int_v00 (doesn't change)
Notation: suffixes
- _v00: baseline measurement
- _v01: endpoint measurement
The conditions to be positive are meeting at least 3 conditions (whichever they are) of the following:
- glucosa_v00 > 100
- trigli_v00 > 150
- cintura1_v00 > 94 ( (if sexo_s1 = 0) or cintura1_v00 > 80 (if sexo_s1 = 1)
- tasis2_e_v00 ≥ 140 or tadias2_e_v00 ≥ 85
- hdl_v00 ≤ 50 (if sexo_s1 = 0) or hdl_v00 ≤ 40 (if sexo_s1 = 1)
I want to count (if possible per group: grupo_int_v00 = A/B) how many individuals meet at least 3 out of 5 at baseline (_v01) and at the end (_v01):
- glucosa_v01 > 100
- trigli_v01 > 150
- cintura1_v01
- tasis2_e_v01 ≥ 140 or tadias2_e_v01 ≥ 85
- hdl_v01 ≤ 50 (if sexo_s1 = 0) or hdl_v01 ≤ 40 (if sexo_s1 = 1)
Objective
- My problem with conditional of this type is I don't know how to write correct syntax to express that 3 conditions, whichever the conditions are, is required to meet positive status, and how to make the conditions fit with sex values (sexo_s1)
- How to get the individuals that have worsened or improved their conditions e.g. patient 6357 has improved 2 variables, so he doesn't meet 3 conditions out of established 5. So, how many patients are like patient 6357. On the other how many patients before did not meet criteria, and now do
As I said I have tried several syntaxes, really basic conditionals but without further success Thanks in advance
Appreciate it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
