LASSO regression for categorical variables [migrated] - r

This question was migrated from Stack Overflow because it can be answered on Cross Validated.
Migrated 24 days ago.
Suppose there are several categorical variables included in the LASSO regression.
For a categorical variable with more than two factors, it is mandatory to create a dummy table.
For example, the categorical variable is vaccination status (Vacc_Stat), in which there are three categories,i.e., 1 = not vaccinated, 2 = partially vaccinated, and 3 = fully vaccinated.
Using the model. matrix function for the vaccination status variable will yield two dummy columns because the value 1= not vaccinated is the reference.
If the final result of the LASSO regression coefficient is as follows
Vacc_Stat1 .
Vacc_Stat2 .
Vacc_Stat3 -4.208877e-01
Do we use the Vacc_Stat3 only, or we used the Vacc_Stat variable as a whole?
I am planning to do a LASSO regression followed by a logistic regression of the remaining variables selected through LASSO regression.
Thank you in advance.
I am expecting that if one of the dummy variables is included in the LASSO regression, then we used the original categorical variable as a whole.
The following is the minimal reproducible dataset
structure(c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1,
1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0,
1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1,
1, 1, 1, 1, 1, 0, 1, 0, 0.34, 0.49, 38, 0.58, 0.2, 0.49, 0.65,
40.57, 2.08, 49.52, 50.77, 38.04, 76.55, 55.95, 53.23, 38.04,
99.72, 80.04, 92.41, 47, 66, 70, 52, 36, 39, 67, 42, 23, 66,
37.109375, 31.22945431, 26.2345679, 20.76124567, 35.3798127,
26.44628099, 23.87511478, 24.8015873, 21.49959688, 22.47120876,
110, 159, 127, 100, 120, 115, 100, 112, 130, 119, 72, 78, 80,
72, 80, 73, 76, 75, 80, 78, 84, 86, 88, 103, 90, 91, 90, 82,
88, 105, 36, 37, 36.5, 36, 38, 38, 36, 36.4, 37, 36, 20, 40,
24, 20, 22, 24, 18, 20, 22, 20, 90, 99, 98, 99, 96, 90, 98, 99,
99, 90, 7, 5, 0, 2, 7, 10, 3, 3, 2, 2, 11.7, 13.8, 13, 10.9,
11.6, 14.5, 15, 16.2, 12.3, 14.2, 3.9, 4.2, 3.6, 4.7, 4, 3.2,
4.4, 5.1, 3, 3.78, 15.7, 28.8, 6, 7.8, 37.6, 13.9, 26.6, 27.2,
33, 23, 138, 139, 121, 135, 139, 132, 133, 138, 137, 128, 75,
64.5, 87.4, 88.9, 47.1, 78, 61.8, 62.52, 56.3, 63.2, 753, 305,
250, 267, 315, 207, 285, 293, 366, 307, 8.7, 8.1, 11.2, 75.9,
13.7, 10.03, 42.2, 10, 9, 10.6, 11.07, 6.8, 1.18, 23.18, 4.33,
5.25, 8.73, 7.44, 8.01, 10.37), dim = c(10L, 76L), dimnames =
list(
c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"),
c("TEST.Year2",
"TEST.Year3", "TEST.Gender2", "TEST.Vacc_Stat1",
"TEST.Vacc_Stat2",
"TEST.Vacc_Stat3", "TEST.Risk_AI2", "TEST.Risk_Obesity2",
"TEST.Risk_Smoking2",
"TEST.Risk_HT2", "TEST.Risk_DM2", "TEST.Risk_Asthma2",
"TEST.Risk_CHD2",
"TEST.Risk_CVD2", "TEST.Risk_COPD2", "TEST.Risk_TBC2",
"TEST.Risk_CKD2",
"TEST.Risk_CLD2", "TEST.Risk_Brain2", "TEST.Risk_HIV2",
"TEST.Risk_Cancer2",
"TEST.Symptom_Fever2", "TEST.Symptom_Cough2",
"TEST.Symptom_Sore_Throat2",
"TEST.Symptom_Rinnorrhea2", "TEST.Symptom_Anosmia2",
"TEST.Symptom_Myalgia2",
"TEST.Symptom_Headache2", "TEST.Symptom_Malaise2",
"TEST.Symptom_Anorexia2",
"TEST.Symptom_Diarrhea2", "TEST.Symptom_Nausea2",
"TEST.Symptom_Vomitting2",
"TEST.Symptom_Abd_Pain2", "TEST.Symptom_Dyspneu2",
"TEST.Symptom_Chest_Pain2",
"TEST.Symptom_LOC2", "TEST.Lab_RT_PCR2", "TEST.CXR_Proj2",
"TEST.CXR_Proj3",
"TEST.CXR_Pneumonia1", "TEST.CXR_Pneumonia2",
"TEST.CXR_Effusion2",
"TEST.Co_Septic2", "TEST.Co_Septic_Shock2", "TEST.Co_ARDS2",
"TEST.Co_Sx_Infection2", "TEST.Severity_Adm2",
"TEST.Severity_Adm3",
"TEST.Severity_Adm4", "TEST.Severity_Adm_Cat_12",
"TEST.Severity_Adm_Cat_22",
"TEST.Severity_Adm_Cat_32", "TEST.Severity_Worst2",
"TEST.Severity_Worst3",
"TEST.Severity_Worst4", "TEST.Progression2", "TEST.CXR_ALA_Num",
"TEST.CXR_Prob_Num", "TEST.Age", "TEST.BMI", "TEST.Vital_SBP",
"TEST.Vital_DBP", "TEST.Vital_PR", "TEST.Vital_Temp",
"TEST.Vital_RR",
"TEST.Vital_SpO2", "TEST.Symptom_Onset", "TEST.Lab_Hb",
"TEST.Lab_K",
"TEST.Lab_Lim", "TEST.Lab_Na", "TEST.Lab_Neu", "TEST.Lab_Tr",
"TEST.Lab_Ur", "TEST.Lab_WBC")))

Related

Missing value where TRUE/FALSE needed error in smcure model

I'm creating a cure model in R to predict Loan Default. I'm seeking someone to help me debug this error. I think it may have to do with my columns.
library(smcure)
smcure(Surv(DURATION, DEFAULT) ~ CHK_ACCT+HISTORY+NEW_CAR+USED_CAR+FURNITURE+`RADIO/TV`+EDUCATION+
RETRAINING+AMOUNT+SAV_ACCT+EMPLOYMENT+INSTALL_RATE+MALE_DIV+MALE_SINGLE+MALE_MAR_or_WID+
`CO-APPLICANT`+GUARANTOR+PRESENT_RESIDENT+REAL_ESTATE+PROP_UNKN_NONE+AGE+OTHER_INSTALL+RENT+
OWN_RES+NUM_CREDITS+JOB+NUM_DEPENDENTS+TELEPHONE+FOREIGN,
cureform=~CHK_ACCT+HISTORY+NEW_CAR+USED_CAR+FURNITURE+`RADIO/TV`+EDUCATION+RETRAINING+AMOUNT+SAV_ACCT+
EMPLOYMENT+INSTALL_RATE+MALE_DIV+MALE_SINGLE+MALE_MAR_or_WID+`CO-APPLICANT`+GUARANTOR+PRESENT_RESIDENT+
REAL_ESTATE+PROP_UNKN_NONE+AGE+OTHER_INSTALL+RENT+OWN_RES+NUM_CREDITS+JOB+NUM_DEPENDENTS+
TELEPHONE+FOREIGN,
model="ph", data = CD)
Error in while (convergence > eps & i < emmax) { :
missing value where TRUE/FALSE needed
Does anyone know what this error may mean?
Attached I have a subset of the data I used.
Data
structure(list(CHK_ACCT = c(0, 1, 3, 0, 0, 3, 3, 1, 3, 1, 1,
0, 1, 0, 0, 0, 3, 0, 1, 3, 3, 0, 0, 1, 3, 0, 3, 2, 1, 0, 1, 0,
1, 3, 2, 1, 3, 2, 2, 1, 3, 1, 1, 0, 0, 3, 3, 0, 3, 3, 1, 1, 3,
3, 1, 3, 1, 3, 2, 0, 1, 1, 1, 1, 3, 3, 3, 1, 3, 3, 3, 3, 0, 1,
0, 0, 0, 1, 3, 1, 3, 3, 3, 0, 0, 3, 1, 1, 0, 0, 3, 0, 3, 2, 1,
1, 3, 1, 1, 1, 3, 1, 3, 1, 3, 1, 3, 1, 0, 1, 1, 2, 1, 3, 0, 3,
0, 0, 0, 1, 0, 3, 3, 2, 1, 0, 0, 1, 1, 0, 1, 0, 3, 3, 3, 3, 3,
1, 1, 2, 2, 1, 0, 0, 3, 1, 0, 3, 0, 3, 3, 3, 2, 1, 1, 0, 0, 0,
1, 3, 3, 3, 3, 1, 3, 3, 0, 1, 3, 1, 0, 3, 1, 1, 0, 3, 0, 0, 3,
0, 3, 1, 0, 3, 1, 3, 1, 1, 0, 1, 3, 1, 1, 3, 1, 1, 3, 1, 1, 1
), DURATION = c(6, 48, 12, 42, 24, 36, 24, 36, 12, 30, 12, 48,
12, 24, 15, 24, 24, 30, 24, 24, 9, 6, 10, 12, 10, 6, 6, 12, 7,
60, 18, 24, 18, 12, 12, 45, 48, 18, 10, 9, 30, 12, 18, 30, 48,
11, 36, 6, 11, 12, 24, 27, 12, 18, 36, 6, 12, 36, 18, 36, 9,
15, 36, 48, 24, 27, 12, 12, 36, 36, 36, 7, 8, 42, 36, 12, 42,
11, 54, 30, 24, 15, 18, 24, 10, 12, 18, 36, 18, 12, 12, 12, 12,
24, 12, 54, 12, 18, 36, 20, 24, 36, 6, 9, 12, 24, 18, 12, 24,
14, 6, 15, 18, 36, 12, 48, 42, 10, 33, 12, 21, 24, 12, 10, 18,
12, 12, 12, 12, 12, 48, 36, 15, 18, 60, 12, 27, 12, 15, 12, 6,
36, 27, 18, 21, 48, 6, 12, 36, 18, 6, 10, 36, 24, 24, 12, 9,
12, 24, 6, 24, 18, 15, 10, 36, 6, 18, 11, 24, 24, 15, 12, 24,
8, 21, 30, 12, 6, 12, 21, 36, 36, 21, 24, 18, 15, 9, 16, 12,
18, 24, 48, 27, 6, 45, 9, 6, 12, 24, 18), HISTORY = c(4, 2, 4,
2, 3, 2, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 4, 0, 2, 2, 4, 2, 4, 4,
4, 2, 0, 1, 2, 3, 2, 2, 2, 4, 2, 4, 4, 2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, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0), AMOUNT = c(1169,
5951, 2096, 7882, 4870, 9055, 2835, 6948, 3059, 5234, 1295, 4308,
1567, 1199, 1403, 1282, 2424, 8072, 12579, 3430, 2134, 2647,
2241, 1804, 2069, 1374, 426, 409, 2415, 6836, 1913, 4020, 5866,
1264, 1474, 4746, 6110, 2100, 1225, 458, 2333, 1158, 6204, 6187,
6143, 1393, 2299, 1352, 7228, 2073, 2333, 5965, 1262, 3378, 2225,
783, 6468, 9566, 1961, 6229, 1391, 1537, 1953, 14421, 3181, 5190,
2171, 1007, 1819, 2394, 8133, 730, 1164, 5954, 1977, 1526, 3965,
4771, 9436, 3832, 5943, 1213, 1568, 1755, 2315, 1412, 1295, 12612,
2249, 1108, 618, 1409, 797, 3617, 1318, 15945, 2012, 2622, 2337,
7057, 1469, 2323, 932, 1919, 2445, 11938, 6458, 6078, 7721, 1410,
1449, 392, 6260, 7855, 1680, 3578, 7174, 2132, 4281, 2366, 1835,
3868, 1768, 781, 1924, 2121, 701, 639, 1860, 3499, 8487, 6887,
2708, 1984, 10144, 1240, 8613, 766, 2728, 1881, 709, 4795, 3416,
2462, 2288, 3566, 860, 682, 5371, 1582, 1346, 1924, 5848, 7758,
6967, 1282, 1288, 339, 3512, 1898, 2872, 1055, 1262, 7308, 909,
2978, 1131, 1577, 3972, 1935, 950, 763, 2064, 1414, 3414, 7485,
2577, 338, 1963, 571, 9572, 4455, 1647, 3777, 884, 1360, 5129,
1175, 674, 3244, 4591, 3844, 3915, 2108, 3031, 1501, 1382, 951,
2760, 4297), SAV_ACCT = c(4, 0, 0, 0, 0, 4, 2, 0, 3, 0, 0, 0,
0, 0, 0, 1, 4, 4, 0, 2, 0, 2, 0, 1, 4, 0, 0, 3, 0, 0, 3, 0, 1,
4, 0, 0, 0, 0, 0, 0, 2, 2, 0, 1, 0, 0, 2, 2, 0, 1, 4, 0, 0, 4,
0, 4, 4, 0, 0, 0, 0, 4, 0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 0, 1, 0, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 1, 1), AGE = c(67, 22, 49, 45, 53, 35,
53, 35, 61, 28, 25, 24, 22, 60, 28, 32, 53, 25, 44, 31, 48,
44, 48, 44, 26, 36, 39, 42, 34, 63, 36, 27, 30, 57, 33, 25,
31, 37, 37, 24, 30, 26, 44, 24, 58, 35, 39, 23, 39, 28, 29,
30, 25, 31, 57, 26, 52, 31, 23, 23, 27, 50, 61, 25, 26, 48,
29, 22, 37, 25, 30, 46, 51, 41, 40, 66, 34, 51, 39, 22, 44,
47, 24, 58, 52, 29, 27, 47, 30, 28, 56, 54, 33, 20, 54, 58,
61, 34, 36, 36, 41, 24, 24, 35, 26, 39, 39, 32, 30, 35, 31,
23, 28, 25, 35, 47, 30, 27, 23, 36, 25, 41, 24, 63, 27, 30,
40, 30, 34, 29, 24, 29, 27, 47, 21, 38, 27, 66, 35, 44, 27,
30, 27, 22, 23, 30, 39, 51, 28, 46, 42, 38, 24, 29, 36, 20,
48, 45, 38, 34, 36, 30, 36, 70, 36, 32, 33, 20, 25, 31, 33,
26, 34, 33, 26, 53, 42, 52, 31, 65, 28, 30, 40, 50, 36, 31,
74, 68, 20, 33, 54, 34, 36, 29, 21, 34, 28, 27, 36, 40),
OTHER_INSTALL = c(0, 0, 0, 0, 0, 0, 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, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0,
1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0,
1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1)), row.names = c(NA,
-200L), class = c("tbl_df", "tbl", "data.frame"))

R Margins: Incorrect number of dimensions

I want to calculate the margins for an independent variable at the values of another independent variable. All variables (including the dependent variable) are binary.
model1 <- glm(data = TrialDF, formula = dep ~ indep1*indep2, family=binomial)
margins::margins(model1, data = TrialDF, variables = "indep1",
at = list("indep2" =c(0,1)))
However, I get the following error:
Error in dat[, not_numeric, drop = FALSE] :
incorrect number of dimensions
I also tried variations of this command by using factor variables or list("indep2" = 0:1), but I always get the same error messages. What does that mean?
The data is:
TrialDF <-structure(list(dep = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1,
0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1,
0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1,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0, 1, 1, 1, 1, 1), indep2 = c(1, 0, 1, 1, 1, 0, 1, 0, 0,
0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1,
0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1,
0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1,
1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1,
0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1
)), row.names = c(NA, -240L), class = c("data.table", "data.frame"
))
This error is related to the problem described in https://github.com/leeper/prediction/pull/34. You can get past it by coercing the data to a data frame with data=data.frame(TrialDF):
> margins(model1, data=data.frame(TrialDF), variables="indep1", at=list("indep2"=c(0,1)))
Average marginal effects at specified values
glm(formula = dep ~ indep1 * indep2, family = binomial, data = TrialDF)
at(indep2) indep1
0 0.6776
1 0.1496

How to get the calibration plot of a multivariable logistic regression model (glm)?

I have the following model and calculated the predicted probabilities:
( all variables are binary (0, 1) except AED_pre which is numeric (0:4)
modelfit <-glm(engelone ~ generalized + SEEG+ Aura + AED_pre + MS, data=data)
summary(modelfit)
prob <-predict(modelfit, type = c("response"))
I used SPSS to obtain the ROC curve, but I still need the calibration plots (+bootstrapping). I tried with:
val <- val.prob(data$prob, data$engelone, pl = TRUE)
but i get this error:
Error in qlogis(p) : Non-numeric argument to mathematical function
What should i do? Thanks!
Here's my data :
structure(list(generalized = c(0, 1, 1, 0, 0, 1, 0, 0, 1, 1,
0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1,
0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1,
1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1,
0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,
0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0,
0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1,
0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0,
0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1,
1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,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
0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1,
1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1,
0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0,
0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0,
1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0,
1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1)), .Names = c("generalized",
"Aura", "AED_pre", "SEEG", "MS", "engelone"), row.names = c(NA,
-316L), class = c("tbl_df", "tbl", "data.frame"))
Maybe you have to see what variable class you have in your database, you can see it with class() and be sure you have numeric or factor variables. could try with this.

venn diagram with categorical data

I have three categorical vectors that represent symptoms. And I would like plot a venn diagram that show how many people have one two or three of them.
I tryed do
library(gplots)
venn(list(sym1, sym2, sym3))
but didn't work
Thank you
sym1=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0, 0, 1,
1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,
1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 0, 1, 0)
Here is an example on how to achieve this with the library eulerr which provides much better looking (at least in my opinion) diagrams:
library(eulerr)
library(tidyverse)
set.seed(123) #for reproducible plot
data.frame(sym1, sym2, sym3)%>% #combine the vectors to a data frame
mutate_at(1:3, as.logical) %>% #convert to logical
euler(shape = "ellipse", input = "disjoint") %>% #calculate euler object, plot as ellipse
plot(quantities = T) plot it
with venn from gplots:
library(gplots)
data.frame(sym1, sym2, sym3)%>%
mutate_at(1:3, as.logical) %>%
venn()
From the help of venn:
Either a list list containing vectors of names or indices of group
intersections, or a data frame containing boolean indicators of group
intersectionship (see below)
In your case I trust the second options is desired.

weight data with R Part II

Given is the following data frame:
structure(list(UH6401 = c(1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0,
1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0,
1, 0, 1, 1), UH6402 = c(1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1,
0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), UH6405a = c(1,
0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0,
0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1,
1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
1, 0, 1, 1), UH6407a = c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1,
1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1), weight = c(405.002592353822,
479.360356183825, 526.548105855472, 810.005184707644, 312.321528531308,
930.961115757095, 567.383058387095, 475.323944260643, 1226.91439266118,
517.086839792615, 1200.2669656949, 810.005184707644, 656.723784884795,
605.370463928298, 668.467435759576, 558.112457492436, 793.751055244424,
479.360356183825, 1226.91439266118, 1606.54816212786, 1657.48609449633,
300.803580980276, 605.370463928298, 1140.55078447979, 669.102760422943,
810.005184707644, 1657.48609449633, 305.569853371963, 2994.30343152033,
762.922030382216, 479.360356183825, 1147.36030437824, 668.467435759576,
517.086839792615, 479.360356183825, 399.141865860217, 656.723784884795,
913.364738988386, 312.321528531308, 569.10576379231, 775.630259688922,
1207.22952429547, 1053.09621171094, 1140.55078447979, 314.857225320909,
668.467435759576, 2416.57081451012, 573.680152189121, 396.875527622212,
605.370463928298, 1036.3159447043, 3088.62283807823, 569.10576379231,
1140.55078447979, 2416.57081451012, 1147.36030437824, 762.922030382216,
702.064141140629, 351.032070570315, 629.714450641817, 517.086839792615,
1996.20228768022, 828.743047248167, 475.323944260643, 920.185794495882,
793.751055244424, 796.08788273764, 1197.42559758065, 405.002592353822,
418.584343119327, 300.803580980276, 654.76828203733, 2740.09421696516,
351.032070570315, 1069.6202614693, 2094.91447516374, 399.141865860217,
654.76828203733, 1003.65414063441, 573.680152189121, 851.074587580641,
913.364738988386, 762.922030382216, 1034.17367958523, 573.680152189121,
479.360356183825, 3208.8607844079, 654.76828203733, 908.055695892447,
328.361892442398, 1036.3159447043, 702.064141140629, 613.457196330588,
601.607161960551, 567.383058387095, 479.360356183825, 306.261087672466,
920.185794495882, 654.76828203733, 828.743047248167)), .Names = c("UH6401",
"UH6402", "UH6403", "UH6404", "UH6409", "UH6410", "UH6411", "UH6412",
"UH6503", "UH66", "UH68", "UH6501a", "UH6405a", "UH6407a", "weight"
), row.names = c(NA, 100L), class = "data.frame")
In social science we often have a weight variable to weight a case (row) by the factor of that variable to correct the sample to fit e.g. the population by age classes. If the weight variable of a row is "1.6" it means that this row need do be observed 1.6 times to fit the basis population.
In SPSS I would write
WEIGHT BY weight.
and all procedures after that command will weight the data accordingly.
In R I can do that with stabs with the command
xtabs(weight ~ UH6401, data=df)
But what if I want to do a SVD or PCA analysis? Here there is no function to weight data like it is in xtabs.
So the question is, is there a method to weight data in R like it is possible in SPSS?
The point with whole numbers would be easy, with the factor "2" we would just double the line, but what is with all the factors that are decimal?
UPDATE:
The SVD or PCA was just an example! Take any other statistical procedure.
In social science the samples are never perfect, but to do an statistical analysis with sample data, the sample needs to represent the basic population, but a sample mostly doesn't. So we try to fix that deficit with weights, so the sample represent the basic population!
First of all, doing PCA on this data doesn't make sense. Second, SPSS does not perform PCA but factor analysis, which is something else. I know they call it PCA, but it isn't.
The WEIGHT BY in SPSS is nothing more than a replication weight, and is exactly the same as doing your analysis by repeating your cases using rep(): complete madness. To link to your example: In SPSS, FACTOR (which is used for the socalled PCA) does not take fractional weights.
If you want to perform weighted procedures, the only sensible way of doing that is using the correct method/function/package for that. In statistics, there is no one-size-fits-all weight procedure, contrary to what SPSS likes to make you believe.
In your example : weighted PCA in R is contained in FactoMineR and aroma.light. But I strongly suggest you take also a look at the vegan package, as that contains a lot more useful ordination methods for the data you're describing.
You probably need to get acquainted with the search engines for R. Baron's RSiteSearch and Rseek:
This is one of the first hits on "weighted PCA" at Baron's site:
http://finzi.psych.upenn.edu/R/library/aroma.light/html/wpca.matrix.html
With the clarification in the comment to Joris Meys response, the answer is often that one needs to be clear that one is desires sample weights versus other types of weighting. Regression weighting is done with the survey package. Lumley's book on survey methods distinguishes among three types of weights. (The "weights" in the lm function are variance weights, NOT sample weights.)
Note: Both PCA and factor analysis (experimental) are included in the survey package. So maybe Dominick's question requestiong a unified approach to weighting in regression methods has a single "answer".
I am not sure if this would suite you. See the R package weights.
I have just found a Post in R-Bloggers which introduces a svydesign() function. As far as I know, this function from the 'survey' package is like SPSS function, allowing you to create a weighted data to use in further analysis. I find it more useful than using different functions from several packages in order to do multivariable analysis.
Note to #djhurio: The answer would have been better with code. It does seem a bit duplicative of my answer which pointed to the survey package that contains 'svydesign'. The cited webpage is still there 4 years later, but that might not always be the case.

Resources