raking and weighting

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

raking and weighting

Sebastián Daza-3
Dear John,
I check it, but it didn't work. This is my syntax:

wei by pond.
begin program.
import spss, spssaux, rake
rake.rake(['cuota','region','gse_cheq'],
[{1:.20, 2:.20,3:.20,4:.10, 5:.10,6:.20},
{1:.028, 2:.032,3:.016,4:.039, 5:.104,6:.051, 7:.059,8:.122,9:.056,
10:.070,11:.006, 12:.010,13:.407},
{5:.128, 4:.197,3:.271,2:.343, 1:.060} ]
, finalweight='wt3', visible=True, delta=1, poptotal=1007)
end program.

Regards.
--
Sebastián Daza Aranzaes
Sociólogo UC
[hidden email]

=====================
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: raking and weighting

Peck, Jon
Did you turn on the new weight?  Here's an example with 17 using the cars.sav data file shipped with SPSS.  First it forces each of the three origins to weight to equal.  Turning on that weight, you can see that this succeeds.
Then it uses the origin variable as a weight and reweights to equal.  Finally the descriptives output shows that these two sets of weights are different.

Although this is using the Version 17 extension command, it is calling the same Python rake module used in 16.

HTH,
Jon Peck

compute wtvar = origin.
freq origin.
SPSSINC RAKE DIM1 = origin 1 .333 2 .333 3 .333
FINALWEIGHT=equalorigin
/OPTIONS ITERATIONS=20 CONVERGENCE=.0001 DELTA=.5 SHOW=NO.
weight by equalorigin.
* All origins should be equal.
freq origin.
weight off.
freq origin.
weight by origin.
* double weight origin 2 and triple weight origin 3.
freq origin.
spssinc rake dim1=origin 1 .333 2 .333 3 .333 finalweight= weightedorigin.
weight by weightedorigin.
freq origin.
WEIGHT off.
desc equalorigin weightedorigin.

-----Original Message-----
From: Sebastián Daza [mailto:[hidden email]]
Sent: Monday, February 02, 2009 7:34 AM
To: Peck, Jon; [hidden email]
Subject: raking and weighting

Dear John,
I check it, but it didn't work. This is my syntax:

wei by pond.
begin program.
import spss, spssaux, rake
rake.rake(['cuota','region','gse_cheq'],
[{1:.20, 2:.20,3:.20,4:.10, 5:.10,6:.20},
{1:.028, 2:.032,3:.016,4:.039, 5:.104,6:.051, 7:.059,8:.122,9:.056,
10:.070,11:.006, 12:.010,13:.407},
{5:.128, 4:.197,3:.271,2:.343, 1:.060} ]
, finalweight='wt3', visible=True, delta=1, poptotal=1007)
end program.

Regards.
--
Sebastián Daza Aranzaes
Sociólogo UC
[hidden email]

=====================
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: raking and weighting

jpduarte
In reply to this post by Sebastián Daza-3
Hello Sebastian

you can use this macro below if you have several weight variables.

if you do not want to use weight variables you can use a macro i made some
years ago that you can find at raynald' spsstools site at syntax section,
compute sub-section(8) , item 11.

João Duarte
[hidden email]

*****************  begin macro *******************.

DEFINE !weight (!POSITIONAL !ENCLOSE('[',']'))
WEIGHT OFF.
compute xxx_xxx=$casenum.
!DO !var !IN (!1)

!let !valW=!concat("w_",!var)

SORT CASES BY !var.
COMPUTE !valW = !var.
IF !var=LAG(!var) !valW = !valW + LAG(!valW).
SORT CASES BY !var (A) !valW (D).
IF !var=LAG(!var) !valW=LAG(!valW).

!doend


!DO !xx=1 !TO 5
!DO !var !IN (!1)
!let !valW=!concat("w_",!var)
SORT CASES BY !var.
COMPUTE wttt = wg.
IF !var=LAG(!var) wttt = wttt + LAG(wttt).
SORT CASES BY !var (A) wttt (D).
IF !var=LAG(!var) wttt=LAG(wttt).
COMPUTE wg=wg * (!valW / wttt).
!DOEND
!doend

sort cases by xxx_xxx.
compute yyy_yyy=$sysmis.
match files
 /file=*
 /drop xxx_xxx to yyy_yyy.
exe.
weight by wg.
!ENDDEFINE.

*************** end macro ********************.

compute wg=1. /*if wg does no exist it is necessary initialize it with 1.

!weight [w1 w2]./* w1 , w2 represent partial weight variables  you can use
any number.

* wg will be your global weight variable .
* you can call again the macro if you need a more accurate result.




----- Original Message -----
From: "Sebastián Daza" <[hidden email]>
To: <[hidden email]>
Sent: Monday, February 02, 2009 2:34 PM
Subject: raking and weighting


> Dear John,
> I check it, but it didn't work. This is my syntax:
>
> wei by pond.
> begin program.
> import spss, spssaux, rake
> rake.rake(['cuota','region','gse_cheq'],
> [{1:.20, 2:.20,3:.20,4:.10, 5:.10,6:.20},
> {1:.028, 2:.032,3:.016,4:.039, 5:.104,6:.051, 7:.059,8:.122,9:.056,
> 10:.070,11:.006, 12:.010,13:.407},
> {5:.128, 4:.197,3:.271,2:.343, 1:.060} ]
> , finalweight='wt3', visible=True, delta=1, poptotal=1007)
> end program.
>
> Regards.
> --
> Sebastián Daza Aranzaes
> Sociólogo UC
> [hidden email]
>
> =====================
> 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


--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.233 / Virus Database: 270.10.18/1935 - Release Date: 02/04/09
16:35:00

=====================
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