R: R: Multiple weighted variables

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

R: R: Multiple weighted variables

Luca Meyer
Hello Stefan,

The syntax in the case that you need to compare before/after treatment
should be different.

More specifically, you would need one (weighted) mean before treatment
and one after it. The group variable shall not then control for a set
of agents but rather for a set of months.

The following syntax is tested on SPSS 15. I am afraid it is a bit
cumbersome but I am sure someone else on the list can provide a easier
solution.

BTW: the test data could not import on some pc, on mine I am using
commas but these might need to be replaced by periods.

/** let generate some sample data also for the month of April **/ DATA
LIST LIST/ AGENT (A10) PERC_JAN COUNT_JAN PERC_FEB COUNT_FEB PERC_MAR
COUNT_MAR PERC_APR COUNT_APR (8f2.2).
BEGIN DATA
AGENT_A ,75 3 ,85 2 ,90 3 ,95 4
AGENT_B ,65 6 ,70 2 ,80 4 ,85 2
AGENT_C ,70 4 ,75 4 , , ,79 5
AGENT_D ,80 5 , , ,85 7 , ,
END DATA.
EXE.

/** let's now assume the treatment was dated end of february and group
weighted satisfaction scores for each agent treated before and after
that date **/ COMPUTE #NUM=0.
COMPUTE #DEN=0.
DO REPEAT V1=PERC_JAN PERC_FEB /V2=COUNT_JAN COUNT_FEB.
        DO IF V1>0 AND V2>0.
                COMPUTE #NUM=#NUM+(V1*V2).
                COMPUTE #DEN=#DEN+V2.
        END IF.
END REPEAT.
COMPUTE WMEAN_A=#NUM/#DEN.
EXE.
COMPUTE #NUM=0.
COMPUTE #DEN=0.
DO REPEAT V1=PERC_MAR PERC_APR /V2=COUNT_MAR COUNT_APR.
        DO IF V1>0 AND V2>0.
                COMPUTE #NUM=#NUM+(V1*V2).
                COMPUTE #DEN=#DEN+V2.
        END IF.
END REPEAT.
COMPUTE WMEAN_B=#NUM/#DEN.
EXE.

/** there is the need to restructure the file using the following
syntax **/ DATASET NAME ENTIRE.
DATASET COPY TIME1.
DATASET ACTIVATE TIME1.
COMPUTE TIME=1.
RENAME VAR (WMEAN_A=WMEAN).
ADD FILES /FILE=* /KEEP TIME WMEAN.
DATASET ACTIVATE ENTIRE.
DATASET COPY TIME2.
DATASET ACTIVATE TIME2.
COMPUTE TIME=2.
RENAME VAR (WMEAN_B=WMEAN).
ADD FILES /FILE=* /KEEP TIME WMEAN.
DATASET ACTIVATE TIME1.
ADD FILES /FILE=* /FILE=TIME2.
EXE.

/** then run the paired t-test **/
DATASET ACTIVATE TIME1.
T-TEST
PAIRS = TIME  WITH WMEAN (PAIRED)
/CRITERIA = CI(.95)
/MISSING = ANALYSIS.

Cheers,
Luca


-----Messaggio originale-----
Da: Stefan Keydel [mailto:[hidden email]]
Inviato: martedì 19 giugno 2007 20.32
A: Luca Meyer
Cc: [hidden email]
Oggetto: Re: R: Multiple weighted variables

Hi Luca,

I will try this-- thank you for this! My situation is a little bit
different, in that I'm trying to compare the performance of one set of
agents before and after treatment. Do you know if this syntax will work
for this, as well? I think it will, or?

Thank you,

Stefan
On Tuesday, June 19, 2007 at 12:41, Luca Meyer wrote:

>Hello Stefan,
>
>What you are saying it makes sense to me if you have to compare
>different agents. I therefore assume that the specific "treatment"
has
>been applied to some agents and not to others. In other words, I
want
>to test if the weighted average score for some agents is
significantly
>higher(smaller) than the same score for other agents.
>
>Here is the syntax I tested:
>
>/** first i generate some sample data **/ DATA LIST LIST/ AGENT
(A10)
>PERC_JAN COUNT_JAN PERC_FEB COUNT_FEB PERC_MAR COUNT_MAR (6f2.2).
>BEGIN DATA
>AGENT_A ,75 3 ,85 2 ,90 3
>AGENT_B ,65 6 ,70 2 ,80 4
>AGENT_C ,70 4 ,75 4
>AGENT_D ,80 5 , , ,85 7 END DATA.
>EXE.
>
>/** i then classify agents into testing groups, assuming that
AGENT_A
>and AGENT_B are part of GROUP 1, while the others are part of GROUP
2
>**/ RECODE AGENT ("AGENT_A"=1) ("AGENT_B"=1) (ELSE=2) INTO GROUP .
>CROSSTABS AGENT BY GROUP.
>
>/** now i compute the weighted scores mean for each agent **/
COMPUTE
>#NUM=0.
>COMPUTE #DEN=0.
>DO REPEAT V1=PERC_JAN PERC_FEB PERC_MAR /V2=COUNT_JAN COUNT_FEB
COUNT_MAR.

>DO IF V1>0 AND V2>0.
>COMPUTE #NUM=#NUM+(V1*V2).
>COMPUTE #DEN=#DEN+V2.
>END IF.
>END REPEAT.
>COMPUTE WMEAN=#NUM/#DEN.
>EXE.
>
>/** i then run the paired t-test **/
>T-TEST
>PAIRS = GROUP  WITH WMEAN (PAIRED)
>/CRITERIA = CI(.95)
>/MISSING = ANALYSIS.
>
>Let me know if I have corretly interpreted your needs or if you
>actually need something else.
>
>Luca
>
>Mr. Luca MEYER
>Market research, data analysis & more
>www.lucameyer.com - Tel: +39.339.495.00.21
>
>-----Messaggio originale-----
>Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto
di
>Stefan Keydel
>Inviato: martedì 19 giugno 2007 7.00
>A: [hidden email]
>Oggetto: Multiple weighted variables
>
>Hello,
>
>I'd wager that a variation of this question has already been posed,
but
>the archive is so huge that, after wading through it a bit, I've
>decided simply to pose my question:
>
>I have a dataset with customer satisfaction scores for a group of
phone
>agents over a range of months, along with the corresponding number
of
>survey responses that went into the score for each month. What I
want
>to do is create weighted variables for each month, based on the
survey

>count. The data table might look as follows:
>
>Agent       Jan     Count       Feb     Count       March       Count
>----------------------------------------------------------------------
>Agent A     .75         3         .85       2
>.80             4
>Agent B     .65         6         .70       2
>.85             1
>...
>
>How can I create 3 separate weighted variables for January,
February,
>and March, based on the respective counts of surveys per agent? Or am
I
>even asking the right question?
>
>Incidentally, the ultimate aim is to run a couple paired-sample t-
tests
>to determine whether a specific "treatment" has resulted in
significant
>changes to the customer satisfaction scores.
>
>Thanks,
>
>Stefan
>




_________________________________________________________
Naviga e telefona senza limiti con Tiscali
Scopri le promozioni Tiscali Adsl: navighi e telefoni senza canone Telecom

http://abbonati.tiscali.it/adsl/
Reply | Threaded
Open this post in threaded view
|

Re: R: R: Multiple weighted variables

Stefan Keydel
Again, many thanks, Luca!

Stefan
On Tuesday, June 19, 2007 at 15:42, [hidden email] wrote:

>Hello Stefan,
>
>The syntax in the case that you need to compare before/after
>treatment should be different.
>
>More specifically, you would need one (weighted) mean before
>treatment and one after it. The group variable shall not then
>control for a set of agents but rather for a set of months.
>
>The following syntax is tested on SPSS 15. I am afraid it is a
>bit cumbersome but I am sure someone else on the list can
>provide a easier solution.

<snip>