2bamaRtopicsdocumentedbama2bamadata7fdrbama7printbama ID: 849865
Download Pdf The PPT/PDF document "PackagebamaJanuary212021TitleHighDimensi..." 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.
1 Package`bama'January21,2021TitleHighDime
Package`bama'January21,2021TitleHighDimensionalBayesianMediationAnalysisVersion1.2URLhttps://github.com/umich-cphds/bamaBugReportshttps://github.com/umich-cphds/bama/issuesDescriptionPerformmediationanalysisinthepresenceofhigh-dimensionalmediatorsbasedonthepotentialoutcomeframework.BayesianMediationAnalysis(BAMA),developedbySongetal(2019) oi:;.1;đ/;iom;.131;褀andSongetal(2020) rXi;─v:2009.11409,reliesontwoBayesiansparselinearmixedmodelstosimultaneouslyanalyzearelativelylargenumberofmediatorsforacontinuousexposureandoutcomeassumingasmallnumberofmediatorsaretrulyactive.ThissparsityassumptionalsoallowstheextensionofunivariatemediatoranalysisbycastingtheidenticationofactivemediatorsasavariableselectionproblemandapplyingBayesianmethodswithcontinuousshrinkagepriorsontheeffects.LicenseGPL-3EncodingUTF-8LazyDatatrueRoxygenNote7.1.1LinkingToRcpp,RcppArmadillo,RcppDist,BHImportsRcpp,parallelDependsR rXi;─(=3.5)Suggestsknitr,rmarkdownVignetteBuilderknitrNeedsCompilationyesAuthorAlexanderRix[aut],MikeKleinsasser[aut,cre],YanyiSong[aut]MaintainerMikeKleinsassermkle;insa;@umi;h.e; u00;RepositoryCRANDate/Publication2021-01-2111:20:06UTC1 2bama
2 Rtopicsdocumented:bama..................
Rtopicsdocumented:bama.............................................2bama.data..........................................7fdr.bama...........................................7print.bama..........................................9print.fdr.bama........................................10summary.bama.......................................10summary.fdr.bama......................................11Index12 bamaBayesianMediationAnalysis DescriptionbamaisaBayesianinferencemethodthatusescontinuousshrinkagepriorsforhigh-dimensionalBayesianmediationanalysis,developedbySongetal(2019,2020).bamaprovidesestimatesfortheregressioncoefcientsaswellastheposteriorinclusionprobabilityforrankingmediators.Usagebama(Y,A,M,C1,C2,method,burnin,ndraws,weights=NULL,inits=NULL,control=list(k=2,lm0=1e-04,lm1=1,l=1,lambda0=0.04,lambda1=0.2,lambda2=0.2,phi0=0.01,phi1=0.01,a0=0.01*ncol(M),a1=0.05*ncol(M),a2=0.05*ncol(M),a3=0.89*ncol(M)),seed=NULL)ArgumentsYLengthnnumericoutcomevectorALengthnnumericexposurevectorMnxpnumericmatrixofmediatorsofYandAC1nxnc1numericmatrixofextracovariatestoincludeintheoutcomemodelC2nxnc2numericmatrixofextracovariatestoincludeinthemediatormodel bama3methodStringindicatingwhichmethodtouse
3 .Optionsare"BSLMM"-mixtureoftwonor
.Optionsare"BSLMM"-mixtureoftwonormalcomponents;Songetal.2019"PTG"-productthresholdGaussianprior;Songetal.2020"GMM"-four-componentGaussianmixtureprior;Songetal.2020burninnumberofiterationstoruntheMCMCbeforesamplingndrawsnumberofdrawstotakefromMCMC(includesburnindraws)weightsLengthnnumericvectorofweightsinitslistofinitialvaluesfortheGibbssampler.Optionsarebeta.m-Lengthpnumericvectorofinitialbeta.mintheoutcomemodel.Seedetailsforequationalpha.a-Lengthpnumericvectorofinitialalpha.ainthemediatormodel.SeedetailsforequationcontrollistofGibbsalgorithmcontroloptions.Theseincludepriorandhyper-priorparameters.Optionsvarybymethodselection.Ifmethod="BSLMM"k-Shapeparameterpriorforinversegammalm0-Scaleparameterpriorforinversegammaforthesmallnormalcom-ponentslm1-Scaleparameterpriorforinversegammaforthelargenormalcompo-nentsl-ScaleparameterpriorfortheotherinversegammadistributionsIfmethod="PTG"lambda0-thresholdparameterforproductofalpha.aandbeta.meffectlambda1-thresholdparameterforbeta.meffectlambda2-thresholdparameterforalpha.aeffectha-inversegammashapepriorforsigma.sq.ala-inversegammascalepriorforsigma.sq.a
4 9;h1-inversegammashapepriorforsigma.sq.e
9;h1-inversegammashapepriorforsigma.sq.el1-inversegammascalepriorforsigma.sq.eh2-inversegammashapepriorforsigma.sq.gl2-inversegammascalepriorforsigma.sq.gkm-inversegammashapepriorfortau.sq.blm-inversegammascalepriorfortau.sq.bkma-inversegammashapepriorfortau.sq.alma-inversegammascalepriorfortau.sq.aIfmethod="GMM"phi0-priorbeta.mvariancephi1-prioralpha.avariancea0-priorcountofnon-zerobeta.mandalpha.aeffectsa1-priorcountofnon-zerobeta.mandzeroalpha.aeffectsa2-priorcountofzerobeta.mandnon-zeroalpha.aeffectsa3-priorcountofzerobeta.mandzeroalpha.aeffects 4bamaha-inversegammashapepriorforsigma.sq.ala-inversegammascalepriorforsigma.sq.ah1-inversegammashapepriorforsigma.sq.el1-inversegammascalepriorforsigma.sq.eh2-inversegammashapepriorforsigma.sq.gl2-inversegammascalepriorforsigma.sq.gseednumericseedforGIBBSsamplerDetailsbamausestworegressionmodelsforthetwoconditionalrelationships,YjA;M;CandMjA;C.Fortheoutcomemodel,bamausesY=MM+AA+CC+YForthemediatormodel,bamausesthemodelM=AA+CC+MForhighdimensionaltractability,bamaemployscon
5 tinuousBayesianshrinkagepriorstoselectme
tinuousBayesianshrinkagepriorstoselectmediatorsandmakesthetwofollowingassumptions:First,itassumesthatallthepotentialmedi-atorscontributesmalleffectsinmediatingtheexposure-outcomerelationship.Second,itassumesthatonlyasmallproportionofmediatorsexhibitlargeeffects("active"mediators).bamausesaMetropolis-HastingswithinGibbsMCMCtogenerateposteriorsamplesfromthemodel.ValueIfmethod="BSLMM",thenbamareturnsaobjectoftype"bama"with12elements:beta.mndrawsxpmatrixcontainingoutcomemodelmediatorcoefcients.r1ndrawsxpmatrixindicatingwhetherornoteachbeta.mbelongstothelargernormalcompo-nent(1)orsmallernormalcomponent(0).alpha.andrawsxpmatrixcontainingthemediatormodelexposurecoefcients.r3ndrawsxpmatrixindicatingwhetherornoteachalpha.abelongstothelargernormalcompo-nent(1)orsmallernormalcomponent(0).beta.aVectoroflengthndrawscontainingthebeta.acoefcient.pi.mVectoroflengthndrawscontainingtheproportionofnonzerobeta.mcoefcients.pi.aVectoroflengthndrawscontainingtheproportionofnonzeroalpha.acoefcients.sigma.m0Vectoroflengthndrawscontainingthestandarddeviationofthesmallernormalcom-ponentformediator-outcomecoefcients(beta.m).sigma.m1Vectoroflengthndrawscontainingstandarddeviationofth
6 elargernormalcomponentformediator-outcom
elargernormalcomponentformediator-outcomecoefcients(beta.m).sigma.ma0Vectoroflengthndrawscontainingstandarddeviationofthesmallernormalcompo-nentforexposure-mediatorcoefcients(alpha.a).sigma.ma1Vectoroflengthndrawscontainingstandarddeviationofthelargernormalcomponentforexposure-mediatorcoefcients(alpha.a). bama5callTheRcallthatgeneratedtheoutput.Ifmethod="GMM",thenbamareturnsaobjectoftype"bama"with:beta.mndrawsxpmatrixcontainingoutcomemodelmediatorcoefcients.alpha.andrawsxpmatrixcontainingthemediatormodelexposurecoefcients.betam_memberndrawsxpmatrixof1'sand0'swhereitem=1onlyifbeta.misnon-zero.alphaa_memberndrawsxpmatrixof1'sand0'swhereitem=1onlyifalpha.aisnon-zero.alpha.cndrawsx(q2+p)matrixcontainingalpha_ccoefcients.Sincealpha.cisamatrixofdimensionq2xp,thedrawsareindexedasalpha_c(w,j)=w*p+jbeta.cndrawsxq1matrixcontainingbeta_ccoefcients.Sincebeta.cisamatrixofdimensionq1xpbeta.aVectoroflengthndrawscontainingthebeta.acoefcient.sigma.sq.aVectoroflengthndrawsvarianceofbeta.aeffectsigma.sq.eVectoroflengthndrawsvarianceofoutcomemodelerrorsigma.sq.gVectoroflengthndrawsvarianceofmediatormodelerrorIfmethod="PTG",thenbamareturnsaobjectoftype"bama"with:beta.
7 mndrawsxpmatrixcontainingoutcomemodelmed
mndrawsxpmatrixcontainingoutcomemodelmediatorcoefcients.alpha.andrawsxpmatrixcontainingthemediatormodelexposurecoefcients.alpha.cndrawsx(q2+p)matrixcontainingalpha_ccoefcients.Sincealpha.cisamatrixofdimensionq2xp,thedrawsareindexedasalpha_c(w,j)=w*p+jbeta.cndrawsxq1matrixcontainingbeta_ccoefcients.Sincebeta.cisamatrixofdimensionq1xpbetam_memberndrawsxpmatrixof1'sand0'swhereitem=1onlyifbeta.misnon-zero.alphaa_memberndrawsxpmatrixof1'sand0'swhereitem=1onlyifalpha.aisnon-zero.beta.aVectoroflengthndrawscontainingthebeta.acoefcient.sigma.sq.aVectoroflengthndrawsvarianceofbeta.aeffectsigma.sq.eVectoroflengthndrawsvarianceofoutcomemodelerrorsigma.sq.gVectoroflengthndrawsvarianceofmediatormodelerrorReferencesSong,Y,Zhou,X,Zhang,M,etal.Bayesianshrinkageestimationofhighdimensionalcausalmediationeffectsinomicsstudies.Biometrics.2019;1-11.doi:10.1111/biom.13189Song,Yanyi,XiangZhou,JianKang,MaxT.Aung,MinZhang,WeiZhao,BelindaL.Needhametal."BayesianSparseMediationAnalysiswithTargetedPenalizationofNaturalIndirectEffects."arXivpreprintarXiv:2008.06366(2020). 6bamaExampleslibrary(bama)Ybama.data$yAbama.data$a#grabthemediatorsfromtheexampledata.frameMas.matrix(bama.data[,paste0
8 ("m",1:100)],nrow(bama.data))#Wejustincl
("m",1:100)],nrow(bama.data))#WejustincludetheinterceptterminthisexampleaswehavenocovariatesC1matrix(1,1000,1)C2matrix(1,1000,1)beta.mrep(0,100)alpha.arep(0,100)outbama(Y=Y,A=A,M=M,C1=C1,C2=C2,method="BSLMM",seed=1234,burnin=1000,ndraws=1100,weights=NULL,inits=NULL,control=list(k=2,lm0=1e-04,lm1=1,l=1))#Thepackageincludesafunctiontosummariseoutputfrom'bama'summarysummary(out)head(summary)#ProductThresholdGaussianptgmod=bama(Y=Y,A=A,M=M,C1=C1,C2=C2,method="PTG",seed=1234,burnin=1000,ndraws=1100,weights=NULL,inits=NULL,control=list(lambda0=0.04,lambda1=0.2,lambda2=0.2))mean(ptgmod$beta.a)apply(ptgmod$beta.m,2,mean)apply(ptgmod$alpha.a,2,mean)apply(ptgmod$betam_member,2,mean)apply(ptgmod$alphaa_member,2,mean)#GaussianMixtureModelgmmmod=bama(Y=Y,A=A,M=M,C1=C1,C2=C2,method="GMM",seed=1234,burnin=1000,ndraws=1100,weights=NULL,inits=NULL,control=list(phi0=0.01,phi1=0.01))mean(gmmmod$beta.a)apply(gmmmod$beta.m,2,mean)apply(gmmmod$alpha.a,2,mean)mean(gmmmod$sigma.sq.a)mean(gmmmod$sigma.sq.e)mean(gmmmod$sigma.sq.g) bama.data7 bama.dataSyntheticexampledataforbama DescriptionSyntheticexampledataforbamaUsagebama.dataFormatAdata.framewith1000observationson102variables:yNumericresponsevariable
9 .aNumericexposurevariable.m[1-100]Numeri
.aNumericexposurevariable.m[1-100]Numericmediatorvariables fdr.bamaBayesianMediationAnalysisControllingForFalseDiscovery Descriptionfdr.bamausesthepermutationtesttoestimatethenullPIPdistributionforeachmediatoranddeterminesathreshold(basedoffofthefdrparameter)forsignicance.Usagefdr.bama(Y,A,M,C1,C2,beta.m,alpha.a,burnin,ndraws,weights=NULL,npermutations=200,fdr=0.1,k=2,lm0=1e-04,lm1=1, 8fdr.bamal=1,mc.cores=1,type="PSOCK")ArgumentsYLengthnnumericoutcomevectorALengthnnumericexposurevectorMnxpnumericmatrixofmediatorsofYandAC1nxnc1numericmatrixofextracovariatestoincludeintheoutcomemodelC2nxnc2numericmatrixofextracovariatestoincludeinthemediatormodelbeta.mLengthpnumericvectorofinitialbeta.mintheoutcomemodelalpha.aLengthpnumericvectorofinitialalpha.ainthemediatormodelburninNumberofiterationstoruntheMCMCbeforesamplingndrawsNumberofdrawstotakefromMCMCaftertheburninperiodweightsLengthnnumericvectorofweightsnpermutationsThenumberofpermutationstogeneratewhileestimatingthenullpipdistribu-tion.Defaultis200fdrFalsediscoveryrate.Defaultis0.1kShapeparameterpriorforinversegamma.Defaultis2.0lm0Scaleparameterpriorforinversegammaforthesmallnormalcomponents.De-faultis1e-4lm1Scaleparameterpriorfo
10 rinversegammaforthelargenormalcomponents
rinversegammaforthelargenormalcomponents.De-faultis1.0lScaleparameterpriorfortheotherinversegammadistributions.Defaultis1.0mc.coresThenumberofcorestousewhilerunningfdr.bama.fdr.bamausestheparallelpackageforparallelization,soseethatformoreinformation.Defaultis1coretypeTypeofclustertomakewhenmc.cores1.SeemakeClusterintheparallelpackageformoredetails.Defaultis"PSOCK"Valuefdr.bamareturnsaobjectoftype"fdr.bama"with5elements:bama.outOutputfromthebamarun.pip.nullApxnpermutationsmatricescontainingtheestimatednullPIPdistributionforeachmediator.thresholdThecutoffsignicancethresholdforeachPIPcontrollingforthefalsediscoveryrate.fdrThefalsediscoveryrateusedtocalculatethreshold.callTheRcallthatgeneratedtheoutput. print.bama9Author(s)AlexanderRixReferencesSong,Y,Zhou,X,Zhang,M,etal.Bayesianshrinkageestimationofhighdimensionalcausalmediationeffectsinomicsstudies.Biometrics.2019;1-11.doi:10.1111/biom.13189Exampleslibrary(bama)Ybama.data$yAbama.data$a#grabthemediatorsfromtheexampledata.frameMas.matrix(bama.data[,paste0("m",1:100)],nrow(bama.data))#WejustincludetheinterceptterminthisexampleaswehavenocovariatesC1matrix(1,1000,1)C2matrix(1,1000,1)beta.mrep(0,100)alpha.arep(0,100)set.seed
11 (12345)outfdr.bama(Y,A,M,C1,C2,beta.m,al
(12345)outfdr.bama(Y,A,M,C1,C2,beta.m,alpha.a,burnin=100,ndraws=120,npermutations=10)#Thepackageincludesafunctiontosummariseoutputfrom'fdr.bama'summary(out) print.bamaPrintingbamaobjects DescriptionPrintabamaobject.Usage##S3methodforclass'bama'print(x,...)ArgumentsxAnobjectofclass'bama'....Additionalargumentstopasstoprint.data.frameorsummary.bama 10summary.bama print.fdr.bamaPrintingbamaobjects DescriptionPrintabamaobject.Usage##S3methodforclass'fdr.bama'print(x,...)ArgumentsxAnobjectofclass'bama'....Additionalargumentstopasstoprint.data.frameorsummary.bama summary.bamaSummarizeobjectsoftype"bama" Descriptionsummary.bamasummarizesthe'beta.m'estimatesfrombamaandgeneratesanoverallestimate,credibleinterval,andposteriorinclusionprobability.Usage##S3methodforclass'bama'summary(object,rank=F,ci=c(0.025,0.975),...)ArgumentsobjectAnobjectofclass"bama".rankWhetherornottoranktheoutputbyposteriorinclusionprobability.DefaultisTRUE.ciThecredibleintervaltocalculate.cishouldbealength2numericvectorspeci-fyingtheupperandlowerboundsoftheCI.Bydefault,ci=c(0.025,.975)....AdditionaloptionalargumentstosummaryValueAdata.framewith4elements.Thebeta.mestimates,theestimates'credibleinterval(whichbydefault
12 is95\inclusionprobability(pip)ofeach'bet
is95\inclusionprobability(pip)ofeach'beta.m'. summary.fdr.bama11 summary.fdr.bamaSummarizeobjectsoftype"fdr.bama" Descriptionsummary.fdr.bamasummarizesthebeta.mestimatesfromfdr.bamaandforeachmediatorgen-eratesanoverallestimate,credibleinterval,posteriorinclusionprobability(PIP),andPIPthresholdforsignicancecontrollingforthespeciedfalsediscoveryrate(FDR).Usage##S3methodforclass'fdr.bama'summary(object,rank=F,ci=c(0.025,0.975),fdr=object$fdr,filter=T,...)ArgumentsobjectAnobjectofclass"bama".rankWhetherornottoranktheoutputbyposteriorinclusionprobability.DefaultisTRUE.ciThecredibleintervaltocalculate.cishouldbealength2numericvectorspeci-fyingtheupperandlowerboundsoftheCI.Bydefault,ci=c(0.025,.975).fdrFalsediscoveryrate.Bydefault,itissettowhateverthefdrofobjectis.However,itcanbechangedtorecalculatethePIPcutoffthreshold.filterWhetherornottolteroutmediatorswithPIPlessthanthePIPthreshold....AdditionaloptionalargumentstosummaryValueAdata.framewith4elements.Thebeta.mestimates,theestimates'credibleinterval(whichbydefaultis95\inclusionprobability(pip)ofeach'beta.m'. Indexdatasetsbama.data,7bama,2bama.data,7fdr.bama,7print.bama,9print.fdr.bama,10summary.bama,10summary.fdr.bama