如何测试缺少值的多元正态性?

时间:2019-07-03 14:50:47

标签: r normalization missing-data multivariate-testing

在数据列上应用missMech:TestMCARNormality时(见下文),其中三列由相同的6行的NA组成:

summary(TestMCARNormality(data = mvn.BN))

我收到一条错误消息:

Warning: More than one missing data pattern should be present.
Error in TestMCARNormality(data = mvn.BN) : 

我的意图是使用此数据测试SEM的多元正态性假设。我的怀疑是,由于这三列在相同的主题上都有缺失值,因此缺失机制不能认为是任意的。因为这三个向量反映了相同的现象,所以我尝试将它们折叠为一个潜在变量,如下所示:

sndPre <- 'sndPre  =~ r + rlct + int'

summary(fit <- cfa(sndPre, data = mvn.BN, missing="fiml"))

df$sndPre <- lavPredict(fit)

但是,使用包含潜在变量而不是三个原始向量的新数据测试多重正态性会导致与以前相同的错误消息。

我们将不胜感激!

structure(list(supp = c(-1.17976111761186, -1.62219358531543, 
1.17976111761186, 0.791638607743375, -0.0477634550971204, -1.22906451292704, 
1.83391463581591, -0.167894004788105, 2.18934975552209, -0.824731912765719, 
0.36610635680057, -1.00626998586084, -0.858754109904802, 0.0716792838286317, 
-0.893800631179489, 1.39869400780818, 1.98075239664728, 0.417667173482733, 
-0.697141434846342, -0.143729233705824, 0.167894004788105, 0, 
1.22906451292704, 0.0477634550971205, -0.241040393886027, -0.497200570681554, 
0.510753305626192, -0.637484160962377, -0.265692304601501, 1.08891702864054, 
-1.83391463581591, -0.119648113039842, 0.637484160962377, 0.727913290881644, 
-2.59265557628224, 0.391756559248618, 0.667016013542502, 0.697141434846342, 
-1.46523379268552, -0.290506771123394, 0.119648113039842, -0.791638607743375, 
-0.75939041152608, -0.0956361870412451, 1.46523379268552, 0.608498134499883, 
-0.315501447257961, -0.0238749182045244, -2.18934975552208, -0.929980941397277, 
0.510753305626192, -1.2815515655446, 0.929980941397277, -0.608498134499883, 
0.551994121316888, 1.71845154339103, 0.290506771123394, -0.524400512708041, 
-1.53897858737058, -0.192157229254373, -0.216534124449171, -0.580014615243761, 
0.580014615243761, -1.13317003025956, 1.00626998586084, 0.0238749182045242, 
-0.667016013542502, -1.71845154339103, -1.04669971498747, 0.443861311926248, 
-0.551994121316888, -0.0716792838286317, 0.241040393886027, -0.391756559248618, 
-0.443861311926248, -1.08891702864054, 0.315501447257961, 0.340694827087795, 
-1.33782840232128, 1.33782840232128, 0.876142849246841, -1.98075239664728, 
-0.340694827087795, 0.876142849246841, 0.216534124449171, -0.727913290881644, 
0.0956361870412451, 1.53897858737058, 0.143729233705824, 0.75939041152608, 
0.824731912765718, 0.265692304601501, 0.967421566101701, -0.470363638377999, 
1.04669971498747, 1.2815515655446, 1.62219358531543, -1.39869400780818, 
1.13317003025956, -0.417667173482733, 0.192157229254372, -0.36610635680057, 
0.470363638377999, -0.967421566101701), rlct = c(0.280221077461472, 
NA, -0.278381421551413, -1.57199071756635, -0.0270835525593782, 
-0.278381421551413, -0.000969320386383176, -0.0386715802266045, 
0.112842890058884, -1.57199071756635, 0.070371710196276, 0.483784267012041, 
-0.742527151717587, -0.987610926853036, 1.47287509993123, -1.57199071756635, 
-1.57199071756635, 1.05640868275726, 0.397314787799829, 1.57113538512573, 
1.20942896447373, -0.145731148967403, 0.940631782306559, -1.57199071756635, 
-0.278381421551413, 1.29238902437959, 0.483784267012041, -1.57199071756635, 
-0.176380408081405, 2.02680058645422, 0.768023557290127, -0.596572861001164, 
0.0634980873774587, -0.448435467665454, NA, -1.12096299160087, 
-0.0202950841488239, -1.57199071756635, 0.940631782306559, 0.578005121810303, 
0.886333728696478, -1.57199071756635, -1.23600381870389, NA, 
0.483784267012041, 0.280221077461472, -1.57199071756635, -0.413265040032032, 
-0.080245567392962, 0.483784267012041, NA, 0.483784267012041, 
1.05640868275726, -0.38857492099479, -1.57199071756635, 1.08976703767843, 
0.628343560444494, 0.443576137399824, -1.57199071756635, -0.831252344445635, 
0.397314787799829, -0.68970672582913, -1.07206642789405, 0.535108926649084, 
-1.57199071756635, -1.57199071756635, NA, 2.02680058645422, 0.645636548945714, 
0.602890708565257, 1.05640868275726, 2.02680058645422, 0.343526991967889, 
-0.145731148967403, 1.35769826997358, 0.550235890534656, -0.335915594040882, 
-1.57199071756635, -0.38857492099479, 1.32107778862743, -1.04341784685432, 
1.63987589158524, NA, 1.25033832194654, 0.42128422668948, -0.596572861001164, 
-0.145731148967403, 0.280221077461472, -1.57199071756635, 0.834247192625187, 
1.37009671045311, -0.859826671324634, 0.871914409639362, 0.112842890058884, 
1.05640868275726, -1.57199071756635, -0.335915594040882, 1.32107778862743, 
-0.278381421551413, -0.247571357064391, -0.481542338316402, -0.481542338316402, 
0.254332998843991, 0.483784267012041), R = c(-1.44878316694673, 
NA, -0.746570767383894, 1.26865645051899, -1.75176415239607, 
0.271791827501559, 0.548071163669653, 0.0169765715809728, 1.63837513046467, 
1.63837513046467, -0.635824706253966, -0.813925628689442, -0.939395691552569, 
0.332386014965153, 0.118098142059536, 1.63837513046467, 1.63837513046467, 
-0.471848700225964, 0.078276278612946, -1.09927490801355, -0.647637011302996, 
-1.31494047461463, 0.0691453765779642, 0.666206157027453, -0.171784871082169, 
-1.07711916265625, 0.118098142059536, -0.471848700225964, -1.12002951365366, 
1.63837513046467, -0.754523167140249, -0.854074237671873, 0.169679176663998, 
-0.156269780499957, NA, 0.186111327124178, 0.0434821717802274, 
-0.230999511810527, -1.23964007778478, 0.305517687906991, -1.75176415239607, 
1.22068945613712, 0.217906742740558, NA, 1.63837513046467, 1.63837513046467, 
0.666206157027453, 0.873615040819669, 0.483819490193061, 0.118098142059536, 
NA, -1.51990113386884, -0.781402829742699, -0.204631736602177, 
-0.471848700225964, -0.583365501745861, 1.07438562229116, -0.471848700225964, 
-1.75176415239607, -0.422187099553652, 1.00819175667281, 0.569705636106715, 
0.271791827501559, 0.533157330977815, 1.63837513046467, -1.75176415239607, 
NA, 1.63837513046467, -0.471848700225964, 0.358200131312215, 
1.63837513046467, 1.63837513046467, 0.248351788877765, -0.781402829742699, 
-0.826338490944626, -1.12725479815266, 0.118098142059536, -0.471848700225964, 
0.620228020132514, -0.129738478713846, 1.00819175667281, -0.471848700225964, 
NA, 0.305517687906991, -0.471848700225964, 0.452056881241183, 
-0.129738478713846, -0.696094415081498, 1.63837513046467, 0.305517687906991, 
-0.299167995749343, -1.2726642552484, -0.270700749601809, -1.43246808902724, 
1.63837513046467, 1.63837513046467, -0.189158730641189, -1.75176415239607, 
1.04312103048841, -0.320577789914539, -1.28026760416336, -1.09927490801355, 
-1.11423481807787, 1.63837513046467), int = c(-0.782440086185924, 
NA, 0.212924230491983, -0.136528542120466, 0.168286644091694, 
0.569310284275056, 0.334351222252171, -0.239257767986, 0.939176254270868, 
-1.23834899552138, 0.344133093176299, 0.514561454790373, -0.157941237779957, 
1.07008109973545, -1.23834899552138, -1.23834899552138, -1.23834899552138, 
0.514561454790373, 0.789682999928247, 1.09903381262152, -1.23834899552138, 
0.694835866181609, 1.7700680825066, -1.23834899552138, 0.569310284275056, 
-1.23834899552138, -1.23834899552138, 1.89862806024719, -0.0378230494652771, 
-1.23834899552138, -0.385153852730917, 0.26169585941428, 1.07415499973807, 
1.57970267890648, NA, 0.127231345700962, 0.870061292013265, -1.23834899552138, 
-1.23834899552138, -0.136528542120466, 0.168286644091694, -1.23834899552138, 
0.323374601090832, NA, 1.2973988974951, 2.53852130586226, 1.01510177359039, 
0.19761523561581, 0.0213873960314485, 1.2973988974951, NA, 1.06441166488122, 
0.0893044347685252, 0.464202232325543, 0.939176254270868, -0.373841392194834, 
-0.113931433468044, 0.000778491766350194, -1.23834899552138, 
-1.23834899552138, 0.26169585941428, 0.806796928486145, 0.212924230491983, 
-0.46348137353114, -1.23834899552138, -1.23834899552138, NA, 
-1.23834899552138, -1.23834899552138, 0.0213873960314485, 0.939176254270868, 
-1.23834899552138, -1.23834899552138, -1.23834899552138, -1.23834899552138, 
0.26169585941428, 1.89862806024719, -1.23834899552138, 0.127231345700962, 
-1.23834899552138, -0.216014117336508, 0.939176254270868, NA, 
0.374522129377425, 0.831454043920379, -1.23834899552138, -1.23834899552138, 
1.09903381262152, 0.514561454790373, -0.136528542120466, -0.511175060632852, 
-0.406654025323036, 0.228691531744415, 2.05858827694955, 1.89862806024719, 
-1.23834899552138, -0.0378230494652771, -1.23834899552138, -0.250360697331749, 
0.0213873960314485, 1.655550552844, 1.09903381262152, 0.228691531744415, 
-1.23834899552138), gta = c(-0.143729233705824, 1.83391463581591, 
-0.929980941397277, -1.46523379268552, 0.378900295495245, 0.948535040826638, 
-1.46523379268552, 1.00626998586084, -1.46523379268552, -0.340694827087795, 
-1.46523379268552, -0.340694827087795, -0.430727299295457, 0, 
-0.697141434846342, -0.929980941397277, -0.143729233705824, -0.340694827087795, 
-0.143729233705824, -0.697141434846342, 0.712443032389489, 1.04669971498747, 
0.580014615243761, 0.315501447257961, 0.791638607743375, 1.46523379268552, 
0.378900295495245, 0.580014615243761, -0.697141434846342, 1.17976111761186, 
-0.538146096504187, 1.71845154339103, 0.948535040826638, -1.46523379268552, 
1.39869400780818, 0.75939041152608, 0.180012369792705, -0.697141434846342, 
-0.929980941397277, -0.143729233705824, 0, 1.2815515655446, -0.430727299295457, 
1.98075239664728, -1.46523379268552, -0.697141434846342, 0, -0.697141434846342, 
-1.46523379268552, -0.143729233705824, 0, 0.893800631179489, 
0.580014615243761, 0.180012369792705, 0.858754109904802, 1.53897858737058, 
0.470363638377999, -0.265692304601501, -1.46523379268552, 1.11077161663679, 
-0.929980941397277, -0.430727299295457, 0.180012369792705, -1.46523379268552, 
-1.46523379268552, 1.62219358531543, 0.824731912765718, 0.265692304601501, 
2.18934975552209, 1.33782840232128, -0.538146096504187, -0.538146096504187, 
-0.929980941397277, -1.46523379268552, -0.538146096504187, 0.580014615243761, 
1.11077161663679, -0.430727299295457, 0.378900295495245, 0.265692304601501, 
-1.46523379268552, -0.929980941397277, 0, -0.216534124449171, 
0.180012369792705, 0, 0.470363638377999, -1.46523379268552, -0.697141434846342, 
0.265692304601501, 0.378900295495245, -1.46523379268552, -0.265692304601501, 
0.107634392383102, 0, -1.46523379268552, 0.470363638377999, 0.580014615243761, 
0.712443032389489, 1.22906451292704, -0.265692304601501, 0.107634392383102, 
0.667016013542502, -0.929980941397277), open = c(-1.92607985655617, 
-0.316590285013791, -0.298402916907573, 0.514186833724082, -1.99813120048837, 
1.94456677442047, 1.56354868020822, -1.08381975857325, 1.26217761908371, 
0.640239717247926, -1.28204786305004, 1.83698930281509, 0.548241607933871, 
1.69544910528848, -0.536011088711, 1.39498216003174, 0.221717933797518, 
-0.695736069353309, 0.650300940259636, 1.14472608609363, 0.898853974686237, 
-0.939565435048314, 1.92697093968417, 0.462290334362355, 1.51181974804599, 
0.667723332853383, 0.845039882354954, -0.332191823394925, -0.858807626023951, 
-0.125821462489645, -0.0634389303805822, -1.01790794895173, -0.723613330734455, 
0.353967113044211, -0.419136624662771, 1.76967413361801, -0.332191823394925, 
-0.570986894367983, -1.99813120048837, -0.274301006996328, -0.824199167288764, 
-1.41980448798487, -0.905146599149194, -1.99813120048837, 0.189550652043953, 
-0.4225531548638, -0.162030614403885, -0.248860637595393, -1.54408925271419, 
0.415670050003845, -0.866109560271283, -1.42724348193835, 1.04110387420274, 
0.6230351809389, -0.382192438913699, -1.15692512350599, -0.377326255741555, 
1.53671972246414, -0.536011088711, 1.16672628385726, 1.42787540110868, 
-1.73627009182479, 0.059953368893635, -0.31084522155919, 0.409150403085802, 
-0.929716900165085, -0.171835768002707, -0.234047527328706, 0.289577319482922, 
0.845039882354954, -0.675071329758215, -0.423570535825805, -0.515836566660935, 
-0.284505490560708, -1.2021149504824, 0.983371293743114, -0.601461993496952, 
0.51894868837645, 0.510699498840829, 0.935837993837305, 1.40235662672974, 
0.845039882354954, -1.99813120048837, 0.746816399891108, 0.488128171705992, 
-1.21266600238008, -0.596634202847598, -0.174599542608208, 1.89421201170045, 
1.24955267381115, -0.517878789742744, -0.351296162327365, 0.68870382291801, 
0.306336571728767, 0.438762693966707, 0.0676668116033076, 0.0232585007488503, 
-0.0634389303805822, 1.62396386651223, -0.736326202021504, -1.21266600238008, 
0.218324021776088, -0.695736069353309, -0.0916621988824299), 
    dtls = c(-1.57921951928357, 0.712443032389489, 0.858754109904802, 
    1.71845154339103, -1.57921951928357, 0.791638607743375, -1.57921951928357, 
    0.315501447257961, 0.551994121316888, 1.00626998586084, -1.57921951928357, 
    0.143729233705824, -0.192157229254373, 0.443861311926248, 
    0.929980941397277, 1.04669971498747, 1.53897858737058, 1.62219358531543, 
    -1.00626998586084, 0.167894004788105, -0.36610635680057, 
    -0.167894004788105, 1.98075239664728, 1.17976111761186, 0.0238749182045242, 
    1.98075239664728, -0.0716792838286317, -0.791638607743375, 
    -1.57921951928357, -0.241040393886027, 0.443861311926248, 
    0.824731912765718, -0.551994121316888, 0.0716792838286317, 
    0.75939041152608, -0.791638607743375, -0.68200135314244, 
    0.443861311926248, -1.57921951928357, -0.497200570681554, 
    -0.0716792838286317, -0.0716792838286317, -1.57921951928357, 
    -1.57921951928357, 0.608498134499883, -0.929980941397277, 
    1.17976111761186, 1.2815515655446, -0.791638607743375, -0.143729233705824, 
    -0.893800631179489, -1.57921951928357, -1.04669971498747, 
    -0.340694827087795, -1.15615185770811, 1.98075239664728, 
    0.278078133485501, 0.241040393886027, 0.443861311926248, 
    -0.637484160962377, 0.667016013542502, -1.15615185770811, 
    -0.580014615243761, 0, -0.216534124449171, 0.443861311926248, 
    1.39869400780818, 0.192157229254372, -0.858754109904802, 
    -0.68200135314244, 0.637484160962377, 0.443861311926248, 
    -0.727913290881644, -0.0716792838286317, -0.0716792838286317, 
    1.08891702864054, -0.470363638377999, -0.608498134499883, 
    0.0956361870412451, 0.278078133485501, 0.0477634550971205, 
    0.216534124449171, -1.57921951928357, -0.524400512708041, 
    0.443861311926248, -0.967421566101701, -0.278078133485501, 
    -0.443861311926248, 0.580014615243761, 0.340694827087795, 
    -0.315501447257961, 1.17976111761186, 0.967421566101701, 
    -0.404677904530048, 1.33782840232128, 1.46523379268552, 0.712443032389489, 
    -1.57921951928357, 0.119648113039842, -0.278078133485501, 
    -1.57921951928357, -0.404677904530048, -1.08891702864054, 
    0.893800631179489)), class = "data.frame", row.names = c(NA, 
-104L))

1 个答案:

答案 0 :(得分:0)

只有一些小提示,希望我能有所帮助。 (很遗憾,我仍然没有完全了解您要归档的内容。

我查看了您的数据-丢失的数据总是以相同的模式出现。 这意味着-如果缺少数据,则始终是这种模式:

non-NA, NA, NA, NA, non-NA, non-NA, non-NA

这也是您的错误信息。

  

警告:应该存在多个缺少的数据模式。

进行您描述的转换(将变量组合为一个变量)时,该转换仍然不会改变。新的模式是:

non-NA, NA, non-NA, non-NA, non-NA

但是整个数据集仍然是相同的模式。

  

我的怀疑是,由于这三列的主题完全相同而缺少值,因此不能将缺失机制视为任意的。

是的-这可能是您可以拥有的非MCAR数据最明显的情况。实际上如此明显,以至于MissMech甚至无法计算出一些东西。

根据MCAR的维基百科定义

  

如果导致任何特定数据项为NA的事件与可观察变量和不可观察参数无关

您的数据显然不是这种情况。由于NA是独立的,因此它们将以某种方式均匀地分布在所有变量上。 NA仅针对3个变量出现的事实表明了这一点。 因为您可以说:如果值取决于NA,则它的变量为v2,v3,v4-因为仅对于这些变量,才会出现NA。

通常,MCAR测试将测试该假设“独立于可观察变量和不可观察参数”。它会以某种方式看起来是否所有可能的模式均等地出现。因为只有那时数据才是MCAR。如果从一开始只有一种模式-您甚至无法开始计算模式的频率。

希望我能帮上忙-这是相当简化的说明,以使其易于理解。

关于多元正态检验:

library("MVN")
library("mice")

#imputation with mice
imp <- mice(mvn, m=5)
imp_data <- complete(imp, action = 1)

# mvn test with MVN package
mvn(imp_data, univariatePlot = "qqplot")

那将以非多重插补方式使用小鼠。您也可以进行多次插补,但是随后您必须合并插补结果。由于您的数据不是MCAR,因此两种方式都有可能引入偏差。但是,如果您进行完整的案例分析,您也可能会引入偏见。因此可能无法100%避免偏见。