time series - What is the use of as.numeric() in R? -


this ex.1 on page 252 in statistics , data analysis financial engineering ruppert:

this problem , next use crsp daily returns. first, data , plot acf in 2 ways:

library(ecdat) data(crspday) crsp=crspday[,7] acf(crsp) acf(as.numeric(crsp)) 

explain “lag” means in 2 acf plots. why lag differ between plots?

i have run code , got 2 acf plots: enter image description here enter image description here

it seems x-axis tags of these plots different. why that? whst use of as.numeric in case? much!

@jeremy miles correct.

there many breeds of data. simple ones integers, binary (t/f) variables, character arrays, , double-precision numbers. r has entire zoos (pun intended) of other breeds , forms of data. 1 of them "time series".

you can verify "crsp" time series object using class function:

class(crsp) 

if want determine methods apply class, use "methods" function:

> methods(class=class(crsp))   [1] [.ts*            [<-.ts*          aggregate.ts     as.data.frame.ts  [5] cbind.ts*        cycle.ts*        diff.ts*         diffinv.ts*       [9] kernapply.ts*    lines.ts*        monthplot.ts*    na.omit.ts*      [13] ops.ts*          plot.ts          print.ts*        t.ts*            [17] time.ts*         window.ts*       window<-.ts*     

now if want compare "numeric" object, use "as.numeric".

> class(as.numeric(crsp))  [1] "numeric" 

you can see difference in available methods:

one of features of time series time values hidden inside of it. when convert numeric, trade away row indices.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -