Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help! Changing similarity to dissimilarity matrix (from Elzinga spell measures to clustering)

    Hi everyone! If someone could advise me, you'd be a lifesaver:

    Doing Sequence analysis and trying to cluster based on similarity/ dissimilarity.

    Im using Elzinga's duration-weighted spell measure (combinadd) as the method of distance (X/t)
    Halpin (2017) http://teaching.sociology.ul.ie/bhal...main-local.pdf, p 6.

    combinprep, state(Element) length(p) idvar(hetu_id) nspells (ööö)
    local spmax = r(maxspells)
    combinadd Element1-p`spmax', pwsim(xts) nspells(ööö) nstates(6) rtype(d)

    This far, it works

    Only, to get to sensible clustering (clustermat wards) one apparently needs to change the Elzinga method's SIMILARITY matrix into dissimilarity/ distance measures
    according to Halpin (2007) http://teaching.sociology.ul.ie/seqanal/essex/labs.pdf, p 15-16.

    set matsize 10000
    matrix altxts = J(_N,_N,1) - xts

    BUT I get "negative dissimilarities found in altxts"

    What's wrong, HOW CAN I change from SIMILARITY MATRIX TO DISSILARITY MATRIX in order to move to clustering?


    Appreciation and gratitude for help


    ps.
    I've also tried:

    matrix dissimilarity altxts = xts, dissim(standard)

    following https://www.stata.com/manuals13/mvma...similarity.pdf
    But it doest work as this commads would be












  • #2
    Sorry to reply so late: I've not been monitoring Stata Forum lately. This is likely too late to be of any use but for the record:

    The rtype() option controls whether you get similarities or distances, and rtype(d) gives distances, so you didn't need to do anything.

    Unfortunately, the Essex notes that you were using are very out of date. The most current account of SADI is the 2017 Stata Journal article.

    Comment

    Working...
    X