Prior moving average (as it says on the tin) takes the averages of the previous n spans (excluding current) but is it possible to take into account the current value plus previous 3 if interested in 4 spans? No mention in CSR of this being possible. I could shift the values one down but then I am left with the very last row without a PMA score?
DATA LIST FREE / X PCT. BEGIN DATA 1 20 2 65 3 15 4 45 5 42 6 23 7 65 8 55 9 75 END DATA. FORMATS ALL (F2.0). CREATE /PCTRoll4=PMA(PCT, 4). SHIFT VALUES VARIABLE=PCTRoll4 RESULT=PCTRoll4SV LEAD=1. Thanks in advance, Jignesh |
Administrator
|
Or COMPUTE an appropriately weighted average of the PMA from CREATE and the current value.
;-) eg SUM(PMA*.75,PCT*.25).
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?" |
This gets me close (but isn't exact) ideally I'd like to avoid introducing this source of error due to the calculation for the final end point. I'm surprised PMA doesn't allow the option to allow the current value in its span, is this how moving averages are commonly presented?
On 11 March 2014 12:44, David Marso <[hidden email]> wrote: Or COMPUTE an appropriately weighted average of the PMA from CREATE and the |
Administrator
|
Please elaborate on 'error due to the calculation for the final end point'.
PMA Prior moving average. The word prior sticks out. DEMO: CREATE pma3score=PMA(score,3). DO IF $CASENUM GT 3. COMPUTE pma3reprod=MEAN(LAG(score,3),LAG(score,2),LAG(score,1)). COMPUTE pma3LAGscore=MEAN(LAG(score,3),LAG(score,2),LAG(score,1),score). COMPUTE pma3Compscore=SUM(pma3score*.75,score*.25). COMPUTE delta=pma3Compscore-pma3LAGscore. END IF. FORMATS delta (F20.16). DESCRIPTIVES delta / STATISTICS MIN MAX MEAN.
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?" |
Is it possible for AGGREGATE to return rows in the resulting dataset of empty cells that might occurs from the BREAK definition?
To put into context. I have longitudinal data which I am aggregating by time intervals and then using this to calculate weekly moving averages of a the last n data points i.e. last 4 weeks. However I am coming stuck when certain weeks are empty/zero cells and so for which a row is not generated. I could capture the same data using CTABLES and EMPTY=INCLUDE but just wanted to gauge if there may be a better solution before I resorted to this.
Thanks in advance. Jignesh On 11 March 2014 20:01, David Marso <[hidden email]> wrote: Please elaborate on 'error due to the calculation for the final end point'. |
Some time ago Jon Peck
posted the syntax below.
Use use something like to create a dataset of whatever intervals you are interested in. Use the match files procedure to make sure that all intervals are in your data. (see "date and time functions" in <help> to use something other than days.) * from Jon Peck. * create list of days in a range. input program. loop #date = date.dmy(1, 3, 2009) TO date.dmy(31, 3, 2009) BY time.days (1). * Whatever date expressions are needed. compute x = #date. end case. end loop. end file. end input program. format x(adate12). exec. Art Kendall Social Research ConsultantsOn 3/31/2014 5:44 PM, JSutar [via SPSSX Discussion] wrote:
Art Kendall
Social Research Consultants |
Administrator
|
Here's another similar path using MATRIX (this builds a fill from first date to last date by week).
DATA LIST LIST / DATE (ADATE) other_stuff (F1). BEGIN DATA 01/01/2014 1 06/22/2014 2 08/23/2014 3 12/31/2014 4 END DATA. DATASET NAME raw. LIST. DATASET DECLARE fill. MATRIX . GET D / FILE * / VARIABLES DATE. SAVE (T({D(1):D(NROW(D)):(86400*7)}))/OUTFILE fill /VARIABLES Date. END MATRIX. MATCH FILES / FILE * / FILE Fill / BY date. DATASET CLOSE fill. EXECUTE. DATASET ACTIVATE raw.
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?" |
I don't necessarily have data in date format but simply a consecutive number to indicate previous 100+ weeks (past couple of years). It's not the weeks that are missing in the raw data but when I aggregate to get scores per week that certain weeks are lost at the aggregated level. I think I understand conceptually what both codes are trying to do. I'm not sure how they will help me if not having date information.
On Tuesday, 1 April 2014, David Marso <[hidden email]> wrote: Here's another similar path using MATRIX (this builds a fill from first date |
Administrator
|
Maybe time to start from scratch and detail why/what the exact problem is so we don't waste any more time cobbling solutions predicated on incomplete information!~!! On Wed, Apr 2, 2014 at 1:19 PM, Jignesh Sutar [via SPSSX Discussion] <[hidden email]> wrote: I don't necessarily have data in date format but simply a consecutive number to indicate previous 100+ weeks (past couple of years). It's not the weeks that are missing in the raw data but when I aggregate to get scores per week that certain weeks are lost at the aggregated level. I think I understand conceptually what both codes are trying to do. I'm not sure how they will help me if not having date information.
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?" |
Administrator
|
In reply to this post by Jignesh Sutar-3
Please direct all replies to the list rather than to my email! I believe my signature is quite clear in that regard. On Wed, Apr 2, 2014 at 1:56 PM, David Marso <[hidden email]> wrote:
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?" |
Free forum by Nabble | Edit this page |