[R] Variance of multiple non-contiguous time periods?

PIKAL Petr petr.pikal at precheza.cz
Tue Nov 4 17:13:00 CET 2014


Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of CJ Davies
> Sent: Tuesday, November 04, 2014 2:50 PM
> To: Jim Lemon; r-help at r-project.org
> Subject: Re: [R] Variance of multiple non-contiguous time periods?
>
> On 04/11/14 09:11, Jim Lemon wrote:
> > On Mon, 3 Nov 2014 12:45:03 PM CJ Davies wrote:
> >> ...
> >> On 30/10/14 21:33, Jim Lemon wrote:
> >> If I understand, you mean to calculate deviations for each
> individual
> >> 'chunk' of each transition & then aggregate the results? This is
> what
> >> I'd been thinking about, but is there a sensible manner within R to
> >> achieve this, or is it something for which it would be easier to
> >> preprocess the data in an external tool? Is there some way to subset
> > the
> >> data such that I can work over just contiguous 'chunks'?
> >>
> > Exactly. If there is some combination of existing variables that can
> > be combined to make a set of unique values for each "chunk", you can
> > calculate the deviations within each "chunk", then average the
> squared
> > deviations for each type of "chunk", weighting by the duration of the
> > "chunks" so that you don't bias the pooled variance toward the longer
> > "chunks".
> >
> > Jim
> >
>
> I am stumped for a way of automating this process though. Each line of
> log data looks like this;
>
> 2406  55.4    (-11.2, 1.0, -0.9)      (-4.1, 1.0, 0.0)        7.077912
>       0.9203392       (0.0,
> 0.7, -0.1, 0.7)       8.129684        89.41537        -8.212769       (0.0, 0.7, -0.1,
> 0.7)
> 8.129684      89.41537        351.7872        1       0       0       False   0.15    3
>       37.76761        True    False   0
> transition 1

First you need to import it to R which could be tricky based on above line.
Some values will probably need to process through regular expression.

If I understand correctly number after transition is a signal which estimets continuous chunks. If it is true then

?rle is a function which can estimate length of chunks.

Cheers
Petr

>
> Where the last variable defines which transition is currently active.
> However to separate these data into 'chunks' would involve making a
> comparison between each line of data & the preceding line of data to
> determine whether it is part of the same contiguous 'chunk'. Is this
> something that would be better achieved using external preprocessing
> written in a language I am more familiar with, as I haven't the
> foggiest how I would approach this within R?
>
> Regards,
> CJ Davies
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.

________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.


More information about the R-help mailing list