MaxDiff analysis

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

MaxDiff analysis

mils
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
mils
Reply | Threaded
Open this post in threaded view
|

Re: MaxDiff analysis

Andy W
Yeah that is a bit much. You can always break it up into smaller questions, and create a before and after dataset and ask for advice.

 - For ranking, see the RANK command
 - For the *average* of the ranks see the AGGREGATE command
 - For cumulative proportions you can use LAG

For that first part in setting up the data (and seeing your multiple computes) you will be probably interested in the VARSTOCASES command.

If it is any consolation, if done properly your SPSS code will be much simpler than that linked R code (although that R code could be done simpler as well I'm sure).
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: MaxDiff analysis

mils
In reply to this post by mils
I've got help for:

1. Computing the overall counts for the whole sample and
2. Computing individual-level counts

R

counts = apply(itMaxDiffData, 2, mean, na.rm = TRUE)
ranks = nAlternatives + 1 - rank(counts)
cbind(Counts = counts, Ranks = ranks)

id = rep(1:n,rep(nBlocks,n))
individualCounts = aggregate(itMaxDiffData,list(id),mean, na.rm = TRUE)[,-1]
round(individualCounts[1:10,],1) #show at data for first 10 respondents

SPSS

comp suma1=mean(maxDiff1alt1,maxDiff2alt1,maxDiff3alt1,maxDiff4alt1,maxDiff5alt1,maxDiff6alt1).
comp suma2=mean(maxDiff1alt2,maxDiff2alt2,maxDiff3alt2,maxDiff4alt2,maxDiff5alt2,maxDiff6alt2).
comp suma3=mean(maxDiff1alt3,maxDiff2alt3,maxDiff3alt3,maxDiff4alt3,maxDiff5alt3,maxDiff6alt3).
comp suma4=mean(maxDiff1alt4,maxDiff2alt4,maxDiff3alt4,maxDiff4alt4,maxDiff5alt4,maxDiff6alt4).
comp suma5=mean(maxDiff1alt5,maxDiff2alt5,maxDiff3alt5,maxDiff4alt5,maxDiff5alt5,maxDiff6alt5).
comp suma6=mean(maxDiff1alt6,maxDiff2alt6,maxDiff3alt6,maxDiff4alt6,maxDiff5alt6,maxDiff6alt6).
comp suma7=mean(maxDiff1alt7,maxDiff2alt7,maxDiff3alt7,maxDiff4alt7,maxDiff5alt7,maxDiff6alt7).
comp suma8=mean(maxDiff1alt8,maxDiff2alt8,maxDiff3alt8,maxDiff4alt8,maxDiff5alt8,maxDiff6alt8).
comp suma9=mean(maxDiff1alt9,maxDiff2alt9,maxDiff3alt9,maxDiff4alt9,maxDiff5alt9,maxDiff6alt9).
comp suma10=mean(maxDiff1alt10,maxDiff2alt10,maxDiff3alt10,maxDiff4alt10,maxDiff5alt10,maxDiff6alt10).

desc suma1 to suma10.


DATASET COPY     Unroll.
DATASET ACTIVATE Unroll WINDOW=FRONT.
VARSTOCASES
   /MAKE    Score FROM suma1 TO suma10
   /INDEX = MsgName(Score)
   /NULL  = DROP.

DATASET DECLARE  Summary.
AGGREGATE OUTFILE=Summary
    /BREAK=MsgName
    /Mean 'Mean score'          = MEAN(Score).

DATASET ACTIVATE  Summary  WINDOW=FRONT.
SORT CASES BY Mean (D).
FORMATS  Mean (F7.4).

NUMERIC  Rank (F3).
COMPUTE  Rank = $CASENUM.

LIST.

Can anyone help me with:

Computing individual-level ranks from the counts

R

set.seed(0) # setting the random number seed to enhance comparability
indidualCountsNoTies = individualCounts + matrix(runif(n * nAlternatives)/100000, n) #adding random numbers to break ties
ranks = nAlternatives + 1 - apply(indidualCountsNoTies,1,rank) #ranks
rankProportions = t(apply(ranks,1,table) / n * 100)
round(rankProportions,1)

And the cumulative proportions:

R

ankCumProportions = t(apply(rankProportions,1,cumsum))
round(rankCumProportions,1)


(http://surveyanalysis.org/wiki/Max-Diff_Analysis_Case_Study_Using_R) the syntax above is for R and I would like to do it in SPSS.
mils
Reply | Threaded
Open this post in threaded view
|

Re: MaxDiff analysis

MLIves
Assuming that the maxdiffNaltX items are in order by N then X (i.e. you CAN use the 'to' convention), this would be simpler for the SPSS section in the middle:
If the vars are in a different order, you would need to either reorder them or list each explicitly).
I am not sure why you would use the name 'sum' for a series of means, but I retained the same varnames.

Do Repeat
  suma=suma1 to suma10/
  MD1alt= maxDiff1alt1 to maxDiff1alt10/
  MD2alt= maxDiff2alt1 to maxDiff2alt10/
  MD3alt= maxDiff3alt1 to maxDiff3alt10/
  MD4alt= maxDiff4alt1 to maxDiff4alt10/
  MD5alt= maxDiff5alt1 to maxDiff5alt10/
  MD6alt= maxDiff6alt1 to maxDiff6alt10.
    Compute suma=mean(md1alt,md2alt,md3alt,md4alt,md5alt,md6alt).
End repeat.

Melissa
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of mils
Sent: Tuesday, April 21, 2015 5:55 AM
To: [hidden email]
Subject: Re: [SPSSX-L] MaxDiff analysis

I've got help for:

1. Computing the overall counts for the whole sample and 2. Computing individual-level counts

R

counts = apply(itMaxDiffData, 2, mean, na.rm = TRUE) ranks = nAlternatives + 1 - rank(counts) cbind(Counts = counts, Ranks = ranks)

id = rep(1:n,rep(nBlocks,n))
individualCounts = aggregate(itMaxDiffData,list(id),mean, na.rm = TRUE)[,-1]
round(individualCounts[1:10,],1) #show at data for first 10 respondents

SPSS

comp
suma1=mean(maxDiff1alt1,maxDiff2alt1,maxDiff3alt1,maxDiff4alt1,maxDiff5alt1,maxDiff6alt1).
comp
suma2=mean(maxDiff1alt2,maxDiff2alt2,maxDiff3alt2,maxDiff4alt2,maxDiff5alt2,maxDiff6alt2).
comp
suma3=mean(maxDiff1alt3,maxDiff2alt3,maxDiff3alt3,maxDiff4alt3,maxDiff5alt3,maxDiff6alt3).
comp
suma4=mean(maxDiff1alt4,maxDiff2alt4,maxDiff3alt4,maxDiff4alt4,maxDiff5alt4,maxDiff6alt4).
comp
suma5=mean(maxDiff1alt5,maxDiff2alt5,maxDiff3alt5,maxDiff4alt5,maxDiff5alt5,maxDiff6alt5).
comp
suma6=mean(maxDiff1alt6,maxDiff2alt6,maxDiff3alt6,maxDiff4alt6,maxDiff5alt6,maxDiff6alt6).
comp
suma7=mean(maxDiff1alt7,maxDiff2alt7,maxDiff3alt7,maxDiff4alt7,maxDiff5alt7,maxDiff6alt7).
comp
suma8=mean(maxDiff1alt8,maxDiff2alt8,maxDiff3alt8,maxDiff4alt8,maxDiff5alt8,maxDiff6alt8).
comp
suma9=mean(maxDiff1alt9,maxDiff2alt9,maxDiff3alt9,maxDiff4alt9,maxDiff5alt9,maxDiff6alt9).
comp
suma10=mean(maxDiff1alt10,maxDiff2alt10,maxDiff3alt10,maxDiff4alt10,maxDiff5alt10,maxDiff6alt10).

desc suma1 to suma10.


DATASET COPY     Unroll.
DATASET ACTIVATE Unroll WINDOW=FRONT.
VARSTOCASES
   /MAKE    Score FROM suma1 TO suma10
   /INDEX = MsgName(Score)
   /NULL  = DROP.

DATASET DECLARE  Summary.
AGGREGATE OUTFILE=Summary
    /BREAK=MsgName
    /Mean 'Mean score'          = MEAN(Score).

DATASET ACTIVATE  Summary  WINDOW=FRONT.
SORT CASES BY Mean (D).
FORMATS  Mean (F7.4).

NUMERIC  Rank (F3).
COMPUTE  Rank = $CASENUM.

LIST.

Can anyone help me with:

Computing individual-level ranks from the counts

R

set.seed(0) # setting the random number seed to enhance comparability indidualCountsNoTies = individualCounts + matrix(runif(n * nAlternatives)/100000, n) #adding random numbers to break ties ranks = nAlternatives + 1 - apply(indidualCountsNoTies,1,rank) #ranks rankProportions = t(apply(ranks,1,table) / n * 100)
round(rankProportions,1)

And the cumulative proportions:

R

ankCumProportions = t(apply(rankProportions,1,cumsum))
round(rankCumProportions,1)


(http://surveyanalysis.org/wiki/Max-Diff_Analysis_Case_Study_Using_R) the syntax above is for R and I would like to do it in SPSS.



-----
mils
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/MaxDiff-analysis-tp5729270p5729292.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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

This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately.  Please notify the sender if you have received this email in error.  NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.

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