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

  • How to 'zoom' in on the central area of a graph, after mca

    I am using Stata 15.1
    I would like to create a secondary graph that focuses in on the output of a joint correspondence analysis. The sample code below uses the dataset as per the Stata manual info for MCA. When this graph is created i would ideally like to be able to place a rectangle around the points x = -2,2 y = -2,2 and then produce another graph that focuses on that area. Can someone please help me with code to do this?


    mca A-D, method(joint) normalize(principal)
    mcaplot, overlay origin

  • #2
    Thanks for the reproducible example. I do not think that you will be able to do this within mcaplot. Your best bet is to reconstruct the graph using twoway. I suspect that there is a way to get the inputs used to create the mcaplot graph using post estimation commands, but I am no expert here. However, Scott Merryman shows in this link how you can recover the inputs from any Stata graph, so here is a first attempt at recreating the graph.

    use, clear
    mca A-D, method(joint) normalize(principal)
    mcaplot, overlay origin
    graph save "Graph1", replace
    gr use "C:\Users\709554\Desktop\Graph.gph"
    serset dir
    serset use
    local names ""
    foreach l in A B C D{
         local names "`names' dimension1`l' dimension2`l' coord`l'"
    rename ( __000000- __00000B ) (`names')
    gen id=_n
    reshape long dimension1 dimension2 coord, i(id) j(which) string
    tw (scatter dimension1 dimension2 if which=="A", mlab(coord)) ///
    (scatter dimension1 dimension2 if which=="B", ///
    mlab(coord)) (scatter dimension1 dimension2 if which=="C", ///
    mlab(coord)) (scatter dimension1 dimension2 if which=="D", ///
    mlab(coord) xline(0) yline(0)  title("MCA coordinate plot"))
    graph save "Graph2", replace
    gr combine Graph1.gph Graph2.gph
    You can now add your manipulations. You can restrict the data using the -if- qualifier.
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	111.7 KB
ID:	1531268