Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lag vs. Lead functions...

1,762 views
Skip to first unread message

Lester Loschky

unread,
Sep 19, 1998, 3:00:00 AM9/19/98
to
Hi,

I am doing an analysis in which I want to use the LEAD function.  I want to copy the value of the chosen variable from the following line.  However, since I have several observations per trial, I must be careful not to cross trial boundaries with the LEAD function (otherwise, I will copy values from the following trial into the current trial).

I have created similar variables (working in the opposite time direction) using the LAG function before, and have a script that solves the trial boundary problem:
 

DO IF  ((lag (subject) = subject) AND (lag (trial) = trial)).
COMPUTE fixdrlag = lag(fixdur).
END IF. 
EXECUTE.
I have tried unsuccessfully,  however, to use the LEAD function within this command structure.  That is, simply switching the term LEAD for LAG results in error messages, where there were none before when used with the LAG function.

I am not quite sure what could be the cause of the problem since both functions seem to require the same parameters and arguments in their syntax.

Any help on this problem would be extremely appreciated.

Thanks in advance!
 

Lester Loschky

Human Perception and Performance Group
Beckman Institute for Advanced Science and Technology
405 North Mathews
Urbana, IL  61801
E-mail: los...@s.psych.uiuc.edu
Phone/voice-mail: 217-333-0970
 

Edward F. Tverdek

unread,
Sep 20, 1998, 3:00:00 AM9/20/98
to llos...@s.psych.uiuc.edu
Lester,

The LEAD function is available only with the CREATE command, not with
the standard COMPUTE (though LAG is available for both). CREATE works
much like the COMPUTE, except for the fact that there is no default
order for the LAG and LEAD functions; you would need to specify the
LEAD order even if it were 1, as in

CREATE fixdrld=LEAD(fixdur,1).

The fact that you are creating such a variable conditionally within
subgroups means that you probably won't be able to substitute a command
such as the one above for your current COMPUTE. The DO IF that is
defining when the transformation will apply is still based on a LAG
function, and you would likely end up pulling values from the next
group defined by subject and trial in your file.

I'm not sure there's enough information here to suggest anything
definitive, but you might look into separating your subject/trial
groupings with SPLIT FILE and running a CREATE..LEAD under those
circumstances, or you might try just sorting your file in reverse of
how subject and trial are currently ordered, and sticking with the same
DO IF and LAG function you have now (this might, in effect, pull what
would currently be the n-order LEAD value in the file as it is currently
sorted).

I hope these are useful suggestions,

Ed Tverdek

> ---------------------------------------------------------------

Edward F. Tverdek

unread,
Sep 20, 1998, 3:00:00 AM9/20/98
to los...@s.psych.uiuc.edu
Lester,

Upon re-reading it, my last suggestion below sounds ambiguous and
poorly worded. It might be better to say that if you sort the file in
the reverse order of the *cases/records* as they are now (i.e. on a case
id variable), this should allow you to pretty much keep the same DO...IF
and COMPUTE you have to effectively get the first-order "lead" values.
Cases would still be grouped by subject and trial as they presumably
are now. If you don't already have a record id variable, you can do
this with something like

COMPUTE recordID=$CASENUM.
SORT CASES BY recordID (d).
DO IF...[the commands you already have].

This might get what you're looking for. I hope this makes it a little
clearer.

Ed Tverdek

Andreas Voelp

unread,
Sep 21, 1998, 3:00:00 AM9/21/98
to llos...@s.psych.uiuc.edu
Lester,

if your syntax works well with the LAG function,
why not just reverse the sort order of your data
set (with SORT CASES) and use LAG instead of LEAD?

Sincerely,
Andreas.

--
psy consult - Dr. Andreas Voelp
Fuchstanzstrasse 107 - 60489 Frankfurt, Germany
Phone (069) 97840133 - Fax (069) 97840134
eMail PsyConsu...@t-online.de

Marcel Dijkstra

unread,
Sep 22, 1998, 3:00:00 AM9/22/98
to
Maybe some has experienced the same kind of problem. I use "SPSS 6.1.1
for the PPC" on my computer (7300/200). I am also hooked up in the local
university network. For about a few month SPSS is acting very strange
when I go to my desktop. It automatically mounts de server from which I
installed SPSS. This is extremely irritating since I don't want any
network connection when I am using SPSS.
Ever since this minor but irritating problem occured I have done several
things to solve the problem. Nothing seems to work:

1) I have started up SPSS, went to the desktop (e.i. let SPSS mount the
local server), changed to the finder threw away the network, and changed
back to SPSS. Then I tried to open another file, but then SPSS was
remounting the network again as soon as I got on the desktop.
2) De-installed all SPSS related files (inc. all SPSS files in the
system forlder), reinstalled SPSS again. I did the reinstall in two
ways. From the LAN and from JAZ drive. The problem keeps coming up.
3) Threw away all possible system files like "Apple Share prefs",
"Finder prefs" etc. The problem reapears.
4) De-installed the whole system (MacOS 8.1). Reinstalled the whole
System (clean install). No solution here.

I am desperate. The longer I am busy with this problem the more
irritating it becomes.

Marcel Dijkstra


Marcel Dijkstra

unread,
Sep 22, 1998, 3:00:00 AM9/22/98
to

Marcel Dijkstra

--
Marcel Dijkstra
Junior Statician
Neuropsychology & Psychobiology
University of Maastricht, The Netherlands

Lester Loschky

unread,
Sep 22, 1998, 3:00:00 AM9/22/98
to
Thanks to everyone who sent helpful suggestions for how to solve the lag vs. lead function problem!  I have been able to successfully implement a solution and it worked perfectly!  Several people (Ed Tverdek being the first) suggested the following approach (quoted from a message from David Matheson):
 
2. Create a variable that is equal to the case number and sort the file
    in descending order on that variable.  Use the lag function to compute
   your new variable. Resort the file to the original order.

compute seq = $casenum.
sort cases by seq (d) .
do if (lag(subject) = subject and lag(trial) = trial) .
compute fixdrld = lag(fixdur).
end if.
execute.
sort cases by seq. 


David Matheson
SPSS Technical Support
 
Thanks again for everyone's help!
 

Lester
**************

0 new messages