Sunday 17 December 2017

Bästa binary optioner diagram of kvadrat funktioner


Binär Obegränsad Kvadratisk Optimering Problem. Gary A Kochenberger Affiliated med Business School, University of Colorado E-post författare. Fred Glover är ansluten till OptTek Systems, Inc. Haibo Wang är ansluten till Företagsekonomiska högskolan, Texas AM International University. Under de senaste åren har det obegränsade kvadratiska binära programmet UQP uppstått som en enhetlig ram för modellering och lösning av en mängd olika kombinatoriska optimeringsproblem. Oväntad mångsidighet i UQP-modellen öppnar dörrar till lösningen av en mängd olika viktiga och utmanande applikationer. Utvecklingen inom detta utvecklingsområde illustreras genom att beskriva metodiken med exempel och genom att rapportera omfattande beräkningserfarenhet som visar lönsamheten och robustheten hos de senaste metoderna för att lösa UQP-modellen visar att de får lösningar på vidsträckta instanser av modellen som konkurrerar med eller överträffar de bästa lösningarna som erhållits idag är de bästa specialanpassade algoritmerna. Detta är en uppdaterad version av det föregående papperet som ges i 38.B Alidaee, G Kochenberger, A Ahmadian, 0-1 kvadratisk programmeringsmetod För den optimala lösningen av två schemaläggningsproblem Int J Syst Sci 25 401 408 1994 MathSciNet CrossRef MATH. B Alidaee, G Kochenberger, F Glover, C Rego, En ny modellering och lösningsmetod för nummerpartitioneringsproblemet J Appl Math Decis Sci 9 2 , 113 121 2005 MathSciNet CrossRef. B Alidaee, F Glover, G Kochenberger, H Wang, Lösning av det maximala kantviktsproblemet genom obegränsad kvadratisk programmering Eur J Oper Res 181 592 587 2007 CrossRef MATH. B Alidaee, G Kochenberger, K Lewis, M Lewis, H Wang, Ett nytt sätt att modellera och lösa uppsatta packproblem via obegränsad kvadratisk binär programmering Eur J ELLER 186 2, 504 512 2008 MathSciNet MATH. B Alidaee, G Kochenberger, K Lewis, M Lewis, H Wang, Computationally attraktiv Icke-linjära modeller för kombinatorisk optimering Int J Math Oper Res 1 1 och 2, 9 20 2009 CrossRef MATH. TM Alkhamis, M Hasan, MA Ahmed, Simulerad glödgning för den obestridna binära kvadratiska pseudobololefunktionen Eur J Oper Res 108 641 65 2 1998 CrossRef MATH. M Amini, B Alidaee, G Kochenberger, En scatter-sökmetod för obestridna kvadratiska binära program, i New Methods Optimization ed av D Corne, M Dorigo, F Glover McGraw-Hill, England, 1999, s. 317 330. JE Beasley, Heuristiska algoritmer för det obestridda binära kvadratiska programmeringsproblemet Arbetspapper, Imperial College, 1999. A Billionnet, A Sutter, Minimering av en kvadratisk pseudoboolsk funktion Eur J ELLER 78 106 115 1994 MATH. B Borchers, J Furman, A Tvåfas exakt algoritm för Max-Sat och viktad Max Sat J Comb Optim 2 299 306 1999 MathSciNet CrossRef MATH. E Boros, P Hammer, Max-cut-problemet och kvadratisk 0-1 optimering, polyhedriska aspekter, avslappningar och gränser Ann OR 33 151 225 1991 MathSciNet CrossRef MATH. E Boros, A Prekopa, Probabilistiska gränser och algoritmer för det maximala uppfyllbarhetsproblemet Ann ELLER 21 109 126 1989 MathSciNet CrossRef MATH. E Boros, P Hammer, X Sun, DDT-metoden för kvadratisk 0-1 Minimering, RUTCOR Research Cent RRR 39 89, 1989. JM Bourjolly, P Gill, G Laporte, H Mercure, En kvadratisk 0 1 optimeringsalgoritm för maximala klick och stabila uppsatta problem Arbetsblad, University of Montreal, 1994.P Chardaire, A Sutter, A Sönderdelningsmetod för kvadratisk noll-en programmering Hantera Sci 41 4, 704 712 1994 CrossRef. G Cornuejolos, Combinatorial Optimization Packaging and Covering CBMS-NSF SIAM, Philadelphia, 2001 CrossRef. CM De Simone, M Diehl, P Junger, Mutzel, G Reinelt , G Rinaldi, Exakt grund State4s av Ising spinglas nya experimentella resultat med en gren - och klippalgoritm J Stat Phys 80 487 496 1995 CrossRef MATH. X Delorme, X Gandibleau, J Rodriques, GRASP för setpackning EJOR 153 564 580 2004 CrossRef MATH. B Eksioglu, R Demirer, I Capar, Subsetval i flera linjär regression en ny matematisk programmeringsmetod Comput Ind Eng 49 155 167 2005 CrossRef. R Forrester, H Greenberg, Kvadratiska binärprogrammeringsmodeller i beräkningsbiologi Algoritmisk Oper Res 3 110 129 2008 MathSciNet. F Glover, G Kochenberger, Handbok av Metaheuristic Kluwer Academic, Boston Dordrecht London, 2003.F Glover, M Laguna, Tabu Sök Kluwer Academic, Boston, 1997 CrossRef MATH. F Glover, G Kochenberger, B Alidaee, Adaptive Memory Tabu Sök efter binära kvadratiska program Hantera Sci 44 3, 336 345 1998 CrossRef MATH. F Glover, G Kochenberger, B Alidaee, MM Amini, Tabu med sökkritisk händelseminne, en förbättrad applikation för binära kvadratiska program, i MetaHeuristics Framsteg och trender i lokal sökning Paradigmer för optimering av S Voss, S Martello, I Osman, C Roucairol Kluwer Academic, Boston, 1999.F Glover, B Alidaee, C Rego, G Kochenberger, One-pass heuristics för storskaliga obegränsade binära kvadratiska program EJOR 137 272 287 2002 MathSciNet CrossRef MATH. F Glover, G Kochenberger, B Alidaee, M Amini, Lösning av kvadratiska ryggsäcksproblem genom omformulering och tabu-sökning i ett begränsat fall, i kombinatorisk och global optimering utarbetad av PM Pardalos, En Migdalas, R Burkard World Scientific, River Edge, 2002, pp 111 121 CrossRef. F Glover, JK Hao, G Kochenberger, Z Lu, H Wang, Lösning av storskaliga maxproblem i tabu sök Arbetspapper, University of Colorado, Denver , 2010.F Glover, Z Lu, JK Hao, Diversifieringsstyrd tabu sökning efter obegränsad binär kvadratisk programmering 4OR 8 3, 239 253 2010 MathSciNet CrossRef MATH. M Grotschel, M Junger, G Reinelt, En applikation av kombinatorisk optimering till statistisk fysik Och kretslayoutdesign Oper Res 36 3, 493 513 1988 CrossRef. P Hammer, S Rudeanu, Boolean Methods in Operations Research Springer, New York, 1968 CrossRef MATH. PB Hansen, Metoder för olinjär 0 1 programmering Ann Discret Math 5 53 70 1979 CrossRef MATH. P Hansen, B Jaumard, Algoritmer för det maximala uppfyllbarhetsproblemet Computing 44 279 303 1990 MathSciNet CrossRef MATH. P Hansen, B Jaumard, V Mathon, begränsad olinjär 0-1 programmering INFORMS J Comput 5 2, 97 119 1993 MathSciNet CrossRef MATH. L D Iasemidis, DS Shiau, JC Sackellares, P Pardalos, Övergång till epileptisk anfall optimering, i DIMACS-serien i diskret matematik och teoretisk datavetenskap American Mathematical Society Publishing, Providence, RI, vol 55 2000, sid 55 73. A Joseph, en samtidig Bearbetningsramar för det inställda partitionsproblemet Comput Oper Res 29 1375 1391 2002 MathSciNet CrossRef MATH. K Katayama, M Tani, H Narihisa, Lösning av stora binära kvadratiska programmeringsproblem med en effektiv genetisk lokalalgoritm, i Proceedings of the Genetic and Evolutionary Computation Conference GECCO 00 Morgan Kaufmann, San Francisco, 2000.G Kochenberger, F Glover, En enhetlig ram för modellering och lösning av kombinatoriska optimeringsproblem en handledning i Multiscale Optimization Methods and Applications utgiven av W Hager, S-J Huang, P Pardalos, O Prokopyev Springer, New York Boston, 2006.G Kochenberger, F Glover, B Alidaee, C Rego, En enhetlig modellerings - och lösningsram för kombinatorisk optimiza Problemlösningar ELLER Spectr 26 237 250 2004 CrossRef MATH. G Kochenberger, F Glover, B Alidaee, C Rego, Lösning av kombinatoriska optimeringsproblem via omformulering och adaptiv minnesmetaheuristics, i Revolutionary Visions in Evolutionary Computation ed av A Menon, D Goldberg Kluwer, Boston , MA, 2004.G Kochenberger, F Glover, B Alidaee, C Rego, En obestridd kvadratisk binär inställning till vertexfärgsproblemet Ann ELLER 139 229 241 2005 MathSciNet CrossRef MATH. G Kochenberger, F Glover, B, Alidaee, K Lewis, Använda det obegränsade kvadratiska programmet för att modellera och lösa max 2-lösproblem Int J Oper Res 1 1 och 2, 89 100 2005 MathSciNet CrossRef MATH. G Kochenberger, F Glover, B Alidaee, H Wang, Clustering av microarray-data via klickpartitionering J Comb Optim 10 77 92 2005 MathSciNet CrossRef MATH. G Kochenberger, B Alidaee, H Wang, En effektiv modellering och lösningsmetod för det generaliserade oberoende uppsatta problemet Optim Lett 1 111 117 2007 Springer-Verlag MathSciNet CrossRef MATH. DJ Laughunn, Kvadratisk binär programmering Oper Res 14 454 461 1970 CrossRef. M Lewis, B Alidaee, G Kochenberger, Använda xQx för att modellera och lösa det okapaciterade uppgiftsallokeringsproblemet ELLER Lett 33 176 182 2005 MathSciNet MATH. M Lewis, G Kochenberger, B Alidaee, Ett nytt modellerings - och lösningsmetod för det uppsatta uppdelningsproblemet Comput OR 35 807 813 2008 MathSciNet CrossRef MATH. M Lewis, B Alidaee, F Glover, G Kochenberger, En notering om xQx som modellerings - och lösningsram för linjär ordering Problem Int J OR 5 2, 152 162 2009 MATH. A Lodi, K Allemand, TM Liebling, En evolutionär heuristisk för kvadratisk 0-1 programmering Teknisk rapport OR-97-12, DEIS University of Bologna, 1997.P Merz, B Freisleben , Genetiska algoritmer för binär kvadratisk programmering, i Proceedings av 1999 års internationella genetiska och evolutionära beräkningskonferens GECCO 99 Morgan Kaufmann, San Francisco 1999, s. 417 424. Mingozzi, M Boschetti, S Ricciardelli, L Blanco, En uppsättning av partitionering t O planeringsproblemet för besättningen Oper Res 47 6 873 888 1999 CrossRef MATH. M Padberg, På ansiktsstrukturen hos uppsatta packningspolyeder Mathprogram 5 199 215 1973 MathSciNet CrossRef MATH. G Palubeckis, En heuristisk gren och bunden algoritm för den obestridda kvadratiska Noll-ett programmeringsproblem Dator 54 284 301 1995 MathSciNet CrossRef. P Pardalos, GP Rodgers, Beräkningsaspekter av en gren och bunden algoritm för kvadratisk noll-en-programmering Dator 45 131 144 1990 MathSciNet CrossRef MATH. P Pardalos, GP Rodgers, En filial Och bunden algoritm för maximal klickproblem Komput ELLER 19 363 375 1992 CrossRef MATH. A Pekec, M Rothkopf, Kombinatoriell auktionsdesign Hantera Sci 49 11, 1485 1503 2003 CrossRef MATH. M Ronnqvist, optimering inom skogsbruk Mathprogram B 97 267 284 2003 MathSciNet. L Schrage, Optimeringsmodellering med LINDO Duxbury, Pacific Grove, 1997.R Vemuganti, Tillämpningar av setbeläggning, setpackning och uppsättning av partitioneringsmodeller en undersökning, i Handbook of Combinatori Al Optimering utarbetad av D Zhu, P Pardalos Kluwer Academic, Boston, MA, 1998.H Wang, B Alidaee, F Glover, G Kochenberger, Lösning av gruppteknologiproblem via klickavdelning Int J Flex Manuf 18 77 97 2006 CrossRef MATH. H Wang , T Obremski, B Alidaee, G Kochenberger, Clique-partitionering för att klustra en jämförelse med K-Means och latent klassanalys. Commun Stat 37 1, 1 13 2008 MathSciNet MATH. Om detta referensarbete Entry. Title Binär Obegränsad Kvadratisk Optimeringsproblem Referens Arbetstitel Handbok för kombinatorisk optimering Sidor sid 533-557 Upphovsrätt 2013 DOI 10 1007 978-1-4419-7997-115 Skriv ut ISBN 978-1-4419-7996-4 Online ISBN 978-1-4419-7997-1 Utgivare Springer New York Copyright Hållare Springer Science Business Media New York Ytterligare länkar. Om denna referens Work. Industry Sectors. Finance, Business Banking. Consumer Packaged Goods. Oil, Gas Geosciences. eBook Packages. Mathematics and Statistics. Panos M Pardalos 1.Ding-Zhu Du 2. Ronald L Graham 3.Editor Affiliati Ons.1 Institutionen för industri och system Eng, University of Florida.2 Institutionen för datavetenskap, University of Texas, Dallas.3 Dept Comp Sci Engineering, University of California, San Diego. Gary A Kochenberger 4.Fred Glover 5.Haibo Wang 6.Author Affiliations.4 School of Business, University of Colorado, 1250 14th Street, Suite 215, 80217, Denver, CO, USA.5 OptTek Systems, Inc, 2241 17th Street, 80302, Boulder, CO, USA.6 College of Företagsekonomi, Texas AM International University, 78041, Laredo, TX, USA. Fortsätt läsa. För att se resten av innehållet, vänligen följ nedladdningen PDF-länken ovan. Polynomiskt lösbara fall av binära kvadratiska program. Slutliga bruttopriser kan variera beroende på lokal moms. Vi sammanfattar i detta kapitel polynomiskt lösliga subklasser av binära kvadratiska programmeringsproblem som studerats i litteraturen och rapporterar några nya polynomiskt lösliga underklasser som avslöjas i vår senaste forskning. Det är välkänt att det binära kvadratiska programmeringsprogrammet är NP-hård allmänhet Identifiera polynomiskt lösliga subklasser av binära kvadratiska programmeringsproblem erbjuder inte bara teoretisk inblick i problemets komplicerade natur utan ger också plattformar för att utforma avslappningsplaner för exakta lösningsmetoder. Vi diskuterar och analyserar i detta kapitel sex polynomiskt lösliga underklasser av Binära kvadratiska program, inklusive problem med speciella strukturer i matrisen Q för den kvadratiska objektivfunktionen, problem definierade av ett speciellt diagram eller en logisk krets och problem som kännetecknas av nollduktighetsgapet i SDP-relaxeringsexemplen och geometriska illustrationer presenteras för att tillhandahålla algoritmiskaOch intuitiva insikter i problemen. Binär kvadratisk programmeringspolynom löslighet serie-parallell graflogik krets lagrangian dual SDP relaxation. How att lösa kvadratiska Equationsbine alla liknande termer och flytta dem till ena sidan av ekvationen Det första steget att factoring en ekvation är Att flytta alla villkor till en sida av ekvationen, hålla x 2 termen positiv För att kombinera termerna, lägg till eller subtrahera alla x 2-termerna, x-termerna och konstanternas heltal, flytta dem till ena sidan av Ekvationen så att inget förblir på andra sidan När den andra sidan inte har några återstående termer kan du bara skriva 0 på den sida av lika tecken. Så här gör du det 1.2 x 2 8 x 4 3 xx 2 -8x-4 3x-x.2 x 2 x 2 8 x 3 x 4 0 x -8x-3x-4 0,3 x 2 11 x 4 0 -11x-4 0.Faktor uttrycket För att faktor uttrycket måste du använda faktorerna för X 2 termen 3 och faktorerna med den konstanta termen -4, för att göra dem multiplicera och sedan lägga upp till medellång sikt, -11 Här är hur du Gör det. Eftersom 3 x 2 bara har en uppsättning möjliga faktorer, 3 x och x kan du skriva de i parentes 3 xx 0. Använd sedan elimineringsprocessen för att koppla in faktorerna 4 för att hitta en kombination som producerar - 11x när multiplicerad Du kan antingen använda en kombination av 4 och 1 eller 2 och 2 eftersom båda dessa nummer multipliceras för att få 4. Kom bara ihåg att en av termen ska vara negativ, eftersom termen är -4. Försök och fel , Prova den här kombinationen av faktorer 3 x 1 x 4 När du multiplicerar dem får du 3 x 2 12 xx 4 -12x x-4 Om du kombinerar villkoren 12 x och x får du 11 x vilket är medeltiden du Syftade till att du just har tagit hänsyn till den kvadratiska ekvationen. Som ett exempel på försök och fel, låt oss försöka kolla en factoring-kombination för 3 x 2 11 x 4 0 -11x-4 0 som är ett fel inte fungerar 3 x 2 x 2 3 x 2 6 x 2 x 4 6x-2x-4 Om du kombinerar dessa villkor får du 3 x 2 4 x 4 -4x-4 Även om faktorerna -2 och 2 multiplicerar för att göra -4, gör medelfristen Inte fungera, för att du nej Ded att få 11 x inte 4 x. Sätt varje uppsättning parentes lika med noll som separata ekvationer Detta leder dig att hitta två värden för x som gör hela ekvationen lika med noll, 3 x 1 x 4 0 Nu när du har Fakturerade ekvationen, allt du behöver göra är att uttrycka i varje uppsättning parentes lika med noll men varför - för att få noll genom multiplicering har vi principen, regeln eller egenskapen att en faktor måste vara noll, åtminstone En av faktorerna inom parentes, eftersom 3 x 1 x 4 måste vara noll så måste antingen 3x 1 eller annars x - 4 vara lika med noll. Så skulle du skriva 3 x 1 0 och också x 4 0. Lossa varje nollställd ekvation oberoende I En kvadratisk ekvation kommer det att finnas två möjliga värden för x Hitta x för varje möjligt värde av x en efter en genom att isolera variabeln och skriva ner de två lösningarna för x som den slutliga lösningen Så här gör du det.3x -1 med Subtrahera.3x 3 -1 3 genom dividing. x -1 3 simplified. x 4 genom att subtrahera. x -1 3, 4 genom att göra en uppsättning möjliga separata lösningar, mig Aning x -1 3 eller x 4 verkar bra. Vi har 3 -1 3 1 -1 3 4 0 genom att ersätta -1 1 -4 1 3 0 genom att förenkla 0 -4 1 3 0 genom att multiplicera därför 0 0 Ja, x -1 3 works. We har 3 4 1 4 4 0 genom att ersätta 13 4 4 0 genom att förenkla 13 0 0 genom att multiplicera 0 0 Ja, x 4 works. So, båda lösningarna kontrolleras separat och båda verifieras som arbetande och korrekta För två olika lösningarbina alla liknande termer och flytta dem till ena sidan av ekvationen Flytta alla villkor till ena sidan av lika tecknet, hålla x 2 termen positiv Skriv orden i fallande ordning av grader, så att x 2 term kommer först, följt av x-termen och den konstanta termen Så här gör du det.4x 2 - 5x - 13x2 -5.4x 2 - x 2 - 5x - 13 5 0. Skriv ner den kvadratiska formeln Kvadratiska Formel är bb 2 4 ac 2 a -4ac 2. Identifiera värdena för a, b och c i den kvadratiska ekvationen Variabeln a är koefficienten för x 2-termen, b är x-koefficienten och c är Konstanten För ekvationen 3x 2 -5x - 8 0, a 3, b -5 och c -8 Skriv ner det här. Sätta in värdena på a, b och c i ekvationen Nu när du känner till värdena för de tre variablerna, kan du bara koppla in dem i ekvationen som This. With matematiken När du har kopplat in siffrorna, gör återstående matte för att förenkla positiva eller negativa tecken, multiplicera eller kvadrera de återstående termerna. Så här gör du det. Förenkla kvadratroten Om siffran under radikalsymbolen är En perfekt kvadrat, får du ett heltal Om numret inte är ett perfekt kvadrat, förenkla sedan till sin enklaste radikala version Om numret är negativt, och du är säker på att det skulle vara negativt, blir rötterna komplexa I Det här exemplet 121 11 Du kan skriva det x 5 - 11 6.Lös för de positiva och negativa svaren Om du har eliminerat kvadratrotsymbolen kan du fortsätta tills du har hittat de positiva och negativa resultaten för x Nu när du Har 5 - 11 6, du kan skriva två alternativ. Lös för de positiva och negativa svaren Jus T gör matematiken. Förenkla För att förenkla varje svar, dela dem bara med det största talet som är jämnt delbart i båda talen. Dela den första fraktionen med 2 och dela den andra med 6, och du har löst för x. Method Three of Three Avsluta kvadratredigeringen. Flytta alla termer till ena sidan av ekvationen Se till att a eller x 2 termen är positiv Här är hur du gör det 3. I denna ekvation är termen 2, b termen är - 12 och c termen är -9.Move c termen eller konstant till den andra sidan Den konstanta termen är den numeriska termen utan en variabel Flytta den till ekvations högra sida. Dividera båda sidorna med koefficienten för a eller X 2 termen Om x 2 inte har någon term framför den och har bara en koefficient på 1, kan du hoppa över det här steget. I så fall måste du dela upp alla termer med 2, som så.2x 2 2 - 12x 2 9 2.Dividera b med två, kvadrera den och lägg till resultatet på båda sidor B-termen i det här exemplet är -6 Här är hur du gör det. Förenkla båda sidorna Faktor villkoren på Vänster sida för att få x-3 x-3 eller x-3 2 Lägg till villkoren på höger sida för att få 9 2 9 eller 9 2 18 2, vilket ger upp till 27 2. Hitta båda sidor av roten Kvadratroten av x-3 2 är helt enkelt x-3 Du kan skriva kvadratroten på 27 2 som 27 2 Därför x - 3 27 2. Förstärka radikalen och lösa x För att förenkla 27 2, leta efter en perfekt kvadrat Inom siffrorna 27 eller 2 eller i deras faktorer Den perfekta rutan 9 kan hittas i 27, eftersom 9 x 3 27 För att ta 9 av radikala tecknet, dra ut siffran 9 från radikalen och skriv nummer 3, dess Kvadratroten utanför det radikala tecknet Lämna 3 i täljaren av fraktionen under det radikala tecknet, eftersom den faktorn 27 inte kan tas ut och lämna 2 på botten. Flytta sedan konstanten 3 på vänster sida av ekvationen till Höger och skriv ner dina två lösningar för x. ,, Mathlab,,,,, Android. Mathlab, .-,,,,, .-,,, - -,,,,. PROFFS-. - - Google-sl en tl ru. . , -,,,,, ln, logsin 2, cos 30, sinh, cosh, tanh, sin sin x cos x x n. 2- 2x 2 3y 2 1 r cos2, x cos t, y sin t, v, x 2 x 1 klämma till zoom-CSV. 1 2 1 3 5 6, 3 1 2. x 1 2 - x 1 x 2-1 0 - x -1,1, x1 x2 1, x1-x2 2,. ,,,,,. PROFFS . , 1 2 3 4,,,,,,. ,,,,,,. , 1 2 3 4,,,,,..Mathlab Apps, LLC 5 2017. Facebook, - PRO-,, PDF. 27 2017.Mathlab Apps, LLC 14 2017. , PDF, online. Diana Tursynkozha 8 2017.Mathlab Apps, LLC 16 2017. ,,,, PDF. Emanuel ka Tawer 6 2017. ,,,,,,,,. 250.Mathlab Apps, LLC 11 2017.He 16, 8, 2 10,,, PDF Online. Chromebooks stöder nya Chromebooks med Google Play. Android 7 0 support. Output format för komplexa tal, Inställningar Calculator. Exact värden för trigonometriska funktioner sin 60 1 2 sqrt 3.Polar form för komplexa nummer 1 30, håll jag i för att komma in. Visual redigering beta, aktivera i Inställningar Calculator. New behörigheter är för valfria videoannonser. Du kan välja att titta på video Annonser för att tjäna PRO-tid..Mathlab Apps, LLC. En introduktion till Stata Graphics. Stata innehåller en rik uppsättning verktyg för att skapa grafik med publiceringskvalitet Mellan de många olika graferna du kan göra och det stora antalet detaljer du kan styra i ett diagram kan Stata-grafik Vara ett skrämmande ämne Men du behöver nog bara göra några olika typer av grafer, och i de flesta fall är standardinställningarna för Stata s bra. Vad mer är, organiserar Stata s Graphical User Interface GUI de olika grafikalternativen på ett intuitivt sätt Så att du kan hitta dem när du behöver dem utan att memorera syntaxen för var och en. Det betyder inte att du inte borde sätta dina grafkommandon i filerna när du har skapat dem, men det betyder att för komplexa grafer kan du använda GUI till Skapa kommandon du kommer att lagra. Stata 10 har också lagt till en grafredigerare som låter dig ändra ett diagram efter att du har skapat det. Detta ger dig ännu mer kontroll över grafen, men i motsats till GUI för att skapa ett diagram ger redaktören inte Du har ett kommando som du kan återupprätta senare Om du senare gör några ändringar i dina data måste du starta din graf över från början Det är sålunda bättre att skapa den graf du vill ha i första hand där det är möjligt, men redaktören är fortfarande En mycket användbar addition. This artikel kommer att diskutera skapa grafer med hjälp av Stata GUI, strukturen i grafkommandotyntaxen utan att bo för mycket på detaljerna, några vanliga typer av diagram och grafredigeraren. Du borde ha någon förtrogenhet med grundläggande Stata innan Börja om du inte tänker börja med Stata för forskare eller Stata för studenter Det bästa sättet att använda den här artikeln är att läsa den på datorn och faktiskt utföra de beskrivna stegen. Exemplen i den här artikeln kommer att använda det autodataset som följer med Stata, börja så med att skriva. För att ladda det, gärna experimentera när du går, speciellt med de inställningar vi inte diskuterar vanligtvis eftersom de är antingen ganska uppenbara eller sällan används. Skapa ett diagram kommer aldrig att förändras E din data, så det värsta som kan hända är att din graf visar sig vara värdelös eller bara ofullständig. Skapa grafer med hjälp av det grafiska användargränssnittet. Vi börjar med en enkel scatterplot med vikt som X-variabeln och mpg som Y-variabeln Stata avser varje graf som har en Y-variabel och en X-variabel som ett twoway-diagram, så klicka på Graphics Twoway-grafen. Nästa steg är att definiera en plot I Stata-termer är en plot en viss specifik data visualiserad på ett visst sätt, Till exempel en scatter plot med mpg på vikt En graf är en hel bild, inklusive axlar, titlar, legender, etc. En enda graf kan innehålla flera plotter Den grundläggande twoway-dialogrutan låter dig definiera så många tomter som du behöver, Plus styra de andra egenskaperna hos grafen. Om du vill definiera en plot klickar du på Skapa Du får då en dialogruta där du kan beskriva den plot du vill Lämna kategorin inställd på Grundläggande plottor och typen som är inställd på Scatter för Y-variabel välj eller Skriv mpg och för X-variabel välj Eller skriv vikt Obs! Linux Stata tillåter dig inte att välja variabler så att du måste skriva in deras namn I Windows Stata kan du heller göra. Om du klickar på Skicka kommer grafen att skapas utan att stänga dialogrutan Här kan du titta över Resultat och sedan enkelt göra justeringar och försök igen Klicka på Skicka nu och du ska få en enkel men professionell utseende scatter plot. Adding More Variables. If du vill lägga till en andra Y-variabel till scatterplot, är det enklaste sättet att skriva in sitt namn i Y-variabelrutan efter den du redan har valt Stata tillåter dig inte att välja flera variabler från listan med musen, men det har inga problem med att förstå flera variabler i rutan Y-variabler så länge du lägger dem där själv. Gör ett förnuftigt diagram med två Y-variabler utan att ha flera skalor Vi behöver variabler med liknande värden Trunkvariabeln kvalificerar, så skriv den i Y-variabelrutan efter mpg och klicka på Skicka igen. Resultatet blir en Scatter plot med båda variablerna Observera hur Stata automatiskt lägger de två variablerna i olika färger och lägger till en legend som förklarar vilken är vilken legendtexten är ritad från de variabla etiketterna, men du kan åsidosätta alla dessa standardbeteenden om du vill. Plocka en delmängd Av data. Om du bara vill inkludera vissa observationer, kan du ange vilka som ska sättas genom att klicka på om i fliken Du kan sedan skriva ett villkor i rutan Om och endast observationer som uppfyller villkoret kommer att ingå i diagrammet Do Skriv inte ordet om det antas. För att bara plotta utländska bilar, skriv utländska i If-rutan. Om det är sant i Stata är det sant och noll är falskt och utländsk kodas i enlighet därmed Således om utländsk motsvarar om utländsk 1 Klicka Skicka in och du får en mycket sparsigare graf. Du kan också använda mer komplicerade uttryck. T ex typ utländsk pris 10000 och du får bara bilarna som är både utländska och kostar mindre än 10 000 i 1978 dollar. Kontrollera Mar Kers. By default stata markeras varje punkt med en liten punkt, men du kan ändra det här första klicket på fliken Plot igen och för bästa resultat ställer du Y-variabeln tillbaka till bara mpg Klicka sedan på Marker Properties Set Symbol till Hollow Circle Nästa check Lägg till Etiketter till markörer och ställ in variabeln och klicka sedan på Submit. Som du ser är varje punkt nu en ihålig cirkel med namnet på bilen som skrivs ut bredvid den men många av namnen överlappar varandra. Du kan förbättra situationen något genom att byta etikett Vinkel till 45 grader, men i allmänhet kan du bara sätta användbara etiketter på ett scatterplot om det har ett litet antal observationer och de spridas ut. Overlaying Plots. Next ska vi kombinera flera plottar Avmarkera Lägg till etiketter till markörer Klicka på Acceptera för att acceptera dessa Inställningar för marköregenskaper och gå tillbaka till fönstret Plot 1 och klicka sedan på Accepter igen för att acceptera plottet som det är och gå tillbaka till det huvudsakliga twoway-fönstret Klicka på Skapa för att lägga till en annan plot i grafen Den här gången kommer vi att göra ett linjeplot Set Tomten typ till Linje och välj igen mpg och vikt som Y - och X-variablerna Klicka på Submit för att se resultatet. Det är nog inte vad du förväntade dig - det verkar faktiskt som ett skribbel. Det är för att Stata drack linjen från observation en till observation Två till observation tre osv. Vad du vill ha är en linje från observationen med den lägsta vikten till den med den näst lägsta vikten osv. Därför inkluderade Stata kryssrutan Sortera på x-variabel Det här ändrar inte den faktiska ordningen för Observationer i din dataset, bara den ordning i vilken de är anslutna i ditt linjeplot. Kontrollera det och klicka på Skicka igen. Den här gången ska du få det graf du förväntade. Notera att medan linjen ansluter alla punkter i sprickplotten Till många punkter som scatterplot inte inkluderar Det s eftersom du inte ställde in ett villkor för linjeplotten, så det s plottar alla observationer i data. Möjligheten att ställa in olika om förhållandena för olika plottar är mycket användbara , Men du noterar att twoway-fönstret har sin egen om i fliken som gäller för alla tomter. Line egenskaper. Du kan styra hur linjen ser ut genom att klicka på Linjeegenskaper. Det vanligaste alternativet här är Mönster Som standard skiljer sig Stata olika Linjeplotor efter färg men det hjälper inte om grafen behöver skrivas ut i svartvitt Så istället kan du ställa in ett mönster för varje rad Alternativt kan du välja ett schema som är utformat för utskrift För att se det i handlingssätt Mönster till Dash också Försök att ställa in Anslutningsmetod till Stairstep. Plotting Subsamples. Let s gå tillbaka till bara plotting mpg vs vikt men den här gången låter s göra de utländska bilarna en färg och de inhemska bilarna ett annat Du kan göra detta genom att skapa två tomter, en för utländska bilar Och en för de inhemska bilarna, som alla har ett om villkor som begränsar det till den riktiga subpopulationen. Då kommer Stata att göra dem olika färger automatiskt. Börja genom att återställa allt Klicka på Acceptera två gånger för att komma tillbaka till mai N twoway fönster och klicka sedan på R-knappen längst ned till vänster för att återställa tomterna Nästa klick Skapa lämna typen som Scatter ställ in Y-variabeln till mpg och sätt in X-variabeln till vikt. Klicka sedan på om och i Om-rutan typ utländska The Utropstecken är Stata för inte så det betyder inte utländsk och motsvarar utländsk 0 Således kommer den här tomten bara att innehålla de inhemska bilarna. Klicka Acceptera för att komma tillbaka till det huvudsakliga twoway-fönstret, klicka sedan på Skapa igen och upprepa hela processen med en viktig Skillnad denna gång i If-rutan skriver du bara utländska Denna tomt kommer endast att innehålla utländska bilar Klicka på Submit för att se resultatet. Det resulterande diagrammet gör de inhemska bilarna blåa och de utländska bilarna röda. Men legenden ger dig ingen indikation som är Vilken för att göra det måste du ta kontroll över legenden själv. Kontrollera hur en graf visas. Du har inte sett några alternativ för att kontrollera legenden eftersom vi hittills har fokuserat på egenskaperna för enskilda tomter Legenden är inte associerad med en viss tomt eftersom den eventuellt innehåller information från alla tomter. Således måste du klicka på Acceptera och gå tillbaka till twoway-fönstret Här kontrollerar du aspekter av grafen som helhet, inklusive Legend. Click på fliken Legend Legendens beteende kontrollerar bara om legenden visas eller inte Eftersom Stata anser att vårt diagram borde ha en och vi är överens kan vi lämna den till Default. Å andra sidan ger standardnycklarna inga Användbar information för den här grafen så vi måste överväga dem Kontrollera Överrätta standardnycklarna I rutan nedan måste du ange numret på varje tomt följt av hur du vill att det ska märkas i citattecken. För denna graftyp.1 Inhemska bilar 2 utländska bilar. Nu klickar du på Submit och du får en graf med en användbar legend. Observera att den ordning i vilken du listar tomterna är den ordning i vilken de kommer att visas i legenden om du skrev 2 utländska bilar 1 Inrikes bilar skulle legenden sätta De utländska bilarna först. Organisationsutseende-knappen öppnar en dialogruta med alla möjliga alternativ för hur legenden ser ut. Klicka på fliken Organisation och sätt Rader kolumner till kolumner som lämnar den till bara en kolumn. Etiketter och regionflikar låter dig För att styra utseendet på legendtexten och hela legendarikboxen. De olika alternativen som storlekar och färger är självförklarande men samma alternativ finns i många olika sammanhang, så det är värt att ta ett ögonblick för att experimentera och se hur de fungerar. some different colors and such just to see how they work Then click Accept to get back to the main twoway window. The Placement button allows you to control where the legend is placed in the graph To understand how locations are specified, imagine putting the face of an analog clock over your graph 12 o clock is the top, 6 o clock the bottom, 3 o clock the right side, etc You can also specify that the legend goes inside the plot region rather than i n the border area around it--just make sure it doesn t cover up anything important. Try setting the Position to 12 o clock and check Place legend inside plot region then click Submit to see the results. You can add a title to the legend using the Title tab of the in the Legend organization and appearance properties window, but you re much more likely to want to add a title to the graph itself To do so click Accept to get back to the main twoway window again, and then click on its Titles tab This gives you four boxes where you can put text the Title Subtitle Caption and Note The easiest way to see what each one means is to try them out, so type Title Subtitle Caption and Note in their respective boxes, and click Submit to see the result. As you see, Title and Subtitle go at the top, while Caption and Note go in the bottom left Each also has a particular font size associated with it However, these are simply defaults Click on the Properties button associated with each one and you can change its position and format Legend titles work in the same way, but they appear inside the legend box. If you want the text to be split across multiple lines, put each line in quotes To see this in action, replace Title with First Line Second Line and click Submit. Next we ll consider the axes of the graph Click on the Y axis tab the X axis tab is identical and the first thing you ll see is the Title box If a plot has just one Y variable, the default title for the Y axis is that variable s label if it has one, or else simply its name If all the plots have multiple Y variables, the default is no title at all However, you can override the default by typing something here, and control its format by clicking Properties Type in Miles Per Gallon and click Submit to see the effect. Major ticks are the marks along the axis with numbers by them that we ve been seeing all along, but by clicking Major tick label properties you can control how many there are and where they are placed This is done by cho osing one of several rules Use the default rule allows Stata to choose, which it usually does pretty well Suggest of ticks leaves most of the control to Stata but allows you to set roughly how many ticks there will be Min Max puts ticks at just the bottom and top of the axis Range Delta gives you complete control as long as you want the ticks to follow a regular rule For example, select Range Delta set the Minimum value to 0, the Maximum value to 40, and the Delta to 5, then click Submit to see the results. The result is a Y axis that starts at zero and has ticks every five units, but note that the graph continues up to 41 because one car got 41 miles per gallon You can extend a graph by extending an axis remember the default version of this graph started at ten but you cannot truncate it Stata will always make the graph big enough to plot all the observations in your data If you really wanted the graph to stop at 40 you d have to add an if condition like mpg 40.Custom rules allow you t o place ticks anywhere you like and have them say whatever you like The syntax is simply a list of numbers and associated labels For example, select Custom and in the Custom rule box type 10 Terrible 20 Mediocre 30 Very Good. The result is a less informative but more eloquent graph You could accomplish the same thing by putting value labels on the variable If you already have value labels assigned just click on the Labels tab and check Use value labels. Every tick does not need a text label For example, you could set the custom rule to 10 Terrible 15 20 Mediocre 25 30 Very Good 35 40 and get ticks every five units with labels at just 10, 20 and 30 However, this will cause the labels to overlap, or at least crowd each other To fix that, click on the Labels tab and set Angle to Horizontal Since this will force Stata to expand the margin to the left of the plot in order to make room for the labels, set the Size to v Small. However, the text labels don t include the numbers 10, 20 or 30, whic h looks odd since the other tick marks do have numbers To make those numbers appear, add them to the end of their respective text labels 10 Terrible 10 15 20 Mediocre 20 25 30 Very Good 30 35 40 That way they ll line up with the other numbers. Minor tick label properties controls smaller ticks that go in between major ticks They follow the same rules as major ticks, but the rules apply to the spaces between the major ticks rather than the whole axis Obviously the default size is smaller as well, but they are otherwise similar. Axis line properties controls the appearance of the axis itself, while Axis scale propertie s controls its scale This includes the ability to change it to a logarithmic scale, to reverse the scale, and to extend the scale but not to truncate it--see the discussion above. Using By with Graphs. Using by in a graph does not give you a completely separate graph for each subpopulation, but it does give you a separate plots within a single graph. The graph we have been work ing with has become unwieldy, so start by clicking the reset button Then set up a scatter plot of mpg on weight just like we have made before Click Accept to go back to the twoway window, then click on the By tab Check the box for Draw subgraphs for unique values of variables and in the Variables box type or select foreign. Click Submit and you ll see two scatter plots side-by-side, one for domestic cars and one for foreign cars. Now replace foreign with rep78 This variable takes on five values, plus it has some missing values Check the boxes for Add a graph with totals and Add graphs for missing values and click Submit. The resulting graph has seven plots one for each of the five standard values taken by rep78 one for observations which are missing rep78 and one for all observations However, the default arrangement of these plots is not particularly attractive, so click on Subgraph organization. One option would be to put all the plots on one row for easy comparison set Style to Compact, Rows Columns to Rows and then the number of rows to 1 Click Submit to see the result--obviously if you wanted to use this you d have to do something about the X axis labels, but you know how to do that. Another possibility would be to go back to the original format, but move the Total graph to the center of the bottom row First set the Style back to Default and Rows Columns back to Default and click Submit to take another look This arrangement has room for nine plots in three rows with three plots each, and Stata numbers them left to right and then top to bottom The Total graph is currently in the seventh position If we tell Stata to leave the seventh position blank, it will automatically move to Total graph to the eighth position, which is in the center of the bottom row To do so, check Force holes in the placement of graphs and in the Holes box type 7 Note that you could put multiple numbers in this box if you wanted to leave multiple holes Click Submit to see the result. Now click Acc ept to get back to the twoway window The Subgraph titles and Subgraph regions are all about controlling appearance and are similar to what you ve seen before Subgraph axes are a little more interesting One problem with our last graph is that Stata tried to reduce clutter by only putting one set of axes per row and column, but given the layout it looks random You can fix that by clicking Subgraph axes and then under Show Axes set both Y axes and X axes to Yes While you re here, also set Rescale axes to Yes for for both axes This tells Stata to choose the scale for each subgraph based on the points it contains rather than choosing one scale for all of them This makes each subgraph look nicer, but makes it impossible to compare them which may be the entire point of the graph. Overall Options. Finally click on the Overall tab to see some general-purpose options for the whole graph. Schemes are stored sets of defaults For example, the Economist scheme implements the graphics guidelines of the journal The Economist The two monochrome schemes s1 monochrome and s2 monochrome are particularly useful if you need to print your graph in black and white Feel free to experiment It s also possible to create your own schemes Try setting Scheme to s1 monochrome and then click Submit. Graph size can be confusing because when you re working with the graph in Stata, Stata will fit the graph in whatever size window you choose However, when it comes to printing or exporting the graph Stata will make it match the size you set here. Region properties refers to the Plot region everything inside a plot and the Graph region everything outside a plot This is where you can make global changes to the appearance of your graph like changing background colors. Saving a Graph. Once you ve created the graph you want, you can save it by clicking File Save As in the graph s window However, you should choose what type of file to save it as carefully The default, Stata Graph format has the advantage of allowing you to make further changes to the graph with the graph editor However gph files cannot be placed in other files like Word documents or web pages If you want to put your graph in a Word document use Enhanced Metafile format or for web pages we suggest Portable Network Graphics. Creating Graphs Using Commands. As you worked through the previous sections you ve probably noticed that Stata pasted a command into the Results window every time you created a graph Stata used everything you clicked on to formulate the command, but it s the command that actually created the graph As you can see, the commands to create graphs are often very complicated If you write the commands yourself you may be able to make them somewhat simpler, but not much. So why learn how to create graphs using commands at all First of all, for simple graphs it can be much faster For example, you can create your basic scatter plot of mpg on weight simply by typing. scatter mpg weight. Second, even if you ve created a graph u sing the graphical user interface you may want to modify it by recalling the command and making changes Third, there are a very few things that cannot be done using the graphical user interface. On the other hand, there s little point in trying to learn the proper syntax for every graph option Let the graphical user interface help you with details like choosing text sizes and colors What you need to know is the basic syntax structure, and that s what we ll discuss. No matter how you created your graph, you should store the command in a do file This allows you to recreate the graph later, if needed It also serves as a record of how you created the graph. Graph Commands. All graph commands really come down to one command graph It is followed by either a type of graph e g graph bar or a family of graphs followed by a type of graph e g graph twoway scatter Then comes whatever information is needed to create the graph itself However, the most common graph types and families were also made stand alone commands, which is why you can just type scatter mpg weight. For the ubiquitous twoway family basically graphs with a Y axis and an X axis what follows is a varlist The last variable in the list is taken to be the X variable, and all the others are Y s--similar to how regress handles a varlist but in the opposite way. Graph commands can use if and in just like regular Stata commands they go at the end of the command but before any optionsbining Plots. If you want to include multiple plots in a graph, they must be separated either by putting them in parentheses or by putting two pipe characters between them Thus to create a graph containing two scatter plots of mpg on weight one for foreign cars and one for domestic cars, you can type either. scatter mpg weight if foreign scatter mpg weight if foreign. twoway scatter mpg weight if foreign scatter mpg weight if foreign. Note how in the second case you had to start with twoway That s because a Stata command can t start with a parenthesis, but once you put it in the context of a twoway graph Stata will understand what you mean. Graph commands cannot use the standard by prefix, but most allow a by option that does the same thing. scatter mpg weight, by foreign. Graph options follow the general option rule of going at the end of the command following a comma, but by that definition a single graph can contain several commands For example, the Sort on x variable checkbox for line plots translates into the sort option but it has to stay with the line plot if the graph has more than one Thus if you typed. line mpg weight scatter mpg weight, sort. the sort option would be applied to the scatter plot, where it would do little good Instead you should type. line mpg weight, sort scatter mpg weight. Things like titles are also options. scatter mpg weight, title MPG vs Weight. Note that the text of the title does not have to go in quotes--unless it has a comma in it You can use quotes to separate lines, just like when you typed it in the Ti tle box. But what really makes life interesting is when your options have options Suppose you wanted the title to be merely medium large medlarge rather than the default very large vlarge , and also a dark red specifically, cranberry You can make it so with the size and color options, but to make it clear what they are controlling the size and color of they have to go inside the title s parentheses Yet they still follow a single comma Thus the command becomes. scatter mpg weight, title MPG vs Weight, size medlarge color cranberry. Of course it s at this point that it becomes attractive to let the graphical user interface keep track of the proper placement of such things for you, not to mention letting you know that medlarge and cranberry are among the available options. For the rest of this article we ll type out the graph commands rather than using the graphical user interface, partially for practice but mostly because we ll be making fairly simple graphs and that s the quickest way to do so. Other Types of Graphs. Stata can create dozens of different kinds of graphs--for a much larger sampling, see the Visual Overview on Stata s web site This section will discuss a few more that are fairly commonly used at the SSCC. Stata can plot several different kinds of fit lines automatically The most common are lfit linear fit , qfit quadratic fit , lfitci linear fit with confidence intervals and qfitci quadratic fit with confidence intervals They re not very interesting by themselves--usually they re overlaid on a scatter plot The syntax is just like any other twoway graph Type. scatter mpg weight lfit mpg weight. Or if you prefer, set up the scatter plot in the graphical user interface as usual, then add a second plot setting the plot category and type to Fit plots and choosing Linear prediction --but typing it will be a whole lot faster. The versions that show confidence intervals need a little care because they can cover things up Try. scatter mpg weight qfitci mpg weight. Any points within the confidence interval are covered up by the shaded region You can fix that by reversing the order of the plots in the command However, qfitci is not one of the plot types that is recognized by itself, so you need to start with twoway. twoway qfitci mpg weight scatter mpg weight. Now all the points are shown Think of a Stata graph as a painting done with completely opaque paints If you have multiple plots each plot is a layer of paint, and layers that are added later cover up what was there before Thus plots that cover areas should be listed first, and anything that needs to go on top should be listed last. How ever, all these plots do is regress Y on X or Y on X and X 2 and plot the predicted values for Y If you want to run a more complicated regression there s no automatic command to plot the predicted values On the other hand, you can easily store the predicted values in a new variable and plot it. Suppose you wanted to plot the predicted probabilities you got from a logit of foreign on mpg a clear case of reversing cause and effect, but the methodology doesn t care No graph command will do this for you, but you can do it yourself. logit foreign mpg predict phat line phat mpg, sort. The result looks reasonable, but try it as a scatter plot. scatter phat mpg. This demonstrates that the only values of mpg represented in the graph are those represented in your data set and keep in mind many observations have the same value of mpg That may or may not be a problem, but if you wanted to plot a smooth curve over the full range of mpg you could replace the actual values of mpg with made-up numbers that are evenly distributed from 14 to 41.gen realMPG mpg replace mpg 41-14 n-1 N-1 14 predict phat2 scatter phat2 mpg replace mpg realMPG. Note that with multivariate regressions if you want to plot the effect of one variable you will probably need to set the others to their means before making predictions Otherwise the line will jump all over due to the effects of the other variables. Stata does two very different kinds of bar plots twoway bar is just a variation on what we ve seen before. twoway bar mpg weight. But there s also graph bar which is not part of the twoway family It plots summary statistics the default is mean rather than values, and is normally used to compare between variables or between groups Variables are simply listed, and the group variable is specified using the over option For example. graph bar weight price, over foreign. hbar is almost identical--it just turns everything sideways. graph hbar weight price, over foreign. If you want to compare something other than the mean, put that statistic in parentheses before the list of variables. graph hbar median weight price, over foreign. Histograms are very simple to create. Note that by default Stata does not put frequency on the Y axis, but probability density This fits with the idea of a histogram being an approximation to the probability density function, but probably isn t how you were taught to make histograms back in grade school You can have it plot frequencies using the frequency option percent is another that is frequently used. If you don t like Stata s default bins you can take control by either setting the number of bins bin option or the width of a bin width option You can get the same results either way The mpg variable goes from 12 to 41, for a total range of 29 Stata chose eight bins, which means each had a width of 29 8 3 625 If you wanted 10 bins, you could type. hist mpg, bin 10 frequency. But you ll get the exact same graph from. hist mpg, width 2 9 frequency. If you have discrete data, the discre te option tells Stata to choose bins accordingly For example, if you just type. Stata will choose eight bins even though rep78 only has five values The result is a confusing histogram of fairly simple data. However, if you add the discrete option Stata creates five bins for the five values. hist rep78, discrete. The result is a much clearer graph. Kernel Densities. You can overlay a kernel density on your histogram just by adding the kdensity option there s also a normal option to add a normal density. hist mpg, width 2 9 frequency kdensity. You can also create an independent kernel density plot with the kdensity command. The most commonly used option for kernel densities is bwidth which sets the bandwidth Compare. kdensity mpg, bwidth 5.kdensity mpg, bwidth 1.The Graph Editor. Stata includes a graph editor that can be used to modify a graph after it has been created Its big disadvantage is that it doesn t give you a command you can save in a do file and use to recreate the graph at will However, it does allow you to make changes very simply and easily. To see it in action, make a simple scatter plot. scatter mpg weight. Then click File Start Graph Editor You re now ready to make changes to this graph. On the left are several buttons that place the graph editor in a particular mode The top button, the arrow, puts it in pointer mode, which allows you to select an item on the graph to edit For example, if you click on the plot part of the graph i e inside the axes you ll be able to edit the plot region Color and Margin will appear in the tool bar at the top, but if you click More you ll be able to change many more properties. If you then click on a particular point you can change the plot itself Now the immediate options are Plottype Color Size and Symbol but you can again click More to see other things. As you do, note the Object Browser on the right Stata keeps track of the various parts of a graph in a sort of tree structure, and as you click on things it will highlight the object you ve selected You can also select an object directly For example, click title and you can add a title by typing it in the Text box Type in MPG vs Weight 1978 Cars and press Enter to see the results. The next three buttons the large T the diagonal line, and the circle with a plus sign allow you to add text, draw lines and place new points anywhere you need them As an example, let s add the Toyota Prius for comparison 46 mpg and about 3000 pounds for a 2008 four-door The smart way would be to add it to the dataset before making the graph, but we ll do it using the graph editor as an exercise. The first problem is that the graph ends at 42 mpg To fix that select yaxis1 in the Object Browser and click More Then set the Axis rule to Range Delta with a Minimum value of 10 a Maximum value of 50 and a Delta of 5 Click OK and the graph will be rescaled--and more ticks will be added so we have a better chance at marking 46 accurately. Now click the circle with a plus sign on the left and then cli ck as best you can at the location mpg 46 just above the line and weight 3000 This will create a hollow circle at that location by default, but note that you could change its appearance at will Seeing the point on the graph makes it clearer that the real advantage of a Prius over a 1978 VW Diesel the 1978 car with 41 MPG is not the Prius somewhat higher MPG, but the fact that it gets that MPG despite being a much heavier car. Now click on the T to add text and then click to the right of the new point This will give you the Textbox properties window In the Text box type 2008 Toyota Prius for comparison and set the Size to Small Then click OK. The bottom button on the left is the grid editor This allows you to make drastic changes to your graph, like rearranging the parts Use with discretion, and saving your graph before changing anything is highly recommended. This is a good time to mention why you might want to save graphs in Stata format while it s true that you can t put them into docum ents that way, you can make changes to them in the graph editor Thus you might want to keep two copies of important graphs, one in Stata graph format in case you need to make changes, and one in something like format that you can insert into your paper. Last Revised 6 7 2013.

No comments:

Post a Comment