“[[<;-.data.frame`”(“*tmp*`,i,value=c(19L,19L,19L,18L,19L,”)中的R包smcure错误:替换有2250行,数据有750行

“[[<;-.data.frame`”(“*tmp*`,i,value=c(19L,19L,19L,18L,19L,”)中的R包smcure错误:替换有2250行,数据有750行,r,survival-analysis,mixture-model,R,Survival Analysis,Mixture Model,数据有1568个观察值,所以我不明白为什么它说数据有750行?而且,替换总是我在模型中输入的协变量量的乘积(这里750x3=2250),提前谢谢 > str(dmpold) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1568 obs. of 12 variables: $ ...1 : chr "109" "761" "844" "1907" ... $ person_id : num 89 63

数据有1568个观察值,所以我不明白为什么它说数据有750行?而且,替换总是我在模型中输入的协变量量的乘积(这里750x3=2250),提前谢谢

> str(dmpold)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   1568 obs. of  12 variables:
 $ ...1             : chr  "109" "761" "844" "1907" ...
 $ person_id        : num  89 634 708 1604 1848 ...
 $ Region           : Factor w/ 13 levels "Aalst-Oudenaarde",..: 11 4 6 7 2 2 13 4 7 12 ...
 $ Education_level  : Factor w/ 17 levels "1Primary Education/1th Degree Secondary Education",..: 14 
17 11 16 17 13 13 11 8 17 ...
 $ Age              : num  61 62 63 60 60 61 62 60 63 63 ...
 $ Driver_License   : Factor w/ 12 levels "A","A3","B","BE",..: 3 NA 3 5 3 3 3 3 7 3 ...
 $ Transportation   : Factor w/ 5 levels "Bicycle","Car",..: 2 NA 2 2 NA 2 2 2 NA 2 ...
 $ Knowledge_Dutch  : Factor w/ 4 levels "Good Knowledge",..: 2 1 1 4 1 4 4 4 1 2 ...
 $ Immigrant        : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Sex              : Factor w/ 2 levels "F","M": 2 1 2 2 2 1 2 2 2 2 ...
 $ unemployment_time: num  39 5 2 3 3 2 3 2 9 6 ...
 $ censor           : num  0 0 0 1 1 0 1 0 0 1 ...

我首先将性别变量设为数字(1表示男性,0表示女性)。然后,使用fastDummies软件包,我附加了教育水平的虚拟变量。共有13个教育水平,因此创建了13个假人。我将这些假人聚合为4组(1中学学位和备选学位、2中学学位、3中学学位、学士/硕士学位。我这样做是为了使smcure能够拟合模型,如果假人内没有足够的观察,则无法拟合模型


然后,我选择了degree secondary&alternative作为我的基线,并将其从模型中排除。所以现在看起来是这样的:pd看起来您的数据中缺少值。您有多少完整案例?使用
sum(complete.cases(dmpold))
,如果只有750个完整的案例可以解释这个错误。我现在使用了一份包含12558个观察值的数据集副本,它仍然会给出这个错误:
[[你能用
dput(head(dmpold,100))发布你问题中的数据副本吗?)
?我在问题中添加了它,谢谢!确切地说,它不喜欢分类变量,所以我为分类变量创建了k-1虚拟变量,现在它可以工作了!
> str(dmpold)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   1568 obs. of  12 variables:
 $ ...1             : chr  "109" "761" "844" "1907" ...
 $ person_id        : num  89 634 708 1604 1848 ...
 $ Region           : Factor w/ 13 levels "Aalst-Oudenaarde",..: 11 4 6 7 2 2 13 4 7 12 ...
 $ Education_level  : Factor w/ 17 levels "1Primary Education/1th Degree Secondary Education",..: 14 
17 11 16 17 13 13 11 8 17 ...
 $ Age              : num  61 62 63 60 60 61 62 60 63 63 ...
 $ Driver_License   : Factor w/ 12 levels "A","A3","B","BE",..: 3 NA 3 5 3 3 3 3 7 3 ...
 $ Transportation   : Factor w/ 5 levels "Bicycle","Car",..: 2 NA 2 2 NA 2 2 2 NA 2 ...
 $ Knowledge_Dutch  : Factor w/ 4 levels "Good Knowledge",..: 2 1 1 4 1 4 4 4 1 2 ...
 $ Immigrant        : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Sex              : Factor w/ 2 levels "F","M": 2 1 2 2 2 1 2 2 2 2 ...
 $ unemployment_time: num  39 5 2 3 3 2 3 2 9 6 ...
 $ censor           : num  0 0 0 1 1 0 1 0 0 1 ...
structure(list(X = c(28L, 77L, 91L, 109L, 125L, 136L, 140L, 219L, 
306L, 372L, 396L, 405L, 439L, 441L, 461L, 504L, 537L, 569L, 585L, 
608L, 616L, 617L, 657L, 681L, 698L, 700L, 729L, 761L, 765L, 778L, 
786L, 808L, 813L, 818L, 844L, 850L, 989L, 1150L, 1165L, 1194L, 
1198L, 1210L, 1314L, 1324L, 1342L, 1442L, 1482L, 1496L, 1621L, 
1640L, 1680L, 1691L, 1726L, 1758L, 1772L, 1803L, 1813L, 1821L, 
1828L, 1907L, 1958L, 1981L, 1988L, 1998L, 2011L, 2012L, 2019L, 
2106L, 2114L, 2120L, 2140L, 2148L, 2167L, 2193L, 2242L, 2274L, 
2336L, 2342L, 2393L, 2394L, 2427L, 2442L, 2461L, 2485L, 2489L, 
2499L, 2525L, 2530L, 2541L, 2581L, 2589L, 2683L, 2684L, 2733L, 
2765L, 2854L, 2860L, 2902L, 2936L, 2940L), person_id = c(24L, 
62L, 73L, 89L, 102L, 111L, 115L, 184L, 258L, 311L, 331L, 339L, 
371L, 373L, 390L, 428L, 453L, 480L, 494L, 512L, 520L, 521L, 551L, 
568L, 583L, 584L, 610L, 634L, 638L, 650L, 657L, 674L, 678L, 683L, 
708L, 714L, 824L, 964L, 977L, 1002L, 1006L, 1017L, 1105L, 1113L, 
1128L, 1211L, 1248L, 1262L, 1358L, 1373L, 1410L, 1419L, 1449L, 
1476L, 1487L, 1515L, 1523L, 1530L, 1535L, 1604L, 1644L, 1663L, 
1667L, 1677L, 1688L, 1689L, 1694L, 1772L, 1779L, 1784L, 1802L, 
1809L, 1824L, 1848L, 1890L, 1916L, 1967L, 1973L, 2016L, 2017L, 
2048L, 2062L, 2075L, 2094L, 2098L, 2108L, 2131L, 2135L, 2144L, 
2177L, 2185L, 2266L, 2267L, 2307L, 2335L, 2406L, 2410L, 2442L, 
2474L, 2477L), Region = structure(c(5L, 5L, 9L, 11L, 3L, 7L, 
2L, 7L, 7L, 2L, 2L, 4L, 1L, 11L, 5L, 11L, 10L, 4L, 2L, 5L, 13L, 
13L, 2L, 1L, 3L, 8L, 5L, 4L, 5L, 4L, 12L, 6L, 2L, 5L, 6L, 13L, 
12L, 11L, 10L, 7L, 2L, 8L, 13L, 9L, 12L, 7L, 13L, 2L, 8L, 4L, 
13L, 4L, 10L, 9L, 4L, 5L, 2L, 5L, 11L, 7L, 5L, 8L, 3L, 2L, 3L, 
12L, 13L, 1L, 13L, 1L, 2L, 4L, 12L, 2L, 13L, 2L, 3L, 9L, 2L, 
2L, 13L, 5L, 13L, 10L, 12L, 2L, 4L, 2L, 5L, 10L, 1L, 5L, 10L, 
2L, 7L, 4L, 13L, 6L, 10L, 6L), .Label = c("Aalst-Oudenaarde", 
"Antwerpen-Boom", "Brugge", "Gent", "Hasselt", "Kortrijk-Roeselare", 
"Leuven", "Mechelen", "Oostende-Westhoek", "Sint-Niklaas-Dendermonde", 
"Tongeren", "Turnhout", "Vilvoorde"), class = "factor"), Education_level =                         
structure(c(4L, 
17L, 4L, 14L, 8L, 13L, 17L, 17L, 1L, 16L, 13L, 17L, 4L, 1L, 16L, 
1L, 13L, 13L, 8L, 8L, 17L, 17L, 11L, 11L, 11L, 17L, 6L, 17L, 
1L, 17L, 11L, 17L, 17L, 17L, 11L, 17L, 8L, 9L, 11L, 4L, 8L, 14L, 
17L, 17L, 11L, 8L, 4L, 17L, 3L, 17L, 3L, 17L, 17L, 4L, 1L, 4L, 
16L, 11L, 9L, 16L, 8L, 17L, 8L, 3L, 3L, 17L, 17L, 17L, 17L, 3L, 
17L, 11L, 8L, 17L, 17L, 13L, 17L, 17L, 13L, 13L, 13L, 13L, 17L, 
17L, 4L, 13L, 11L, 6L, 4L, 8L, 17L, 14L, 17L, 9L, 8L, 17L, 3L, 
17L, 3L, 17L), .Label = c("1Primary Education/1th Degree Secondary                 
Education", 
"2nd Degree Artistic Secondary Education", "2nd Degree Technical Secondary 
Education", 
"2nd Degree Vocational Secondary Education", "2Primary Education/1th 
Degree Secondary Education", 
"3Primary Education/1th Degree Secondary Education", "3th Degree Artistic 
Secondary Education", 
"3th Degree Technical Secondary Education", "3th Degree Vocational 
Secondary Education", 
"4th Degree Vocational Secondary Education (7years)", "5Primary 
Education/1th Degree Secondary Education", 
"71", "7Primary Education/1th Degree Secondary Education", "8Primary 
Education/1th Degree Secondary Education", 
"Extraordinary Secondary Education", "Master Degree", "Primary 
Education/1th Degree Secondary Education"
), class = "factor"), Age = c(56L, 55L, 55L, 61L, 55L, 59L, 55L, 
55L, 56L, 59L, 56L, 57L, 56L, 57L, 58L, 55L, 55L, 57L, 57L, 58L, 
57L, 59L, 55L, 56L, 57L, 59L, 59L, 62L, 55L, 56L, 56L, 55L, 57L, 
56L, 63L, 55L, 56L, 55L, 57L, 59L, 55L, 56L, 55L, 56L, 55L, 57L, 
56L, 55L, 56L, 55L, 56L, 59L, 57L, 55L, 59L, 56L, 58L, 56L, 55L, 
60L, 58L, 58L, 55L, 55L, 55L, 55L, 55L, 56L, 55L, 55L, 57L, 57L, 
55L, 60L, 56L, 56L, 57L, 56L, 55L, 61L, 62L, 55L, 57L, 55L, 55L, 
59L, 60L, 57L, 55L, 57L, 59L, 57L, 57L, 56L, 63L, 56L, 55L, 55L, 
57L, 58L), Driver_License = structure(c(7L, 5L, 5L, 5L, 5L, 5L, 
1L, 1L, 5L, 5L, 5L, 1L, 9L, 5L, 5L, 5L, 7L, 5L, 5L, 5L, 1L, 5L, 
5L, 5L, 1L, 5L, 5L, 1L, 5L, 1L, 5L, 7L, 1L, 5L, 5L, 5L, 9L, 5L, 
7L, 9L, 9L, 5L, 5L, 5L, 5L, 5L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 10L, 
5L, 5L, 5L, 5L, 5L, 7L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 1L, 1L, 7L, 
1L, 5L, 5L, 5L, 5L, 7L, 5L, 5L, 5L, 5L, 5L, 5L, 1L, 1L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 9L, 5L, 1L, 5L, 5L, 7L), .Label = c("", 
"A", "A2", "A3", "B", "BE", "C", "C1", "CE", "D", "D1", "DE", 
"E", "G"), class = "factor"), Transportation = structure(c(3L, 
3L, 1L, 3L, 1L, 1L, 6L, 6L, 3L, 3L, 1L, 4L, 3L, 1L, 1L, 3L, 3L, 
3L, 1L, 1L, 6L, 3L, 1L, 3L, 6L, 3L, 3L, 1L, 3L, 6L, 3L, 1L, 6L, 
3L, 3L, 1L, 3L, 1L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 6L, 6L, 3L, 
3L, 3L, 3L, 1L, 3L, 1L, 3L, 3L, 3L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 6L, 6L, 3L, 6L, 3L, 3L, 1L, 3L, 3L, 1L, 1L, 1L, 3L, 3L, 
3L, 6L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 1L, 1L, 6L, 
3L, 3L, 3L), .Label = c("", "Bicycle", "Car", "Moped", "Motorbike", 
"Public Transportation", "Uknown Transportation Method"), class =         
"factor"), 
Knowledge_Dutch = structure(c(3L, 2L, 1L, 2L, 3L, 4L, 2L, 
3L, 4L, 4L, 4L, 3L, 2L, 3L, 4L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 
4L, 4L, 3L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 2L, 3L, 3L, 4L, 3L, 
4L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 
3L, 3L, 3L, 4L, 4L, 4L, 3L, 4L, 4L, 3L, 3L, 4L, 3L, 4L, 4L, 
3L, 3L, 3L, 4L, 3L, 4L, 3L, 3L, 4L, 3L, 3L, 3L, 4L, 4L, 2L, 
3L, 3L, 3L, 4L, 4L, 3L, 3L, 4L, 3L, 4L, 2L, 4L, 3L, 4L, 3L, 
3L, 3L, 3L), .Label = c("0", "1", "2", "3"), class = "factor"), 
Immigrant = c(0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), 
Sex = c(TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, 
TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, 
FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, 
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, 
TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, 
FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, 
FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, 
TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, 
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, 
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, 
TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE), 
unemployment_time = c(1L, 33L, 9L, 39L, 2L, 6L, 81L, 79L, 
7L, 2L, 14L, 4L, 1L, 82L, 12L, 36L, 4L, 6L, 1L, 1L, 5L, 53L, 
18L, 5L, 2L, 1L, 3L, 5L, 3L, 1L, 21L, 23L, 18L, 41L, 2L, 
16L, 15L, 3L, 1L, 4L, 1L, 16L, 25L, 8L, 44L, 12L, 1L, 25L, 
24L, 23L, 15L, 6L, 2L, 35L, 11L, 6L, 4L, 32L, 44L, 3L, 2L, 
6L, 8L, 13L, 1L, 1L, 31L, 25L, 3L, 35L, 13L, 2L, 2L, 3L, 
8L, 19L, 7L, 1L, 17L, 2L, 3L, 32L, 1L, 6L, 1L, 11L, 2L, 9L, 
34L, 1L, 4L, 7L, 17L, 17L, 9L, 1L, 25L, 2L, 2L, 3L), censor = c(1L, 
0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 
1L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 
1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 
1L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 
0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 
0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L)), row.names = c(NA, 100L
), class = "data.frame")