[R] Application of rolling window in entropy analysis

Eric Berger er|cjberger @end|ng |rom gm@||@com
Fri Nov 2 13:33:15 CET 2018


You have not provided any information that leads you to write 'it is not
working'.
Can you be specific?
Are you getting error messages? What are they?
etc
etc


On Fri, Nov 2, 2018 at 12:33 PM Subhamitra Patra <subhamitra.patra using gmail.com>
wrote:

> ts= India[-1,]
> N<-ncol(ts)
> width <- 500
> M <- nrow(ts) - width
> r<-matrix(0, ncol = N, nrow = M)
> library(pracma)
> for (i in 1:N){
>        r[,i]<-rollapply( data=ts[,i], width=width, FUN=approx_entropy,
> edim = 2, r = 0.2*sd(ts[,i]), elag = 1, align="right")
> }
>
> This is my entropy value which I am interested to use in rolling window
> size of 500. I applied rollapply function, but it is not working.
>
> Kindly help me out
>
>
> [image: Mailtrack]
> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/02/18,
> 4:02:18 PM
>
> On Fri, Nov 2, 2018 at 3:59 PM Eric Berger <ericjberger using gmail.com> wrote:
>
>> How about something like this:
>>
>> ts= India[-1,]   #####For deleting the year row
>> N<-ncol(ts)
>> width <- 500
>> M <- nrow(ts) - width
>> r<-matrix(0, ncol = N, nrow = M)
>> library(pracma)
>> for (i in 1:N){
>>        r[,i]<-rollapply( data=ts[,i], width=width, FUN=approx_entropy,
>> edim = 2, r = 0.2*sd(ts[,i]), elag = 1, align="right")
>> }
>>
>> Best,
>> Eric
>>
>>
>>
>> On Fri, Nov 2, 2018 at 12:15 PM Subhamitra Patra <
>> subhamitra.patra using gmail.com> wrote:
>>
>>> Thank you for the clarification. I checked and there was a small
>>> mistakes in the code. Now my code is
>>>
>>> ts= India[-1,]   #####For deleting the year row
>>> N<-ncol(ts)
>>> r<-matrix(0, ncol = N, nrow = 1)
>>> library(pracma)
>>> for (i in 1:N){
>>>        r[i]<-approx_entropy(ts[,i], edim = 2, r = 0.2*sd(ts[,i]), elag =
>>> 1)
>>> }
>>>
>>> Even with this code also, I am unable to apply rollapply function.
>>>
>>> Kindly help me.
>>>
>>>
>>> [image: Mailtrack]
>>> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>> notified by
>>> Mailtrack
>>> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/02/18,
>>> 3:44:26 PM
>>>
>>> On Fri, Nov 2, 2018 at 3:42 PM Eric Berger <ericjberger using gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>> You have some problems with your setup. You set N based on the number
>>>> of rows in ts, but then in the call to approx_entropy you write ts[,i].
>>>> Note that ts[,i] is the i'th column of ts, whereas your definition of i
>>>> implies it is based on row numbers.
>>>>
>>>> Maybe this is leading you to see problems elsewhere. From the rollapply
>>>> documentation I don't see any reason why it would not work with the
>>>> approx_entropy function.
>>>>
>>>> Best,
>>>> Eric
>>>>
>>>>
>>>> On Fri, Nov 2, 2018 at 11:16 AM Subhamitra Patra <
>>>> subhamitra.patra using gmail.com> wrote:
>>>>
>>>>> Dear all R users,
>>>>>
>>>>> I want to apply the entropy methods in rolling window analysis. I tried
>>>>> with the rollapply function, but it is not working. For your
>>>>> convenience, I
>>>>> am providing my code so that you can easily suggest me the application
>>>>> of
>>>>> rolling window in the particular methodology. Here is my code
>>>>>
>>>>> N<-nrow(ts)
>>>>> r<-matrix(0, nrow = N, ncol = 1)
>>>>> for (i in 1:N){
>>>>>      r[i]<-approx_entropy(ts[,i], edim = 2, r = 0.2*sd(ts[,i]), elag =
>>>>> 1)
>>>>> }
>>>>>
>>>>> Kindly suggest me how to apply rolling window size of 500 in the
>>>>> particular
>>>>> time series model?
>>>>>
>>>>> I expect positive help from you.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> --
>>>>> *Best Regards,*
>>>>> *Subhamitra Patra*
>>>>> *Phd. Research Scholar*
>>>>> *Department of Humanities and Social Sciences*
>>>>> *Indian Institute of Technology, Kharagpur*
>>>>> *INDIA*
>>>>>
>>>>>
>>>>> [image: Mailtrack]
>>>>> <
>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&
>>>>> >
>>>>> Sender
>>>>> notified by
>>>>> Mailtrack
>>>>> <
>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&
>>>>> >
>>>>> 11/02/18,
>>>>> 2:44:12 PM
>>>>>
>>>>>         [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________________________
>>>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>> PLEASE do read the posting guide
>>>>> http://www.R-project.org/posting-guide.html
>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>
>>>>
>>>
>>> --
>>> *Best Regards,*
>>> *Subhamitra Patra*
>>> *Phd. Research Scholar*
>>> *Department of Humanities and Social Sciences*
>>> *Indian Institute of Technology, Kharagpur*
>>> *INDIA*
>>>
>>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>

	[[alternative HTML version deleted]]




More information about the R-help mailing list