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:
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.DO IF ((lag (subject) = subject) AND (lag (trial) = trial)). COMPUTE fixdrlag = lag(fixdur). END IF. EXECUTE.
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
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
> ---------------------------------------------------------------
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
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
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
--
Marcel Dijkstra
Junior Statician
Neuropsychology & Psychobiology
University of Maastricht, The Netherlands
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
Lester
**************