cumulative max (analogous to cumulative sum) ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

cumulative max (analogous to cumulative sum) ?

Larsen, Jeff T

Hello everyone –

 

I’m trying to figure out when time series signals have hit what skin conductance researchers call “recovery half time”. After a peak in skin conductance activity, half recovery occurs when the signal falls back down halfway toward its baseline level. You can see an example here: https://images.app.goo.gl/PVME8Lxhtw2rXCnw5

 

I’m dealing with thousands of these signals, so it needs to be automated. It wouldn’t be too difficult if the suite of time series functions included a “cumulative max” function (i.e., the maximum value to this point in the time series), but there is no such function.

 

I thought I had a workaround involving the cumulative sum (CSUM) function. At each time point, I calculated the cumulative sum of all rises (RiseCsum) and all declines (FallCsum) . I then divided RiseCsum by FallCsum with the idea that half recovery time occurred when that fraction exceeded .5. This works with simple, canonical responses, but falls apart when the signal gets choppy.

 

That said, if anyone knows of any way to calculate cumulative max, I’d greatly appreciate hearing about it.

 

(Note: If nothing comes up, my next step will be to turn to the SHIFT VALUES function to get all of the subsequent values in each time series. I’m not entirely sure how it will work, but I suspect that I’ll be able to manage from there. The problem is that these time series can go on for up to 1000 time points, so that would mean 1000 new variables. Not fun. If someone knows how to get the cumulative max, I’d be in a much better position.)

 

Thanks in advance.

 

-- Jeff

 

 

**********************
Jeff T. Larsen, Ph.D.
Professor of Psychology
University of Tennessee, Knoxville
[hidden email]  /    865-974-9967

 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: cumulative max (analogous to cumulative sum) ?

David Marso
Administrator
I would stack the series' using VARSTOCASES then the following untested.
VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.

DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
+  COMPUTE SeriesMAX= datavalue.
END IF.

DO  IF datavalue GT LAG(SeriesMAX).
+  COMPUTE SeriesMAX= datavalue.
ELSE.
+  COMPUTE SeriesMAX= LAG(SeriesMAX).
END IF.



Larsen, Jeff T wrote

> Hello everyone –
>
> I’m trying to figure out when time series signals have hit what skin
> conductance researchers call “recovery half time”. After a peak in skin
> conductance activity, half recovery occurs when the signal falls back down
> halfway toward its baseline level. You can see an example here:
> https://images.app.goo.gl/PVME8Lxhtw2rXCnw5
>
> I’m dealing with thousands of these signals, so it needs to be automated.
> It wouldn’t be too difficult if the suite of time series functions
> included a “cumulative max” function (i.e., the maximum value to this
> point in the time series), but there is no such function.
>
> I thought I had a workaround involving the cumulative sum (CSUM) function.
> At each time point, I calculated the cumulative sum of all rises
> (RiseCsum) and all declines (FallCsum) . I then divided RiseCsum by
> FallCsum with the idea that half recovery time occurred when that fraction
> exceeded .5. This works with simple, canonical responses, but falls apart
> when the signal gets choppy.
>
> That said, if anyone knows of any way to calculate cumulative max, I’d
> greatly appreciate hearing about it.
>
> (Note: If nothing comes up, my next step will be to turn to the SHIFT
> VALUES function to get all of the subsequent values in each time series.
> I’m not entirely sure how it will work, but I suspect that I’ll be able to
> manage from there. The problem is that these time series can go on for up
> to 1000 time points, so that would mean 1000 new variables. Not fun. If
> someone knows how to get the cumulative max, I’d be in a much better
> position.)
>
> Thanks in advance.
>
> -- Jeff
>
>
> **********************
> Jeff T. Larsen, Ph.D.
> Professor of Psychology
> University of Tennessee, Knoxville

> jeff.larsen@

> <mailto:

> jeff.larsen@

> >  /    865-974-9967
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: cumulative max (analogous to cumulative sum) ?

David Marso
Administrator
Actually :

VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.
DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
COMPUTE  SeriesMAX= datavalue.
ELSE.
COMPUTE SeriesMAX= MAX(datavalue,LAG(SeriesMAX)).
END IF.


David Marso wrote

> I would stack the series' using VARSTOCASES then the following untested.
> VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.
>
> DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
> +  COMPUTE SeriesMAX= datavalue.
> END IF.
>
> DO  IF datavalue GT LAG(SeriesMAX).
> +  COMPUTE SeriesMAX= datavalue.
> ELSE.
> +  COMPUTE SeriesMAX= LAG(SeriesMAX).
> END IF.
>
>
>
> Larsen, Jeff T wrote
>> Hello everyone –
>>
>> I’m trying to figure out when time series signals have hit what skin
>> conductance researchers call “recovery half time”. After a peak in skin
>> conductance activity, half recovery occurs when the signal falls back
>> down
>> halfway toward its baseline level. You can see an example here:
>> https://images.app.goo.gl/PVME8Lxhtw2rXCnw5
>>
>> I’m dealing with thousands of these signals, so it needs to be automated.
>> It wouldn’t be too difficult if the suite of time series functions
>> included a “cumulative max” function (i.e., the maximum value to this
>> point in the time series), but there is no such function.
>>
>> I thought I had a workaround involving the cumulative sum (CSUM)
>> function.
>> At each time point, I calculated the cumulative sum of all rises
>> (RiseCsum) and all declines (FallCsum) . I then divided RiseCsum by
>> FallCsum with the idea that half recovery time occurred when that
>> fraction
>> exceeded .5. This works with simple, canonical responses, but falls apart
>> when the signal gets choppy.
>>
>> That said, if anyone knows of any way to calculate cumulative max, I’d
>> greatly appreciate hearing about it.
>>
>> (Note: If nothing comes up, my next step will be to turn to the SHIFT
>> VALUES function to get all of the subsequent values in each time series.
>> I’m not entirely sure how it will work, but I suspect that I’ll be able
>> to
>> manage from there. The problem is that these time series can go on for up
>> to 1000 time points, so that would mean 1000 new variables. Not fun. If
>> someone knows how to get the cumulative max, I’d be in a much better
>> position.)
>>
>> Thanks in advance.
>>
>> -- Jeff
>>
>>
>> **********************
>> Jeff T. Larsen, Ph.D.
>> Professor of Psychology
>> University of Tennessee, Knoxville
>
>> jeff.larsen@
>
>> <mailto:
>
>> jeff.larsen@
>
>> >  /    865-974-9967
>>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (not to SPSSX-L), with no body text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the command
>> INFO REFCARD
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: cumulative max (analogous to cumulative sum) ?

Bruce Weaver
Administrator
Yes. Good catch.  


David Marso wrote

> Actually :
>
> VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.
> DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
> COMPUTE  SeriesMAX= datavalue.
> ELSE.
> COMPUTE SeriesMAX= MAX(datavalue,LAG(SeriesMAX)).
> END IF.
>
>
> David Marso wrote
>> I would stack the series' using VARSTOCASES then the following untested.
>> VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.
>>
>> DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
>> +  COMPUTE SeriesMAX= datavalue.
>> END IF.
>>
>> DO  IF datavalue GT LAG(SeriesMAX).
>> +  COMPUTE SeriesMAX= datavalue.
>> ELSE.
>> +  COMPUTE SeriesMAX= LAG(SeriesMAX).
>> END IF.
>>
>>
>>
>> Larsen, Jeff T wrote
>>> Hello everyone –
>>>
>>> I’m trying to figure out when time series signals have hit what skin
>>> conductance researchers call “recovery half time”. After a peak in skin
>>> conductance activity, half recovery occurs when the signal falls back
>>> down
>>> halfway toward its baseline level. You can see an example here:
>>> https://images.app.goo.gl/PVME8Lxhtw2rXCnw5
>>>
>>> I’m dealing with thousands of these signals, so it needs to be
>>> automated.
>>> It wouldn’t be too difficult if the suite of time series functions
>>> included a “cumulative max” function (i.e., the maximum value to this
>>> point in the time series), but there is no such function.
>>>
>>> I thought I had a workaround involving the cumulative sum (CSUM)
>>> function.
>>> At each time point, I calculated the cumulative sum of all rises
>>> (RiseCsum) and all declines (FallCsum) . I then divided RiseCsum by
>>> FallCsum with the idea that half recovery time occurred when that
>>> fraction
>>> exceeded .5. This works with simple, canonical responses, but falls
>>> apart
>>> when the signal gets choppy.
>>>
>>> That said, if anyone knows of any way to calculate cumulative max, I’d
>>> greatly appreciate hearing about it.
>>>
>>> (Note: If nothing comes up, my next step will be to turn to the SHIFT
>>> VALUES function to get all of the subsequent values in each time series.
>>> I’m not entirely sure how it will work, but I suspect that I’ll be able
>>> to
>>> manage from there. The problem is that these time series can go on for
>>> up
>>> to 1000 time points, so that would mean 1000 new variables. Not fun. If
>>> someone knows how to get the cumulative max, I’d be in a much better
>>> position.)
>>>
>>> Thanks in advance.
>>>
>>> -- Jeff
>>>
>>>
>>> **********************
>>> Jeff T. Larsen, Ph.D.
>>> Professor of Psychology
>>> University of Tennessee, Knoxville
>>
>>> jeff.larsen@
>>
>>> <mailto:
>>
>>> jeff.larsen@
>>
>>> >  /    865-974-9967
>>>
>>>
>>> =====================
>>> To manage your subscription to SPSSX-L, send a message to
>>
>>> LISTSERV@.UGA
>>
>>>  (not to SPSSX-L), with no body text except the
>>> command. To leave the list, send the command
>>> SIGNOFF SPSSX-L
>>> For a list of commands to manage subscriptions, send the command
>>> INFO REFCARD
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (not to SPSSX-L), with no body text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the command
>> INFO REFCARD
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: cumulative max (analogous to cumulative sum) ?

David Marso
Administrator
A bit of a brain fart ;-).

Another take...

VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.
COMPUTE SeriesMAX= MAX(datavalue,LAG(SeriesMAX) * (SeriesID EQ LAG(SeriesID)
)).

My preferred method if the series' consist of positive values.
-------


Bruce Weaver wrote

> Yes. Good catch.  
>
>
> David Marso wrote
>> Actually :
>>
>> VARSTOCASES MAKE datavalue FROM series0001 TO series1000 /INDEX=SeriesID.
>> DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
>> COMPUTE  SeriesMAX= datavalue.
>> ELSE.
>> COMPUTE SeriesMAX= MAX(datavalue,LAG(SeriesMAX)).
>> END IF.
>>
>>
>> David Marso wrote
>>> I would stack the series' using VARSTOCASES then the following untested.
>>> VARSTOCASES MAKE datavalue FROM series0001 TO series1000
>>> /INDEX=SeriesID.
>>>
>>> DO IF $CASENUM EQ 1 OR SeriesID NE LAG(SeriesID).
>>> +  COMPUTE SeriesMAX= datavalue.
>>> END IF.
>>>
>>> DO  IF datavalue GT LAG(SeriesMAX).
>>> +  COMPUTE SeriesMAX= datavalue.
>>> ELSE.
>>> +  COMPUTE SeriesMAX= LAG(SeriesMAX).
>>> END IF.
>>>
>>>
>>>
>>> Larsen, Jeff T wrote
>>>> Hello everyone –
>>>>
>>>> I’m trying to figure out when time series signals have hit what skin
>>>> conductance researchers call “recovery half time”. After a peak in skin
>>>> conductance activity, half recovery occurs when the signal falls back
>>>> down
>>>> halfway toward its baseline level. You can see an example here:
>>>> https://images.app.goo.gl/PVME8Lxhtw2rXCnw5
>>>>
>>>> I’m dealing with thousands of these signals, so it needs to be
>>>> automated.
>>>> It wouldn’t be too difficult if the suite of time series functions
>>>> included a “cumulative max” function (i.e., the maximum value to this
>>>> point in the time series), but there is no such function.
>>>>
>>>> I thought I had a workaround involving the cumulative sum (CSUM)
>>>> function.
>>>> At each time point, I calculated the cumulative sum of all rises
>>>> (RiseCsum) and all declines (FallCsum) . I then divided RiseCsum by
>>>> FallCsum with the idea that half recovery time occurred when that
>>>> fraction
>>>> exceeded .5. This works with simple, canonical responses, but falls
>>>> apart
>>>> when the signal gets choppy.
>>>>
>>>> That said, if anyone knows of any way to calculate cumulative max, I’d
>>>> greatly appreciate hearing about it.
>>>>
>>>> (Note: If nothing comes up, my next step will be to turn to the SHIFT
>>>> VALUES function to get all of the subsequent values in each time
>>>> series.
>>>> I’m not entirely sure how it will work, but I suspect that I’ll be able
>>>> to
>>>> manage from there. The problem is that these time series can go on for
>>>> up
>>>> to 1000 time points, so that would mean 1000 new variables. Not fun. If
>>>> someone knows how to get the cumulative max, I’d be in a much better
>>>> position.)
>>>>
>>>> Thanks in advance.
>>>>
>>>> -- Jeff
>>>>
>>>>
>>>> **********************
>>>> Jeff T. Larsen, Ph.D.
>>>> Professor of Psychology
>>>> University of Tennessee, Knoxville
>>>
>>>> jeff.larsen@
>>>
>>>> <mailto:
>>>
>>>> jeff.larsen@
>>>
>>>> >  /    865-974-9967
>>>>
>>>>
>>>> =====================
>>>> To manage your subscription to SPSSX-L, send a message to
>>>
>>>> LISTSERV@.UGA
>>>
>>>>  (not to SPSSX-L), with no body text except the
>>>> command. To leave the list, send the command
>>>> SIGNOFF SPSSX-L
>>>> For a list of commands to manage subscriptions, send the command
>>>> INFO REFCARD
>>>
>>>
>>>
>>>
>>>
>>> -----
>>> Please reply to the list and not to my personal email.
>>> Those desiring my consulting or training services please feel free to
>>> email me.
>>> ---
>>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>>> porcos
>>> ne forte conculcent eas pedibus suis."
>>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>>> in
>>> abyssum?"
>>> --
>>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>>
>>> =====================
>>> To manage your subscription to SPSSX-L, send a message to
>>
>>> LISTSERV@.UGA
>>
>>>  (not to SPSSX-L), with no body text except the
>>> command. To leave the list, send the command
>>> SIGNOFF SPSSX-L
>>> For a list of commands to manage subscriptions, send the command
>>> INFO REFCARD
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (not to SPSSX-L), with no body text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the command
>> INFO REFCARD
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"