JSSJournalofStatisticalSoftwareMay2010,Volume34,Issue9.:amultivariatetestofrandomnessfollowedbyatestofmutualindependenceandaseriesofgoodness-of-ttests.Allthetestsunderconsiderationarebasedontheempiricalcopula,whichisanonparametricrank-basedestimatorofthetrueunknowncopula.TheprinciplesofthetestsarerecalledandtheirimplementationinthecopulaRpackageisbrieydescribed.Theiruseintheconstructionofacopulamodelfromdataisthoroughlyillustratedonrealinsuranceandnancialdata.Keywords:goodnessoft,multivariateindependence,pseudo-observations,rank-basedtests,serialindependence.1.IntroductionCopulasarebeingincreasinglyusedtomodelmultivariatedistributionswithcontinuousmar-ginsineldssuchashydrology(Salvadori,Michele,Kottegoda,andRosso2007),actuarialsciences(FreesandValdez1998)ornance(Cherubini,Vecchiato,andLuciano2004;Mc-Neil,Frey,andEmbrechts2005).Thequiterecententhusiasmfortheuseofthismodelingapproach(seee.g.,Genest,Gendron,andBourdeau-Brien2009a,forananalysisofthisphe-nomenominnance)ndsitsorigininanelegantrepresentationtheoremduetoSklar(1959).LetX=(X1;:::;Xd)bearandomvectorwithcontinuousmarginalcumulativedistributionfunctions(c.d.f.s)F1;:::;Fd.Sklar(1959)showedthatthec.d.f.HofXcanberepresentedasH(x)=CfF1(x1);:::;Fd(xd)g;x2Rd;(1)intermsofauniquefunctionC:[0;1]d![0;1]calledacopula,whichismerelyad-dimensionalc.d.f.withstandarduniformmargins.2ModelingMultivariateDistributionswithContinuousMarginsUsingcopulaTheaiminmanyapplicationsistoestimatetheunknownc.d.f.HfromavailabledataX1;:::;Xn.Sklar'srepresentationthensuggestsbreakingtheconstructionofamodelforHintotwoparts:theestimationofthemarginalc.d.f.sF1;:::;Fd,andtheestimationofthecopulaC.AsamodelforC,onecouldforinstanceconsidertheGumbel-Hougaardfamilyofcopulas,parameterizedbyareal1,anddenedbyCGu(u)=exp0@ dXi=1f log(ui)g#1=1A;u2[0;1]d;orthenormalcopulafamily,parameterizedbyacorrelationmatrix,anddenedbyCN(u)=f 1(u1);:::; 1(ud)g;u2[0;1]d;whereandarethec.d.f.softhemultivariatestandardnormalwithcorrelationandtheunivariatestandardnormal,respectively.AcomprehensivelistofcopulafamiliescanbefoundinJoe(1997)andNelsen(2006).Anexcellentreviewoftheconceptsandstatisticalissuesinvolvedinthepreviouslymentionedmodel-buildingisgiveninGenestandFavre(2007).Inparticular,inthelatterpaperasinanincreasingproportionoftheliterature,itisarguedthattheestimationofCshouldbesolelybasedonthevectorsofranksR1;:::;Rn,whereRi=(Ri1;:::;Rid)andRijistherankofXijamongX1j;:::;Xnj.TheuseofranksmakestheestimationofCmargin-free,whichimpliesthatamisspecicationofoneofthemarginalsF1;:::;Fdwillhavenoconsequencesonthecopulaestimate(seee.g.,FermanianandScaillet2005;Kim,Silvapulle,andSilvapulle2007,forempiricalargumentsinfavoroftheuseofranks).Theaimofthisarticleistopresenthowallthestepsinvolvedinsucharank-basedestimationofCcanbepracticallycarriedoutinR(RDevelopmentCoreTeam2009)usingthecopulapackage(YanandKojadinovic2010),whichisavailablefromtheComprehensiveRArchiveNetworkat=copula.Aswecontinue,wewillassumethatthedataathandconsistofncopiesX1;:::;XnoftherandomvectorXwhosec.d.f.Hadmitsrepresentation(1).TherstpracticalstepintheconstructionofamodelforCistotestwhetherX1;:::;Xnaremutuallyindependent,i.e.,iftheycanberegardedasarandomsamplefromH.Thisisofparticularimportanceineldssuchasnancewherethedataaretypicallytimeseries.Ifthei.i.d.hypothesisisrejected,onemayattempttotatimeseriesmodeltoeachmarginandworkontheresiduals.Whendealingwithnanciallog-returns,GARCHmodelsareafrequentchoiceforattemptingtoremoveserialdependenceinthecomponenttimeseries,asdiscussedinGregoire,Genest,andGendron(2008)andGiacomini,Hardle,andSpokoiny(2009).Ifthei.i.d.hypothesisisnotrejected,asensiblesecondstepistotestagainstthepresenceofdependenceamongthecomponentsofX.Inthecontextunderconsideration,thisamountstotestingH0:C=againstH1:C6=;where(u)=Qdi=1ui,u2[0;1]d,istheindependencecopula.Ifindependenceisrejected,atypicalnextstepistotanappropriateparametriccopulafamilytotheavailabledata.Inpractice,thisamountstoperforminggoodness-of-ttestsoftheformH0:C2CagainstH1:C62C;JournalofStatisticalSoftware3forseveralparametricfamiliesC=fCg.Thenalstepinvolveschoosingoneofthecandidatefamiliesthatwerenotrejected,ifany,andpossiblyprovidingstandarderrorsfortheparameterestimates.AllthestepsmentionedabovecanbecarriedoutbymeansofthecopulaRpackage.ThebasicfunctionalitiesofthepackageweredescribedinYan(2007).Sincethen,signicantdevelopmenthasbeenaddedtothepackagewhichenablestheuser,amongotherthings,toperformtestsofindependence,serialindependenceandgoodnessoft.Animportantbuildingblockofthetestsunderconsiderationistheempiricalcopulaofthedata(Deheuvels1979,1981b)whichisaconsistentestimatoroftheunknowncopulaC.Let^U1;:::;^Unbepseudo-observationsfrom