2ACVSACVSAutocovariancesequenceDescriptionCalculatestheautocovariancesequenceforaninputtimeseriesUsageACVSxbiasedTRUEcenterTRUEArgumentsxanumericvectorrepresentingauniformlysampledrealvaluedtimeserie ID: 861962
Download Pdf The PPT/PDF document "PackagesapaMarch312021TitleSpectralAnaly..." 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`sapa'March31,2021TitleSpectralAn
Package`sapa'March31,2021TitleSpectralAnalysisforPhysicalApplicationsVersion2.0-3DependsR(=3.0.2)DescriptionSoftwareforbookSpectralAnalysisforPhysicalApplications,DonaldB.PercivalandAndrewT.Walden(1993), oi:;.1;/;ËO9;砅ᅢ❢CambridgeUniversityPress.Containsfunctionalityfornonparametricspectraldensityestimationoftimeseries,includingdirectspectralestimators,lagwindowestimators,estimatorsbasedonWelchsoverlappedsegmentaveraging(WOSA)andmultitaperestimatorsbasedondiscreteprolatespheroidalsequences(DPSS)andonsinusoidaltapers.LicenseGPL-2Importsifultools oi:;.1;/;ËO9;砅ᅢ❢(=2.0-22),splus2R oi:;.1;/;ËO9;砅ᅢ❢(=1.3-3),methodsNeedsCompilationyesAuthorDonaldPercival[cre,aut],WilliamConstantine[aut]MaintainerDonaldPercivalÛpe;rciv; l@g;mail;.com;RepositoryCRANDate/Publication2021-03-3113:20:03UTCRtopicsdocumented:ACVS............................................2SDF.............................................3taper.............................................7Index111 2ACVS ACVSAutocovariancesequence DescriptionCalculatestheautocovariancesequenceforaninputtimeseries.UsageACVS(x,biased=TRUE,center=TRUE)Argumentsxanumericvectorrepresentingauniformlysampledreal-valuedtimeseries.biasedalogicalvalue.IfTRUE,thebiasedestimator(normalizedbyN,thenumberofsamplesinthetimeseries)isreturned.IfFALSE,theresultistheunbiasedestimator(thekthACVSvalueisnormalizedbyNjkjfortheunbiasedcasewherek=0;:::;N1).Default:TRUE.centeralogicalvalue.IfTRUE,theseriesisrstcentered(samplemeanissubtractedfrom
2 series)priortocalculatingtheACVS.Default
series)priortocalculatingtheACVS.Default:TRUE.Valueanumericvectorcontainingthesingle-sidedACVSforlagsk=0;:::;N1whereNisthelengthoftheinputtimeseries.SeeAlsoSDF.Examples##calculatetheACVSforanN(0,1)realizationplot(seq(0,99),ACVS(rnorm(100)),type="l",lwd=2,xlab="lag",ylab="ACVS(rnorm(100))")ifultools::gridOverlay() SDF3 SDFNonparametric(cross)spectraldensityfunctionestimation DescriptionEstimatetheprocess(cross)spectraldensityfunctionvianonparametricmodels.UsageSDF(x,method="direct",taper.=NULL,window=NULL,n.taper=5,overlap=0.5,blocksize=NULL,single.sided=TRUE,sampling.interval=NULL,center=TRUE,recenter=FALSE,npad=2*numRows(x))Argumentsxavectorormatrixcontaininguniformly-sampledreal-valuedtimeseries.Ifamatrix,eachcolumnshouldcontainadifferenttimeseries.blocksizeanintegerrepresentingthenumberofpoints(width)ofeachblockintheWOSAestimatorscheme.Default:floor(N/4)whereNisthenumberofsamplesineachseries.centeralogicalvalue.IfTRUE,themeanofeachtimeseriesisrecenteredpriortoestimatingtheSDF.Default:TRUE.methodacharacterstringdenotingthemethodtouseinestimatingtheSDF.Choicesare"direct","lagwindow","wosa"(Welch'sOverlappedSegmentAveraging),"multitaper".SeeDETAILSformoreinformation.Default:"direct".n.taperanintegerdeningthenumberoftaperstouseinamultitaperscheme.Thisvalueisoverwrittenifthetaperinputisofclasstaper.Default:5.npadanintegerrepresentingthetotallengthofeachtimeseriestoanalyzeafterpaddingwithzeros.Thisargumentallowstheusertocontrolthespectralresolu-tionoftheSDFestimates:thenormalizedfrequencyintervalisf=1=npad.Thisargumentmustbesetsuchthatnpad2.Default:2*numRows(x).over
3 lapanumericvalueon[0;1]denotingthefracti
lapanumericvalueon[0;1]denotingthefractionofwindowoverlapfortheWOSAestimator.Default:0.5.recenteralogicalvalue.IfTRUE,themeanofeachtimeseriesisrecenteredafter(posssi-bly)taperingtheseriespriortoestimatingtheSDF.Default:FALSE.sampling.intervalanumericvaluerepresentingtheintervalbetweensamplesintheinputtimeseriesx.Default:NULL,whichservesasaagtoobtainthesamplingin-tervalviathedeltatfunction.Ifxisalist,thedefaultsamplingintervalisdeltat(x[[1]]).Ifxisanatomicvector(alaisVectorAtomic),thenthede-faultsamplignintervalisestablishedaladeltat(x).Finally,iftheinputseriesisamatrix,thesamplingintervaloftherstseries(assumedtobeintherstcolumn)isobtainedaladeltat(x[,1]). 4SDFsingle.sidedalogicalvalue.IfTRUE,asingle-sidedSDFestimateisreturnedcorrespond-ingtothenormalizedfrequencyrangeof[0;1=2].Otherwise,adouble-sidedSDFestimatecorrespondingtothenormalizedfrequencyinterval[1=2;1=2]isreturned.Default:TRUE.taper.anobjectofclasstaperoracharacterstringdenotingtheprimarytaper.Ifanobjectofclasstaper,thelengthofthetaperischeckedtoensurecompatitbilitywiththeinputx.SeeDETAILSformoreinformation.Thedefaultvaluesareafunctionofthemethodasfollows:directnormalizedrectangulartaperlagwindownormalizedParzenwindowwithacutoffatN=2whereNisthelengthofthetimeseries.wosanormalizedHanningtapermultitapernormalizedHanningtaperwindowanobjectofclasstaperoracharacterstringdenotingthe(secondary)windowforthelagwindowestimator.Ifanobjectofclasstaper,thelengthofthetaperischeckedtoensurecompatitbilitywiththeinputx.SeeDETAILSformoreinformation.Default:NormalizedHanningwindow.DetailsLetXtbeauniformlysampledreal-valuedtim
4 eseriesoflengthN,Letanestimateoftheproce
eseriesoflengthN,Letanestimateoftheprocessspectraldensityfunctionbedenotedas^SX(f)wherefarefrequenciesontheinterval[1=(2t);1=(2t)]wheretisthesamplinginterval.ThesupportedSDFestimatorsare:directThedirectSDFestimatorisdenedas^S(d)X(f)=jPN1t=0htXtei2ftj2,wherefhtgisadatatapernormalizedsuchthatPN1t=0h2t=1.Ifht=1=p Nthenweobtainthedenitionoftheperiodogram^S(p)X(f)=1 NjPN1t=0Xtei2ftj2.Seethetaperfunctionformoredetailsonsupportedwindowtypes.lagwindowThelagwindowSDFestimatorisdenedas^S(lw)X(f)=PN1=(N1)w^s(d)X;ei2f,where^s(d)X;istheautocovariancesequenceestimatorcorrespondingtosomedirectspectralestimator(oftentheperiodogram)andwisalagwindow(popularchoicesaretheParzen,Papoulis,andDaniellwindows).Seethetaperfunctionformoredetails.wosaWelch'sOverlappedSegmentAveragingSDFestimatorisdenedas^S(wosa)=1 NBNB1Xj=0^S(d)jNO(f)where^S(d)l(f)NS1Xt=0htXt+lei2ft2;0lNNS;Here,NOisapositiveintegerthatcontrolshowmuchoverlapthereisbetweensegmentsandthatmustsatisfybothNONSandNO(NB1)=NNS,whilefhtgisadatataperappropriateforaseriesoflengthNS(i.e.,PNS1t=0h2t=1). SDF5multitaperAmultitaperspectralestimatorisgivenby^S(mt)X(f)=1 KK1Xk=0N1Xt=0hk;tXtei2ft2;whereS(k;f)=jPN1t=0hk;tXtexp(i2ft)j2andfhk;tg,k=0;:::;K1,isasetofKorthonormaldatatapers.N1Xt=0hk;thk0;t=1;ifk=k0;0;otherwisePopularchoicesformultitapersincludesinuso
5 idaltapersanddiscreteprolatespheroidalse
idaltapersanddiscreteprolatespheroidalse-quences(DPSS).Seethetaperfunctionformoredetails.Crossspectraldensityfunctionestimation:Iftheinputxisamatrix,whereeachcolumncontainsadifferenttimeseries,thentheresultsarereturnedinamatrixwhosecolumnscorrespondtoallpossibleuniquecombinationsofcross-SDFestimates.Forexample,ifxhasthreecolumns,thentheoutputwillbeamatrixwhosecolumnsarefS11;S12;S13;S22;S23;S33gwhereSijisthecross-SDFestimateoftheithandjthcolumnofx.Allcross-spectraldensityfunctionestimatesarereturnedascomplex-valuedseriestomaintainthephaserelationshipsbetweencomponents.ForallSijwherei=j,however,theimaginaryportionswillbezero(uptoanumericalnoiselimit).ValueanobjectofclassSDF.S3METHODSas.matrixconvertsthe(cross-)SDFestimate(s)asamatrix.Optionalargumentsarepasseddirectlytothematrixfunctionduringtheconversion.plotplotsthe(cross-)SDFestimate(s).Optionalargumentsare:xscaleacharacterstringdeningthescalingtoperformonthe(common)frequencyvec-toroftheSDFestimates.SeethescaleDatafunctionforsupportedchoices.Default:"linear".yscaleacharacterstringdeningthescalingtoperformontheSDFestimates.SeethescaleDatafunctionforsupportedchoices.Default:"linear".typeasinglecharacterdeningtheplottype(alatheparfunction)oftheSDFplots.Default:ifelse(numRows(x)100,"l","h").xlabacharacterstringrepresentingthex-axislabel.Default:"FREQUENCY(Hz)".ylaba(vectorof)characterstring(s),oneper(cross-)SDFestimate,representingthey-axislabel(s).Default:inthemultivariatecase,thestrings"Sij"areusedforthey-axislabels,whereiandjaretheindicesofthedifferentvariables.Forexample,iftheusersuppliesa2-columnmatrixforx,thel
6 abels"S11","S12",and"S22"areusedtolabelt
abels"S11","S12",and"S22"areusedtolabelthey-axesofthecorresponding(cross-)SDFplots.Intheunivariatecase,thedefaultstring"SDF"prependedwithastringdescribingthetypeofSDFperformed(suchas"Multitaper")isusedtolabelthey-axis. 6SDFplot.meanalogicalvalue.IfTRUE,theSDFvalueatnormalizedfrequencyf=0isplottedforeachSDF.Thisfrequencyisassociatedwiththesamplemeanofthecorrespondingtimeseries.Arelativelylargemeanvaluedominatesthespectralpatternsinaplotandthusthecorrespondingfrequencyistypicallynotplotted.Default:!attr(x,"center").n.plotanintegerdeningthemaximumnumberofSDFplotstoplaceontoasinglegraph.Default:3.FUNapostprocessingfunctiontoapplytotheSDFvaluespriortoplotting.SupportedfunctionsareMod,Im,ReandArg.Seeeachofthesefunctionsfordetails.IftheSDFispurelyreal(nocross-SDFiscalculated),thisargumentiscoercedtotheModfunction.Default:Mod.addAlogicalvalue.IfTRUE,theplotisaddedusingthecurrentpar()layout.Otherwiseanewplotisproduced.Default:FALSE....additionalplotparameterspasseddirectlytothegenPlotfunctionusedtoplottheSDFestimates.printprintstheobject.Availableoptionsare:justifytextjusticationalaprettPrintList.Default:"left".sepheaderseparatoralaprettyPrintList.Default:":"....AdditionalprintargumentssentdirectlytotheprettyPrintListfunction.ReferencesPercival,DonaldB.andConstantine,WilliamL.B.(2005)ExactSimulationofGaussianTimeSeriesfromNonparametricSpectralEstimateswithApplicationtoBootstrapping",JournalofCom-putationalandGraphicalStatistics,acceptedforpublication.D.B.PercivalandA.Walden(1993),SpectralAnalysisforPhysicalApplications:MultitaperandConventionalUnivariateTechniques,CambridgeUniv
7 ersityPress,Cambridge,UK.SeeAlsotaper,AC
ersityPress,Cambridge,UK.SeeAlsotaper,ACVS.Examples##calculatevariousSDFestimatesforthe##sunspotsseries.removemeancomponentfora##bettercomparison.require(ifultools)dataas.numeric(sunspots)methodsc("direct","wosa","multitaper","lagwindow")Slapply(methods,function(x,data)SDF(data,method=x),data)xattr(S[[1]],"frequency")[-1]ylapply(S,function(x)decibel(as.vector(x)[-1]))names(y)methods##createastackplotofthedatastackPlot(x,y,col=1:4) taper7##calculatethecross-spectrumofthesame##series:allspectrashouldbethesamein##thiscaseSDF(cbind(data,data),method="lag")##calculatetheSDFusingnpad=31SDF(data,npad=31,method="multitaper") taperOraclefunctionforobtainingaparticulartaper/window DescriptionDevelopsignalprocessingtapersorwindows.Usagetaper(type="rectangle",n.sample=100,n.taper=NULL,sigma=0.3,beta=4*pi*(n.sample-1)/n.sample,cutoff=floor(n.sample/2),sidelobedB=80,roughness=n.sample/2,flatness=0.3,bandwidth=4,normalize=TRUE)ArgumentsbandwidthbandwidthforDPSStapers.SeeDetailsformoreinformation.Default:4.betakaiserwindowshapefactor(mustbepositiveorzero).SeeDetailsformoreinformation.Default:4*pi*(n.sample-1)/n.sample.cutoffparzenorPapouliswindowcutoff(mustbegreaterthanunity).SeeDetailsformoreinformation.Default:floor(n.sample/2).flatnessraisedcosinetaperatnessfraction(mustbeon[0,1]).SeeDetailsformoreinformation.Default:0.3.n.sampleanintegerdenotingthenumberofsamples.Default:1000.n.taperanintegerdeningthemultitaperorder(numberoforthogonaltapers)touseinamultitaperscheme.ThetaperorderdirectlyimpactsthequalityoftheSDFestimate.LowtaperordersareusuallyassociatedwithSDFestimateswithlowbiasandhigh
8 variance,whilehightaperordersattenuateth
variance,whilehightaperordersattenuatethevarianceoftheestimateattheriskofincurringalargebias.ThistradeoffbetweenbiasandvarianceisunavoidablebuttaperorderallowsyoutotunetheSDFtomeettheneedsofyourapplication.Studiesshowthatamultitaperorderof5typicallyprovidesagoodbalancewithreasonablylowbiasandvarianceproperties(seethereferencesformoredetails).Default:NULL,whichservesasaagtosetthedefaulttaperorderdependingonthetypeoftaperchosenfortheanalysis.Ifsineordpssmultitapersarechosen,thedefaulttaperorderis5,otherwiseissettounity. 8tapernormalizealogicalvalue.IfTRUE,thetaperisnormalizedtohaveunitenergy.Default:TRUE.roughnessdaniellwindownroughnessfactor(mustbepositive).SeeDetailsformoreinformation.Default:n.sample/2.sidelobedBchebyshevsidelobedBbandwidthindecibels(mustbepositive).SeeDetailsformoreinformation.Default:80.sigmastandarddeviationforGuassiantaper.Default:0.3.typeacharacterstringdenotingthetypeoftapertocreate.Supportedtypesare"rectangle","triangle","raisedcosine","hanning","hamming","blackman","nuttall","gaussian","kaiser","chebyshev","bornjordan","sine","parzen","papoulis","daniell",and"dpss".SeeDetailsformoreinfor-mation.Default:"rectangle".DetailsLetw()andh(t)fort=0,...,N-1bealagwindowandtaper,respectively.Thefollowinglagwindowortapertypesaresupported.rectangularArectangulartaperisdenedasht=1.triangleAtriangulartaperisdenedasht=hNt1=2(t+1)=(N+1)fortMwhereM=bN=2candhM=1ifNisevenlydivisibleby2.raisedcosineAraisedcosineisasymmetrictaperwithaatmid-plateau.Letp2[0;1]bethefractionofthelengthofthetaperthatisat,M=bpNc,and=2=(M+1).Araisedcosinetaperi
9 sdenedasht=hNt1=0:5(1cos
sdenedasht=hNt1=0:5(1cos((t+1)))for0tbM=2cht=1forbM=2ctNbM=2c:hanningLet=2=(N+1).AHanningtaperisdenedasht=0:5(1cos((t+1))).hammingLet=2=(N1).AHammingtaperisdenedasht=0:540:46cos(t).blackmanLet=2=(N+1).ABlackmantaperisdenedasht=0:420:5cos((t+1))+0:08cos(2(t+1)).nuttallLet=2=(N1).ANuttalltaperisdenedasht=0:36358190:4891775cos(t)+0:1365995cos(2t)0:0106411cos(3t)gaussianLetbethestandarddeviationofaGaussiandistribution.Let(t)=2(0:5t=(N1)).AGaussiantaperisdenedasht=hNt1=eB2=2for0tbN=2c.hN=2=1ifNisevenlydivisibleby2.kaiserLetVt=(2t1N)=NandI0()bethezeroth-ordermodiedBesselfunctionoftherstkind.Giventheshapefactor]TJ/;༔ ; .96;& T; 16;.881; 0 T; [0;0,aKaisertaperisdenedasht=I0(p 1V2t)=I0(). taper9chebyshevTheDolph-ChebyshevtaperisafunctionofboththedesiredlengthNandthedesiredsidelobelevel(ourroutineacceptsasidelobeattenuationfactorexpressedindecibels).SeetheMitrareferenceformoredetails.bornjordanLetM=(N1)=2.ABorn-Jordantaperisdenedasht==hNt1=1=(Mt+1).sineSinemultitapersaredenedashk;t=2 N+11=2sin(k+1)(t+1) N+1;fort=0,...,N-1andk=0,...,..Thissimpleequationdenesagoodapproximationtothediscreteprolatespheroidalsequences(DPSS)usedinmultitaperSDFestimationschemes.parzenAParzenlagwindowisdenedasw;m=8:16(t=m)2+6(jtj=m)3;jtjm=2;2(1jtj=m)3;m=2jtjm=2;0;otherwise:
10 for(N1)(N1).T
for(N1)(N1).Thevariablemisreferredtoasthecutoffsinceallvaluesbeyondthatpointarezero.papoulisAPapoulislagwindowisdenedasw;m=1 jsin(=m)j+(1jj=m)cos(=m);jjm;0;jjmfor(N1)(N1).Thevariablemisreferredtoasthecutoffsinceallvaluesbeyondthatpointarezero.daniellADanielllagwindowisdenedasw;m=(sin(=m) =m;jjN;0;jjNfor(N1)(N1).Thevariablemisreferredtoastheroughnessfactor,since,inthecontextofspectraldensityfunction(SDF)estimation,itcontrolsthedegreeofaveragingthatisperformedonthepreliminarydirectSDFestimate.Thesmallertheroughness,thegreatertheamountofsmoothing.dpssDiscreteprolatespheroidalsequencesare(typically)usedformultitaperspectraldensityfunc-tionestimation.TherstorderDPSScanbedened(toagoodapproximation)asht;0=CI0fWp 1(1gt)2=I0(fW)fort=1;:::;N,whereCisascalingconstantusedtoforcethenormalizationPh2t;k=1;fW=W(N1)twheretisthesamplinginterval;gt=(2t1)=N;andI0()isthemodiedBesselfunctionoftherstkindandzerothorder.TheparameterWisrelatedtotheresolutionbandwidthsinceitroughlydenesthedesiredhalf-widthofthecentrallobeoftheresultingspectralwindow.HigherorderDPSStapers(i.e.,ht;kfork0)canbecalculatedusingarelativelysimpletridiagonalizationformulation(seethereferencesformoreinformation).Finally,wenotethatthesamplingintervaltcanbesettounitywithoutanylossofgenerality. 10taperValueanobjectofclasstaper.S3METHODSas.matrixconvertsoutputtoamatrix.plotplots
11 theoutput.Optionalargumentsare:ylabChara
theoutput.Optionalargumentsare:ylabCharacterstringdenotingthey-axislabelfortheplot.Default:upperCase(attr(x,"type")).typeLinetype(sameasthetypeargumentoftheparfunction).Default:"l"....Additionalplotarguments(setinternallybytheparfunction).printprintsasummaryoftheoutputobject.ReferencesA.T.Walden,AccurateApproximationofa0thOrderDiscreteProlateSpheroidalSequenceforFilteringandDataTapering",SignalProcessing,18,3418(1989).Percival,DonaldB.andConstantine,WilliamL.B.(2005)ExactSimulationofGaussianTimeSeriesfromNonparametricSpectralEstimateswithApplicationtoBootstrapping",JournalofCom-putationalandGraphicalStatistics,acceptedforpublication.D.B.PercivalandA.Walden(1993),SpectralAnalysisforPhysicalApplications:MultitaperandConventionalUnivariateTechniques,CambridgeUniversityPress,Cambridge,UK.S.K.Mitra,J.Kaiser(1993),HandbookforDigitalSignalProcessing,JohnWileyandSons,Inc.SeeAlsotaper.Examplesrequire(ifultools)##changeplotlayoutgap0.11old.pltsplitplot(4,4,1,gap=gap)##createaplotofallsupportedtapersand##windowsnmsc("rectangle","triangle","raisedcosine","hanning","hamming","blackman","nuttall","gaussian","kaiser","chebyshev","bornjordan","sine","parzen","papoulis","daniell","dpss")for(iinseq(along=nms)){if(i--50;1)splitplot(4,4,i,gap=gap)plot(taper(type=nms[i]))}##restoreplotlayouttoinitialstatepar(old.plt) IndexspectraldensityfunctionestimationSDF,3taperswindowstaper,7tstaper,7univarACVS,2SDF,3utilitiesACVS,2ACVS,2,6as.matrix.SDF(SDF),3as.matrix.taper(taper),7plot.SDF(SDF),3plot.taper(taper),7print.SDF(SDF),3print.taper(taper),7SDF,2,3taper,6,7