Announcement

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

  • how to calculate the formula ,like Euclidean distance

    hello, everyone!
    Is that anybody know how to calculate the formula,data as follow, many thanks!the formula is like "Euclidean distance"! Dit=(X11-X11)^2+(X11-X21)^2+(X11-X31)^2
    +.....
    Click image for larger version

Name:	WechatIMG65.jpeg
Views:	1
Size:	68.7 KB
ID:	1523498


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long citycode_s int year double awage_employ
    1100 2001         19155
    1100 2002         21852
    1100 2003         25312
    1100 2004         29674
    1100 2005         34191
    1100 2006         40117
    1100 2007         46507
    1100 2008         56328
    1100 2009         58140
    1100 2010         65683
    1100 2011  75834.609375
    1100 2012 85306.0234375
    1100 2013         93997
    1100 2014     103400.41
    1100 2015        113073
    1100 2016        122749
    1100 2017        134994
    1200 2001         14308
    1200 2002         16258
    1200 2003         18648
    1200 2004         21754
    1200 2005         25271
    1200 2006         28682
    1200 2007         34938
    1200 2008         41748
    1200 2009         44992
    1200 2010         52963
    1200 2011  55636.328125
    1200 2012 65398.4296875
    1200 2013         68864
    1200 2014      84833.06
    1200 2015         84187
    1200 2016         87806
    1200 2017         96965
    end


  • #2
    Assuming that t corresponds to your variable year, I corresponds to citycode_s, and x corresponds to awage_employ:

    Code:
    preserve
    tempfile copy
    rename (citycode_s awage_employ) =_2
    save `copy'
    
    restore
    joinby year using `copy'
    
    by citycode_s citycode_s_2, sort: egen double wanted = total((awage_employ - awage_employ_2)^2)
    replace wanted = sqrt(wanted)

    Comment


    • #3
      thanks very much

      Comment

      Working...
      X