GithubHelp home page GithubHelp logo

nickpoison / tsa4 Goto Github PK

View Code? Open in Web Editor NEW
154.0 9.0 65.0 946 KB

R code for Time Series Analysis and Its Applications, Ed 4

astsa time-series-analysis r data-science data-analysis state-space-models kalman-filter em-algorithm frequency-domain missing-data time-domain

tsa4's Introduction

tsa4

✨ Here is A Road Map if you want a broad view of what is available.


tsa4

astsa

python

   mr natch

tsa4's People

Contributors

dsstoffer avatar nickpoison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tsa4's Issues

Example 5.12 of Chapter 5: Additional Time Domain Topics in tsa4

Dear Nicky Poison,

In the Example 5.12 of Chapter 5: Additional Time Domain Topics
https://github.com/nickpoison/tsa4/blob/master/textRcode.md#chapter-5

The R code command line below:

acf(innov)

has created the error as below.

Error in na.fail.default(as.ts(x)) : missing values in object

I guess the arugment "na.action = na.fail" as default value by stats::acf function may be the cause of the error.

So, I set the arugment "na.action = na.pass" in the command line above as

acf(innov, na.action = na.pass)

to have a display of 3 x 3 plots of acf() as result.

I may be wrong.

Please consider the suggestion in your side to check whether my suggestion is wrong or not.

Thanks in advance.

Best regards,
Jimmy Au

tsplot(innov)
head(innov) # contains missing values
u1 u2 u3
1 NA NA NA
2 NA NA NA
3 -7.986554 -3.401042 -6.244936
4 -3.757739 5.160169 -2.446715
5 -2.455558 6.115729 11.073832
6 -1.188275 -2.249943 -10.914951
#acf(innov) # <-------- Error
acf(innov, na.action = na.pass)
acf(innov)
Error in na.fail.default(as.ts(x)) : missing values in object

Wrong ACF code in Example 3.11

The problem

The following code of Example 3.11 is inconsistent with the chart shown in left-hand-side of Fig 3.5.

tsa4/textRcode.md

Lines 567 to 569 in 775a7ec

ACF = ARMAacf(ar=c(1.5,-.75), ma=0, 50)
tsplot(ACF, type="h", xlab="lag")
abline(h=0, col=8)

ACF is a list with value of ACF[1] being actually $\rho(0)=1$. That is, the lag values skewed.

The following figure shows what will be plotted using the code above.

Screen Shot 2023-01-01 at 01 15 23

The fix

Actually ACF chart should be start with index 0. Or, if we just ignore ACF[1] (which is always 1), the code should be:

ACF = ARMAacf(ar=c(1.5,-.75), ma=0, 25)[-1]
plot(ACF, type="h", xlab="lag")
abline(h=0)

which produces

Screen Shot 2023-01-01 at 01 16 46

The chart above is exactly Fig 3.5 in the text.

R version

> version
               _                           
platform       x86_64-apple-darwin17.0     
arch           x86_64                      
os             darwin17.0                  
system         x86_64, darwin17.0          
status                                     
major          4                           
minor          0.2                         
year           2020                        
month          06                          
day            22                          
svn rev        78730                       
language       R                           
version.string R version 4.0.2 (2020-06-22)
nickname       Taking Off Again            

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.