Date: Fri, 3 Jun 2011 16:22:12 -0700
Reply-To: David Marso <david.marso@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: David Marso <david.marso@gmail.com>
Subject: Re: Python: List Index out of range
In-Reply-To: <1307134271637-4452509.post@n5.nabble.com>
Content-Type: text/plain; charset=UTF-8
drfg2008 wrote:
>
> I’ve found the solution at last: if len(alpha) ==1 instead of 0.
>
> if len(alpha) ==1 and len(beta1) == 1 and len(beta2) ==1:
> …
> else:
> continue
>
>
> Thanks for the hint of the “out of range” problem. I would never have
> happened on it.
>
>
>>@David: The task was to generate (calibrate) a regression model in file1
and use it in file2.
> TRIVIAL! See SELECT subcommand with SAVE PRED(varname)within REGRESSION
> (assumes your files are stacked using ADD FILES with an identifier). This
> also respects SPLIT FILE -cases which match the SELECT clause are used to
> estimate the model. If /SAVE is specified the unselected cases can have
> predicted values estimated using the equation calibrated in the SELECT.
>
> Actually regressions over 351 splits in each file multiplied by 3
> different times (t0, t1, t2) multiplied by 2 different regression models
> (3 variables and 4 variables). I suggested a different approach
> (multilevel regression) and reducing the split-groups, but the customer
> insisted of computing about 2100 regressions (because this was the method
> described in the literature). So, what can I do?
>
> Frank,
> It looks like you are getting lost in the forest due to unfamiliarity
> with a few important trees.
> Notably the following and how the operate together.
> ADD FILES
> SORT CASES
> SPLIT FILE
> SELECT/SAVE subcommands within REGRESSION and consider how they work
> together.
> after that do something like the following.
> Study the outcome....
> THEN AND *ONLY* THEN bring Python or MACRO into the scene.
> Allow SPSS to handle as much of the messy repetitive stuff and use Python
> like a pair of tweezers pulling a splinter from a pinkie finger rather
> than as a hammer where everything is a nail ;-)
> Consider the following:
> Consider wrapping the basic meat in a python loop but let SPSS take care
> of all the crossvalidation and iterative (SPLIT) stuff. You will have
> more hair next week .
> GET
> FILE='C:\Program Files\SPSS\1991 U.S. General Social Survey.sav'
> /KEEP EDUC HAPPY LIFE SIBS AGE RACE.
> SORT CASES BY EDUC RACE.
> SPLIT FILE BY EDUC.
> MISSING VALUES ALL ().
>
> REGRESSION VARIABLES happy life sibs age
> /SELECT RACE EQ 1
> /DEP happy
> /METHOD ENTER life sibs age
> /SAVE PRED(RACE1).
>
> REGRESSION VARIABLES happy life sibs age
> /SELECT RACE EQ 2
> /DEP happy
> /METHOD ENTER life sibs age
> /SAVE PRED(RACE2).
>
> REGRESSION VARIABLES happy life sibs age
> /SELECT RACE EQ 3
> /DEP happy
> /METHOD ENTER life sibs age
> /SAVE PRED(RACE3).
>
>
>
> Frank
>
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Python-List-Index-out-of-range-tp4450774p4452882.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
|