RobStat

  • 格式:pdf
  • 大小:41.54 KB
  • 文档页数:6

RobStatTMPackageVignette

November10,2021

RicardoA.Maronna,R.DouglasMartin,VictorJ.Yohai,MatiasSalibian-Barrera

Abstract

TheRobStatTMRpackageisacompaniontothebookRobustStatistics:TheoryandMethods(withR)bytheauthorsofthisdocument.ThepurposeofthisvignetteistoguideyouonhowtousetheRscriptsandrelateddatasetsinthepackage,whichreplicateexamplesinthebook.AshortSection2onconvergenceofrobustestimationalgorithmsisalsoincluded

1Contents1TheRobStatTMScriptsandDataSets31.1AccessingtheExampleRScriptsinYourInstalledRobStatTM................4

1.2LoadingDataSetsProvidedinRobStatTM..........................4

1.3InstallingOtherPackagesNeededforDataorFunctionsAccess...............5

1.4LoadingDataSetsProvidedinAnotherPackage........................5

1.5UsingFunctionsfromAnotherInstalledPackagewithoutLoadingthePackage.......5

1.6DifferencesBetweentheExampleRScriptsResultsandtheBookExamples.........6

1.7RunningtheExampleScripts..................................6

2ConvergenceofAlgorithmsforComputingRobustEstimates6

21TheRobStatTMScriptsandDataSets

ThefirstcolumnofTable1belowliststhenumberingoftheexamplesinthebook,andthesecondcolumn

containsthenamesinthebookofthecorrespondingRscripts.Thethirdandfourthcolumnsprovidethe

namesofdatasetsusedbythescripts.SomeoftheRscriptsinthetablemakeuseofpackagesotherthan

RobStatTM,foreitheraccessingdata,orforusingcertainRfunctions,andsuchpackagesarelistedinthe

fifthcolumnofthetable.Inordertorunthosescripts,youneedtohavealreadyinstalledthosepackage(s)

fromCRAN(https://cran.r-project.org/).EXAMPLENAMERobStatTMDATAOTHERDATAOTHERPACKAGESREQUIRED4.1shock.Rshockquantreg4.2oats.Roats5.1mineral.Rmineralquantreg5.2wood.Rwoodrobustbase5.3step.Rmadeupdata5.4algae.Ralgae5.5ExactFit.Rsyntheticdata6.1biochem.Rbiochem6.2wine.Rwine6.3vehicle.Rvehiclerrcov6.4bus.Rbus6.5-6.6wine1.RwineGSE6.7autism.RautismWWGbook,robustvarComp,nlme7.1leukemia.Rleuk.datrobust7.2skin.Rskin7.3epilepsy.Rbreslow.datrobust8.1ar1.Rsyntheticdatarobustarima8.2ar3.Rsyntheticdatarobustarima8.3identAR2.Rsyntheticdatarobustarima8.4identMA1.Rsyntheticdatarobustarima8.5MA1-AO.Rsyntheticdatarobustarima8.6resex.Rresexrobustarima

Table1:RScriptsandDataintheRobStatTMRPackage

Wenotethatthescriptflour.R,andthedatasetflourusedbythescript,containedinRobStatTMbut

notlistedintheabovetableareforExample1.1,Figure2.1,andTable2.4ofthebook.Furthermore,the

datasetneuralgiacontainedinRobStatTMbutnotlistedinthetableabove,isusedonlyinProblem7.1

ofthebook.

31.1AccessingtheExampleRScriptsinYourInstalledRobStatTM

IncaseyouhavenotalreadyinstalledRobStatTM,installitwiththecommand:

install.packages("RobStatTM")

WithRobStatTMinstalled,loaditinyourcurrentRsessionwith:

library("RobStatTM")

InordertoaccesstheexampleRscripts,youneedtofindyourinstalledRobStatTM“scripts”folder,whichis

oneofseveralRobStatTMpackagefolders.Youcanfindthelocationofthescriptsfolderonyourcomputer

byusingthefunctionsystem.file()asfollows:

system.file("scripts",package="RobStatTM")

NOTE:Copy/pasteoftheabovelinedoesnottypicallywork,soyoushouldtypeitin.Theresultofusing

thiscommandwilldependuponyourcomputer.Forexample,inthecaseofaparticularcomputerrunning

Windows10,theresultis:

[1]"C:/Users/Doug/Documents/R/win-library/3.4/RobStatTM/scripts"

Thenyoujustneedtonavigatetothescriptsfolder,whereyouwillseealloftheexampleRscripts,with

thesamenametheyaregiveninthebook,i.e.,thenameintheNAMEcolumnofTable1.Youshouldthen

copy/pasteanyscript,orallthescripts,tosomeotherlocationonyourcomputerwhereyouwanttorun

them.

1.2LoadingDataSetsProvidedinRobStatTM

ToloadanydatasetthatisinRobStatTM,justusethedata()functionwiththedatasetname.Forexample,

inthecaseoftheshockdataset:

data(shock)

head(shock,2)

##n.shockstime

##1011.4

##2111.9

41.3InstallingOtherPackagesNeededforDataorFunctionsAccess

YouwillnoticeinthetableonthepreviouspagethatthereisacolumnnamedOTHERPACKAGESRE-

QUIRED.Theotherpackageisrequiredforaccessingadatasetinthepackage,orforusinganRfunction

inthepackage,orboth.InthecaseofanyexampleRscriptthatrequiresanotherpackageforoneofthose

reasons,youneedtohaveinstalledthepackagebeforerunningthescript.Youcoulddothisonacase

bycasebasis,butitmaybeeasiertojustbesureandinstallallthepackagesintheOTHERPACKAGES

REQUIREDonceandforall.YoucandothisquiteeasilyfromRStudio.

1.4LoadingDataSetsProvidedinAnotherPackage

ToloadadatasetthatisinanotherpackagethatyouhavealreadyinstalledinyourR(buthavenotloaded,

andinfactshouldnotload)youusethedata()functionwithanoptionalargumentthatspecifiesthepackage

thedataisin.Forexample,inthecaseofthewooddatasetthatisintherobustbasepackage:

data(wood,package="robustbase")

head(wood,1)

##x1x2x3x4x5y

##10.5730.10590.4650.5380.8410.534

Notethattheaboveuseofdata()doesnotresultinloadingthenamedpackage,andthisistherec-