Ellipse containing percentage of given points in R

后端 未结 1 1280
自闭症患者
自闭症患者 2020-12-14 13:18

I\'m drawing F1/F2 vowel graph (an example is here). Each vowel has several points/values, and I\'d like to draw an ellipse around the points, so that:

  • ellipse
相关标签:
1条回答
  • 2020-12-14 13:32
    require(car)
     x=rnorm(100)
     y=1+.3*x+.3*rnorm(100)
     dataEllipse(x,y, levels=0.80)
    

    So with your data:

    with(olm ,dataEllipse(ol.f1, ol.f2, levels=0.8) )
    

    Another package, mixtools, has similar capabilities but uses the alpha level rather than the 1-alpha:

     mu <- with(olm, c(mean(ol.f1), mean(ol.f2)) )
     sigma <- var(olm)  # returns a variance-covariance matrix.
     sigma
    #          ol.f1     ol.f2
    #ol.f1 1077.2098  865.9306
    #ol.f2  865.9306 2090.2021
    
    require(mixtools)
    #Loading required package: mixtools
    #Loading required package: boot
    # And you get a warning that ellipse from car is masked.
    
    ellipse(mu, sigma, alpha=0.2, npoints = 200, newplot = FALSE)
    

    Which would overlay the earlier plot with the new estimate (which is slightly narrower in this case.This is the comparison of the two methods

    0 讨论(0)
提交回复
热议问题