/
PackagemifaJanuary222021TitleMultipleImputationforExploratoryFactor PackagemifaJanuary222021TitleMultipleImputationforExploratoryFactor

PackagemifaJanuary222021TitleMultipleImputationforExploratoryFactor - PDF document

hadley
hadley . @hadley
Follow
347 views
Uploaded On 2021-06-26

PackagemifaJanuary222021TitleMultipleImputationforExploratoryFactor - PPT Presentation

2mifaIndex11 mifaGetcovariancematrixofincompletedatausingmultipleimputation DescriptionComputecovariancematrixofincompletedatausingmultipleimputationFormultipleimputationMultivariateImputationbyCha ID: 847331

boot data mifa mice data boot mice mifa denceintervals fieller cov x0000 note bydefault false dplyr con aut numericdata

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "PackagemifaJanuary222021TitleMultipleImp..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1 Package`mifa'January22,2021TitleMultiple
Package`mifa'January22,2021TitleMultipleImputationforExploratoryFactorAnalysisVersion0.2.0URLhttps://github.com/teebusch/mifaBugReportshttps://github.com/teebusch/mifa/issuesImportsstats,mice,dplyr,checkmateSuggestspsych,testthat,knitr,rmarkdown,ggplot2,tidyr,covrDescriptionImputethecovariancematrixofincompletedatasothatfactoranalysiscanbeperformed.ImputationsaremadeusingmultipleimputationbyMultivariateImputationwithChainedEquations(MICE)andcombinedwithRubinsrules.ParametricFiellercondenceintervalsandnonparametricbootstrapcondenceintervalscanbeobtainedforthevarianceexplainedbydifferentnumbersofprincipalcomponents.ThemethodisdescribedinNassirietal.(2018) oi:;.3;ݘ/;&#xs134;(-0;-1;-;䀀LicenseMIT+leLICENSEEncodingUTF-8LazyDatatrueRoxygenNote7.1.1NeedsCompilationnoAuthorVahidNassiri[aut],AnikóLovik[aut],GeertMolenberghs[aut],GeertVerbeke[aut],TobiasBusch[aut,cre](&#xhttp;&#xs://;&#xorci; .or;᠀g/0000-0002-8390-7892)MaintainerTobiasBusch&#xteeb;&#xusch;&#x@gma;&#xil.c;&#xom00;RepositoryCRANDate/Publication2021-01-2208:40:08UTCRtopicsdocumented:mifa.............................................2mifa_ci_boot........................................5mifa_ci_eller........................................91 2mifaIndex11 mifaGetcovariancematrixofincompletedatausingmultipleimputation DescriptionComputecovariancematrixofincompletedatausingmultipleimputation.Formultipleimputa-tion,MultivariateImputationbyChainedEquations(MICE)fromthemicepackageisused.ThecovariancematricesoftheimputeddatasetsarecombinedusingRubin'srules.Usagemifa(data,co

2 v_vars=dplyr::everything(),n_pc,ci=FALSE
v_vars=dplyr::everything(),n_pc,ci=FALSE,conf=0.95,n_boot=1000,...)ArgumentsdataAdataframewithmissingvaluescodedasNA.cov_varsVariablesindataforwhichtocalculatethecovariancematrix.Supports(tidyselection)dplyr::select().Thisallowstoselectvariablesthatareusedfortheimputationsofmissingvalues,butnotthecalculationsofthecovariancematrix.Thisisespeciallyusefulwhentherearecategoricalpredictorsthatcanimprovetheimputationoftheresponsevariables,butforwhichcovariancecannotbecalculated.Bydefault,allvariablesindataareusedforboth,theimputationandthecovariancematrix.Note:Variablesandrowsusedfortheimputation,aswellasthemethodforimputationcanbeconguredusingthe....Seealsomice::mice().n_pcIntegerorintegervectorindicatingnumberofprincipalcomponents(eigenvec-tors)forwhichexplainedvariance(eigenvalues)shouldbeobtainedandforwhichcondenceintervalsshouldbecomputed.Defaultstoallprincipalcom-ponents,i.e.,thenumberofvariablesinthedata.ciAcharacterstringindicatingwhichtypesofcondenceintervalsshouldbecon-structedforthevarianceexplainedbytheprincipalcomponents.If"boot","fieller",or"both",thecorrespondingintervalsarecomputed.IfFALSE(thedefault)nocondenceintervalswillbecomputed.Thecomponentsforwhichcondenceintervalsshouldbecomputedcanbesetwithn_pc.Seemifa_ci_boot()andmifa_ci_fieller()fordetailsaboutthetwomethods.confCondencelevelforconstructingcondenceintervals.Thedefaultis.95thatis,95%condenceintervals. mifa3n_bootNumberofbootstrapsamplestouseforbootstrappedcondenceintervals.Thedefaultis1000....Argumentspassedontomice::micemNumberofmultipleimputations.Thedefaultism=5.met

3 hodCanbeeitherasinglestring,oravectorofs
hodCanbeeitherasinglestring,oravectorofstringswithlengthlength(blocks),specifyingtheimputationmethodtobeusedforeachcolumnindata.Ifspeciedasasinglestring,thesamemethodwillbeusedforallblocks.Thedefaultimputationmethod(whennoargumentisspecied)dependsonthemeasurementlevelofthetargetcolumn,asregulatedbythedefaultMethodargument.Columnsthatneednotbeimputedhavetheemptymethod"".Seedetails.predictorMatrixAnumericmatrixoflength(blocks)rowsandncol(data)columns,containing0/1dataspecifyingthesetofpredictorstobeusedforeachtargetcolumn.Eachrowcorrespondstoavariableblock,i.e.,asetofvariablestobeimputed.Avalueof1meansthatthecolumnvariableisusedasapredictorforthetargetblock(intherows).Bydefault,thepredictorMatrixisasquarematrixofncol(data)rowsandcolumnswithall1's,exceptforthediagonal.Note:Fortwo-levelimputationmod-els(whichhave"2l"intheirnames)othercodes(e.g,2or-2)arealsoallowed.ignoreAlogicalvectorofnrow(data)elementsindicatingwhichrowsareignoredwhencreatingtheimputationmodel.ThedefaultNULLincludesallrowsthathaveanobservedvalueofthevariabletoimputed.RowswithignoresettoTRUEdonotinuencetheparametersoftheimpu-tationmodel,butarestillimputed.Wemayusetheignoreargumenttosplitdataintoatrainingset(onwhichtheimputationmodelisbuilt)andatestset(thatdoesnotinuencetheimputationmodelestimates).Note:Multivariateimputationmethods,likemice.impute.jomoImpute()ormice.impute.panImpute(),donothonourtheignoreargument.whereAdataframeormatrixwithlogicalsofthesamedimensionsasdataindicatingwhereinthedatatheimputationsshouldbecreated.Thedefault,where=is.na(data),speciesthatthemissingdatashouldbeimp

4 uted.Thewhereargumentmaybeusedtooverimpu
uted.Thewhereargumentmaybeusedtooverimputeobserveddata,ortoskipimputationsforselectedmissingvalues.blocksListofvectorswithvariablenamesperblock.Listelementsmaybenamedtoidentifyblocks.Variableswithinablockareimputedbyamulti-variateimputationmethod(seemethodargument).Bydefaulteachvari-ableisplacedintoitsownblock,whichiseffectivelyfullyconditionalspecication(FCS)byunivariatemodels(variable-by-variableimputation).Onlyvariableswhosenamesappearinblocksareimputed.TherelevantcolumnsinthewherematrixaresettoFALSEofvariablesthatarenotblockmembers.Avariablemayappearinmultipleblocks.Inthatcase,itiseffectivelyre-imputedeachtimethatitisvisited.visitSequenceAvectorofblocknamesofarbitrarylength,specifyingthesequenceofblocksthatareimputedduringoneiterationoftheGibbssam-pler.Ablockisacollectionofvariables.Allvariablesthataremembersofthesameblockareimputedwhentheblockisvisited.Avariablethatis 4mifaamemberofmultipleblocksisre-imputedwithinthesameiteration.ThedefaultvisitSequence="roman"visitstheblocks(lefttoright)intheor-derinwhichtheyappearinblocks.Onemayalsouseoneofthefollowingkeywords:"arabic"(righttoleft),"monotone"(orderedlowtohighpro-portionofmissingdata)and"revmonotone"(reverseofmonotone).formulasAnamedlistofformula's,orexpressionsthatcanbeconvertedintoformula'sbyas.formula.Listelementscorrespondtoblocks.Theblocktowhichthelistelementappliesisidentiedbyitsname,solistnamesmustcorrespondtoblocknames.TheformulasargumentisanalternativetothepredictorMatrixargumentthatallowsformoreexibilityinspecifyingimputationmodels,e.g.,forspecifyinginteractionterms.blotsAnamedlistofalist'sthatc

5 anbeusedtopassdownargumentstolowerleveli
anbeusedtopassdownargumentstolowerlevelimputationfunction.Theentriesofelementblots[[blockname]]arepasseddowntothefunctioncalledforblockblockname.postAvectorofstringswithlengthncol(data)specifyingexpressionsasstrings.Eachstringisparsedandexecutedwithinthesampler()func-tiontopost-processimputedvaluesduringtheiterations.Thedefaultisavectorofemptystrings,indicatingnopost-processing.defaultMethodAvectoroflength4containingthedefaultimputationmethodsfor1)numericdata,2)factordatawith2levels,3)factordatawith�2unorderedlevels,and4)factordatawith�2orderedlevels.Bydefault,themethodusespmm,predictivemeanmatching(numericdata)logreg,logisticregressionimputation(binarydata,factorwith2levels)polyreg,polytomousregressionimputationforunorderedcategoricaldata(factor�2levels)polr,proportionaloddsmodelfor(ordered,�2levels).maxitAscalargivingthenumberofiterations.Thedefaultis5.printFlagIfTRUE,micewillprinthistoryonconsole.Useprint=FALSEforsilentcomputation.seedAnintegerthatisusedasargumentbytheset.seed()foroffsettingtherandomnumbergenerator.Defaultistoleavetherandomnumbergeneratoralone.data.initAdataframeofthesamesizeandtypeasdata,withoutmissingdata,usedtoinitializeimputationsbeforethestartoftheiterativeprocess.ThedefaultNULLimpliesthatstartingimputationarecreatedbyasimplerandomdrawfromthedata.Notethatspecicationofdata.initwillstartallmGibbssamplingstreamsfromthesameimputation.DetailsThefunctionalsocomputesthevarianceexplainedbydifferentnumbersofprincipalcomponentsandthecorrespondingFieller(parametric)orbootstrap(nonparametric)condenceintervals.ValueAlist:cov_

6 combinedTheestimatedcovariancematrixofth
combinedTheestimatedcovariancematrixoftheincompletedata,basedonthecombinedcovariancematricesofimputeddatasets. mifa_ci_boot5cov_imputationsAlistcontainingtheestimatedcovariancematrixesforallimputeddatasets.var_explainedAdataframecontainingtheestimatedproportionsofexplainedvarianceforeachofspeciedn_pccomponents.Dependingonci,itwillalsocontaintheestimatedFieller's(parametric)and/orbootstrap(nonparametric)condenceintervalfortheproportionofvari-anceexplainedbythedifferentnumbersofprincipalcomponentsdenedbyn_pc.midsObjectoftypemice::mids.Thisistheresultsofthemultipleimputationstepforthecovari-ancematrix.Canbeusefulfordiagnosingthemultipleimputations.ReferencesNassiri,V.,Lovik,A.,Molenberghs,G.,&Verbeke,G.(2018).Onusingmultipleimputationforexploratoryfactoranalysisofincompletedata.BehavioralResearchMethods50,501–517.doi:10.3758/s1342801710134SeeAlsomifa_ci_boot(),mifa_ci_fieller(),mice::mice()Examplesif(requireNamespace("psych")){datapsych::bfimifa(data,cov_vars=-c(age,education,gender),ci="fieller",print=FALSE)} mifa_ci_bootBootstrapcondenceintervalsforexplainedvariance DescriptionComputebootstrapcondenceintervalsfortheproportionofexplainedvarianceforthecovarianceofanincompletedataimputedusingmultipleimputation.Formultipleimputation,MultivariateImputationbyChainedEquations(MICE)fromthemicepackageisused.Usagemifa_ci_boot(data,cov_vars=dplyr::everything(),n_pc,conf=0.95,n_boot=1000,progress=FALSE,...) 6mifa_ci_bootArgumentsdataAdataframewithmissingvaluescodedasNA.cov_varsVariablesindataforwhichtocalculatethecovariancematrix.Supports(tidyselection)dplyr::s

7 elect().Thisallowstoselectvariablesthata
elect().Thisallowstoselectvariablesthatareusedfortheimputationsofmissingvalues,butnotthecalculationsofthecovariancematrix.Thisisespeciallyusefulwhentherearecategoricalpredictorsthatcanimprovetheimputationoftheresponsevariables,butforwhichcovariancecannotbecalculated.Bydefault,allvariablesindataareusedforboth,theimputationandthecovariancematrix.Note:Variablesandrowsusedfortheimputation,aswellasthemethodforimputationcanbeconguredusingthe....Seealsomice::mice().n_pcIntegerorintegervectorindicatingnumberofprincipalcomponents(eigenvec-tors)forwhichexplainedvariance(eigenvalues)shouldbeobtainedandforwhichcondenceintervalsshouldbecomputed.Defaultstoallprincipalcom-ponents,i.e.,thenumberofvariablesinthedata.confCondencelevelforconstructingcondenceintervals.Thedefaultis.95thatis,95%condenceintervals.n_bootNumberofbootstrapsamplestouseforbootstrappedcondenceintervals.Thedefaultis1000.progressLogical.Whethertoshowprogressbarsforcomputationofbootstrapcondenceintervals.DefaultisFALSE....Argumentspassedontomice::micemNumberofmultipleimputations.Thedefaultism=5.methodCanbeeitherasinglestring,oravectorofstringswithlengthlength(blocks),specifyingtheimputationmethodtobeusedforeachcolumnindata.Ifspeciedasasinglestring,thesamemethodwillbeusedforallblocks.Thedefaultimputationmethod(whennoargumentisspecied)dependsonthemeasurementlevelofthetargetcolumn,asregulatedbythedefaultMethodargument.Columnsthatneednotbeimputedhavetheemptymethod"".Seedetails.predictorMatrixAnumericmatrixoflength(blocks)rowsandncol(data)columns,containing0/1dataspecifyingthesetofpredictor

8 stobeusedforeachtargetcolumn.Eachrowcorr
stobeusedforeachtargetcolumn.Eachrowcorrespondstoavariableblock,i.e.,asetofvariablestobeimputed.Avalueof1meansthatthecolumnvariableisusedasapredictorforthetargetblock(intherows).Bydefault,thepredictorMatrixisasquarematrixofncol(data)rowsandcolumnswithall1's,exceptforthediagonal.Note:Fortwo-levelimputationmod-els(whichhave"2l"intheirnames)othercodes(e.g,2or-2)arealsoallowed.ignoreAlogicalvectorofnrow(data)elementsindicatingwhichrowsareignoredwhencreatingtheimputationmodel.ThedefaultNULLincludesallrowsthathaveanobservedvalueofthevariabletoimputed.RowswithignoresettoTRUEdonotinuencetheparametersoftheimpu-tationmodel,butarestillimputed.Wemayusetheignoreargumenttosplitdataintoatrainingset(onwhichtheimputationmodelisbuilt) mifa_ci_boot7andatestset(thatdoesnotinuencetheimputationmodelestimates).Note:Multivariateimputationmethods,likemice.impute.jomoImpute()ormice.impute.panImpute(),donothonourtheignoreargument.whereAdataframeormatrixwithlogicalsofthesamedimensionsasdataindicatingwhereinthedatatheimputationsshouldbecreated.Thedefault,where=is.na(data),speciesthatthemissingdatashouldbeimputed.Thewhereargumentmaybeusedtooverimputeobserveddata,ortoskipimputationsforselectedmissingvalues.blocksListofvectorswithvariablenamesperblock.Listelementsmaybenamedtoidentifyblocks.Variableswithinablockareimputedbyamulti-variateimputationmethod(seemethodargument).Bydefaulteachvari-ableisplacedintoitsownblock,whichiseffectivelyfullyconditionalspecication(FCS)byunivariatemodels(variable-by-variableimputation).Onlyvariableswhosenamesappearinblocksareimputed.Therelevantcolumnsinthewhe

9 rematrixaresettoFALSEofvariablesthataren
rematrixaresettoFALSEofvariablesthatarenotblockmembers.Avariablemayappearinmultipleblocks.Inthatcase,itiseffectivelyre-imputedeachtimethatitisvisited.visitSequenceAvectorofblocknamesofarbitrarylength,specifyingthesequenceofblocksthatareimputedduringoneiterationoftheGibbssam-pler.Ablockisacollectionofvariables.Allvariablesthataremembersofthesameblockareimputedwhentheblockisvisited.Avariablethatisamemberofmultipleblocksisre-imputedwithinthesameiteration.ThedefaultvisitSequence="roman"visitstheblocks(lefttoright)intheor-derinwhichtheyappearinblocks.Onemayalsouseoneofthefollowingkeywords:"arabic"(righttoleft),"monotone"(orderedlowtohighpro-portionofmissingdata)and"revmonotone"(reverseofmonotone).formulasAnamedlistofformula's,orexpressionsthatcanbeconvertedintoformula'sbyas.formula.Listelementscorrespondtoblocks.Theblocktowhichthelistelementappliesisidentiedbyitsname,solistnamesmustcorrespondtoblocknames.TheformulasargumentisanalternativetothepredictorMatrixargumentthatallowsformoreexibilityinspecifyingimputationmodels,e.g.,forspecifyinginteractionterms.blotsAnamedlistofalist'sthatcanbeusedtopassdownargumentstolowerlevelimputationfunction.Theentriesofelementblots[[blockname]]arepasseddowntothefunctioncalledforblockblockname.postAvectorofstringswithlengthncol(data)specifyingexpressionsasstrings.Eachstringisparsedandexecutedwithinthesampler()func-tiontopost-processimputedvaluesduringtheiterations.Thedefaultisavectorofemptystrings,indicatingnopost-processing.defaultMethodAvectoroflength4containingthedefaultimputationmethodsfor1)numericdata,2)factordatawith2levels,3)factord

10 atawith�2unorderedlevels,and4)fac
atawith�2unorderedlevels,and4)factordatawith�2orderedlevels.Bydefault,themethodusespmm,predictivemeanmatching(numericdata)logreg,logisticregressionimputation(binarydata,factorwith2levels)polyreg,polytomousregressionimputationforunorderedcategoricaldata(factor�2levels)polr,proportionaloddsmodelfor(ordered,�2levels).maxitAscalargivingthenumberofiterations.Thedefaultis5. 8mifa_ci_bootprintFlagIfTRUE,micewillprinthistoryonconsole.Useprint=FALSEforsilentcomputation.seedAnintegerthatisusedasargumentbytheset.seed()foroffsettingtherandomnumbergenerator.Defaultistoleavetherandomnumbergeneratoralone.data.initAdataframeofthesamesizeandtypeasdata,withoutmissingdata,usedtoinitializeimputationsbeforethestartoftheiterativeprocess.ThedefaultNULLimpliesthatstartingimputationarecreatedbyasimplerandomdrawfromthedata.Notethatspecicationofdata.initwillstartallmGibbssamplingstreamsfromthesameimputation.DetailsThisfunctionusestheShaoandSitter(1996)methodtocombinemultipleimputationandboot-strapping.Theimputationsaredoneusingmice::mice().Normally,thisfunctiondoesnotneedtobecalleddirectly.Instead,usemifa(...,ci="boot").ValueAdataframecontainingbootstrappedcondenceintervalsforvarianceexplainedbydifferentnum-berofprincipalcomponents.ReferencesShao,J.&Sitter,R.R.(1996).Bootstrapforimputedsurveydata.JournaloftheAmericanStatis-ticalAssociation91.435(1996):1278-1288.doi:10.1080/01621459.1996.10476997SeeAlsomifa(),mice::mice()Othermifacondenceintervals:mifa_ci_fieller()Examplesif(requireNamespace("psych")){datapsych::bfi[,1:25]mifa_ci_boot(data,n_pc=3:8,n_boot=10,pr

11 int=FALSE)} mifa_ci_eller9 mifa_ci_f
int=FALSE)} mifa_ci_eller9 mifa_ci_fiellerFiellercondenceintervalsforexplainedvariance DescriptionComputesparametriccondenceintervalsforproportionofexplainedvarianceforgivennumbersofprincipalcomponentsusingFieller'smethod.Notethatbysettingci=TRUEinmifa(),thiscondenceintervalcanbecomputedaswell.Usagemifa_ci_fieller(cov_imps,n_pc,conf=0.95,N)Argumentscov_impsListcontainingtheestimatedcovariancematrixwithineachimputeddata.Onecanusecov_imputationsreturnedbymifa().n_pcIntegerorintegervectorindicatingnumberofprincipalcomponents(eigenvec-tors)forwhichexplainedvariance(eigenvalues)shouldbeobtainedandforwhichcondenceintervalsshouldbecomputed.Defaultstoallprincipalcom-ponents,i.e.,thenumberofvariablesinthedata.confCondencelevelforconstructingcondenceintervals.Thedefaultis.95thatis,95%condenceintervals.NAscalarspecifyingsamplesize.DetailsNormally,thisfunctiondoesnotneedtobecalleddirectly.Instead,usemifa(...,ci="fieller").ValueAdataframecontainingcondenceintervalsforn_pcprincipalcomponents.ReferencesFieller,E.C.(1954).Someproblemsinintervalestimation.JournaloftheRoyalStatisticalSociety.SeriesB(Methodological):175-185.SeeAlsomifa()Othermifacondenceintervals:mifa_ci_boot() 10mifa_ci_ellerExamplesif(requireNamespace("psych")){datapsych::bfi[,1:25]mimifa(data,print=FALSE)mifa_ci_fieller(mi$cov_imputations,n_pc=3:8,N=nrow(data))} Indexmifacondenceintervalsmifa_ci_boot,5mifa_ci_fieller,9dplyr::select(),2,6mice,2,5mice::mice,3,6mice::mice(),2,5,6,8mice::mids,5mifa,2mifa(),8,9mifa_ci_boot,5,9mifa_ci_boot(),2,5mifa_ci_fieller,8,9mifa_ci_fiell

Related Contents


Next Show more