我有一个三级数据集,其中包含嵌套在个人内的几天之内嵌套的纵向数据(个人在几天内提供了多个纵向测量值)。数据集中的某些基线变量中缺少数据,因此我想执行多次插补。
我知道MICE可以为两个级别的数据提供多个插补(第5个小插图详细介绍了此过程)。
是否可以使用R中当前可用的软件包(例如MICE,Amelia)对三级纵向数据进行多次插补?如果是这样,什么是正确的编码以确保数据正确聚类?
我不能在此处共享数据集,但是我创建了一个示例数据集,以给出有关结构类型的想法(三层数据,协变量中缺少数据)。
dput(example)
structure(list(Individual = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), Day = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L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3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), Gender = c(NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), Employment = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2), X1 = c(4.56799937761568, 3.28530621609137,
1.88643722843339, 3.42422132662748, 3.14302452735969, 4.34985690923306,
3.27002303956632, 3.94053506229622, 2.74554385385596, 1.30041561375585,
4.76162702174774, 2.93723737817891, -0.726455413439576, 3.19541585897237,
2.55763273548039, 1.60337293238759, 4.04541284157429, 7.47881346686,
4.9800832922899, 4.20401413072706, 2.89462105543075, 1.99655930977235,
3.5035291970676, 1.98422462728112, 1.59434512649229, 1.73897362770121,
2.38112975362368, 0.937768572351, 2.53102728108233, 1.93664582749016,
0.36652184684279, 2.07784348322669, 0.738973564510718, 0.873169056997296,
0.503682024238028, 0.971089717504977, 2.60221016037519, 2.24933522242153,
1.62538130164906, 2.98648446960426, 4.58809508670484, 1.84281924946719,
0.253661566596934, 4.2663432818192, 1.06517666943662, 1.00343214550086,
2.66396658733004, 3.45228776822585, -1.70401559530981, 7.18027270471957,
NA, 4.34328505170825, 2.32236316246228, 2.44087317365538, NA,
3.34062921792044, 4.23295044967829, NA, 1.7019679624866, 2.5071793294043,
1.54162298812261, 8.41855278524014, 3.53527290896066, 2.1902854117709,
2.73061024025738, 3.58171661403679, 6.5596468209299, 2.5831821744669,
4.34117659228018, 2.67484129757982, 2.56501166705279, 5.89162342569475,
9.70355610605046, 7.01581126897901, 5.34777180414719, 6.57411987963925,
4.580600633833, 5.35913153139529, 9.51523790792593, 4.01372279867166,
0.899070262936315, 4.07678323507976, 1.03106472484263, 1.28683203324844,
0.29444039154462, 3.26510653182127, 1.44993488455612, 4.02983124253234,
2.39115637237936, 2.83977057433979, NA, 1.11165798774108, -2.50192750695809,
0.771650316358582, NA, -0.364299664373447, -2.9064868561653,
3.45268382831264, -1.48116394768266, -1.12156412784994, -2.92964853045487,
-1.52865241382115, 0.964307751354998, 1.19092565659524, -1.04838003708988,
-3.22238572203632, -1.27522060985488, 1.96848113503559, NA, -1.73141592727595,
0.872137460669562, -0.491286316636652, -0.380720539256574, -1.47142225548013,
2.00655469848947, -1.33397286854922, 0.808215399304354, 3.22346876835569,
1.03695501303861, -0.84134216534803, 2.40310659352902, 1.12473483611501,
0.895024716877496, 0.551373537342888, 1.56979757096968, 0.60874017413089,
-0.0278688331928156, -0.944950321223158, 1.11982283854112, 0.264619266329284,
0.42525706041798, 0.544964867220432, 0.302283249775677, 2.64421186880713,
3.02006414126338, -1.80524204835356, 2.64130323670771, 3.25739885251618,
1.0257146545255, 3.72449749516719, 2.26818250832416, 0.383169300895392,
-1.72708614488018, -0.438909624038464, 1.08514861523167, -1.62506913485824,
0.522487669220221, 1.31609170790053, -0.645116914611231, -2.25892446022356
), Outcome = c(3.29031420361728, 3.24062664454343, 3.39338685374188,
3.197651549523, 3.26766208613382, 3.11995045176225, 3.50991531372801,
2.93471300502479, 3.75219067356005, 3.64368697900055, 4.43484855283625,
-0.232395438715922, 0.658689323966351, 3.74731932668456, 2.74414259855657,
2.81181144507717, 2.61061874499533, 2.74548699086686, 2.4377403180924,
1.58942432214642, 4.91761099679115, 2.54145093636531, 1.22670638221606,
2.68370082960663, 2.57428411204219, 6.13801490396762, 1.82179734215785,
3.34550898188158, 3.93047176530982, 2.86125697212997, 7.90860317580001,
8.89660172974458, 9.11564217096599, 8.82741941555083, 9.5968074326626,
9.25767615989576, 9.49544697662325, 8.59932087596937, 9.33975684926234,
9.27308789749323, 9.49843534672129, 9.06117936752841, 9.40783844880124,
5.2538824659606, 9.59041837913761, 8.55277979590736, 7.226908924541,
11.7914002441666, 9.46604604479229, 11.3225388947399, 6.81060422996336,
9.2097962640867, 7.73024268972153, 9.15230439214275, 9.20316756207127,
8.63437120413027, 9.41567306810507, 8.6694305334743, 10.007524355154,
8.73468902590688, 4.73172382207641, 3.96176561300984, 5.13726960648637,
3.99429747168309, 2.21014002434785, 5.29419360003254, 5.0053268566294,
3.32101788959176, 2.69751117352717, 3.44680717054661, 2.15202655992689,
2.03378295975044, 1.54872651578228, 2.52696718269767, 1.8668552280892,
2.99263257935166, 0.926233674772212, 3.11662956590077, 4.0800107216195,
1.70933495481982, 5.22756420152372, 1.70997322513211, 3.98831750090815,
2.46610661471806, 7.29096774392846, 1.51381319571508, 3.04203037732175,
4.32251400630439, 4.19483684044264, 2.14971484766726, 5.61533361764839,
5.2349825721004, 5.26809624207159, 5.46254325606683, 5.40329889182761,
5.29219576867797, 5.45115780447221, 5.40890742546083, 5.31741976729163,
5.24364361604231, 4.20910101259922, 4.43063929813557, 4.3472773369923,
4.44056475758137, 4.40999242252797, 4.71577240431478, 4.49273594174865,
4.23408827043171, 4.43683645729281, 4.50609662906562, 4.12642226884583,
1.1978502696604, 3.8995838457029, 3.40184412295174, 2.77514176974999,
3.8739409884941, 2.17710412503079, 5.44698159092671, 4.10982991271197,
3.12399562097586, 2.74339083721318, 1.47342993709278, 1.49072833589541,
3.20126283483613, 2.84819778247538, 1.55354977873263, 0.257909445450114,
1.46782743610311, 1.3748039938255, 2.17750589200485, 3.96795836211079,
5.43261884744704, 7.28857275675995, 4.31274500659575, 8.70936455365878,
4.3067420105185, 6.90333624632229, 6.49908965132559, 5.81903347781654,
8.31698424396048, 6.30247607724175, 7.43900754402365, 6.18403633478174,
0.173351883424298, 3.37536631167211, 6.67461890035257, 5.81122906483395,
4.56660407266441, 7.96726314681218, 7.29650620991117)), row.names = c(NA,
-150L), class = "data.frame")