Friday 28 July 2017

Stata marginsplot ไบนารี ตัวเลือก


การสำรวจผลลัพธ์การถดถอยโดยใช้ Margins เมื่อคุณได้เรียกใช้การถดถอยแล้วความท้าทายต่อไปคือการคิดว่าผลลัพธ์มีความหมายคำสั่ง Margin เป็นเครื่องมือที่มีประสิทธิภาพในการทำความเข้าใจกับโมเดลและบทความนี้จะแสดงวิธีการใช้งาน ส่วน 1 และ 2 จะถูกนำมาโดยตรงจากส่วนสถิติของ Stata สำหรับนักวิจัยพวกเขาจะทำซ้ำที่นี่เพื่อประโยชน์ของผู้ที่มองหาเฉพาะสำหรับข้อมูลเกี่ยวกับการใช้อัตรากำไรหากคุณคุ้นเคยกับวัสดุที่คุณสามารถข้ามไปยังส่วนที่ 3 การถดถอยของพลังงาน ด้วยคำสั่งที่ไม่เป็นเชิงเส้นคำสั่ง margins สามารถใช้ได้เฉพาะหลังจากที่คุณเรียกใช้การถดถอยและทำงานกับผลลัพธ์ของคำสั่ง regression ล่าสุดสำหรับตัวอย่างแรกของเราให้โหลดชุดข้อมูลอัตโนมัติที่มาพร้อมกับ Stata และเรียกใช้การถดถอยต่อไปนี้.sysuse auto reg price mpg displacement. Levels ของตัวแปรผลลัพธ์ถ้าคุณเพียงแค่ type. all โดยตัวเอง Stata จะคำนวณค่าที่คาดการณ์ของตัวแปรขึ้นอยู่กับการสังเกตแต่ละครั้ง hen รายงานค่าเฉลี่ยของการคาดการณ์ดังกล่าวพร้อมกับข้อผิดพลาดมาตรฐาน t สถิติ ฯลฯ ถ้าอัตรากำไรตามด้วยตัวแปรเด็ดขาด Stata แรกระบุระดับทั้งหมดของตัวแปรเด็ดขาดแล้วสำหรับแต่ละค่าจะคำนวณว่าหมายถึงค่าเฉลี่ยที่คาดการณ์ไว้ ค่าของตัวแปรตามจะเป็นถ้าข้อสังเกตทั้งหมดมีค่าสำหรับตัวแปรประเภทตัวแปรอื่น ๆ ทั้งหมดจะไม่ถูกเปลี่ยนแปลง Thus. first ถามว่าราคาเฉลี่ยเท่าไรถ้ารถยนต์ทั้งหมดเป็นของในประเทศ แต่ก็ยังมีน้ำหนักที่มีอยู่ displacements ฯลฯ แล้วถามว่าราคาเฉลี่ยจะเป็นอย่างไรถ้ารถยนต์ทั้งหมดต่างประเทศทำเช่นเดียวกันสำหรับทั้งห้าค่าของ rep78 แต่เนื่องจากมีจำนวนมากดังนั้นจึงเป็นผู้สมัครที่ดีสำหรับงานนำเสนอแบบกราฟิกคำสั่ง marginsplot ใช้ผลของหน้าที่ margins และเปลี่ยนให้เป็นกราฟสำหรับขอบตัวแปรอย่างต่อเนื่องอย่างเห็นได้ชัดสามารถ t ดูค่าที่เป็นไปได้ทั้งหมด แต่คุณสามารถระบุค่าที่คุณต้องการตรวจสอบกับตัวเลือกที่.margins ที่น้ำหนัก 2000 4000 นี่คำนวณค่าพยากรณ์เฉลี่ยของราคาด้วยน้ำหนักที่กำหนดไว้ที่ 2,000 ปอนด์แล้วอีกครั้งด้วยน้ำหนักที่ตั้งไว้ที่ 4000 ปอนด์คิดว่าแต่ละค่าเป็นสถานการณ์สถานการณ์ข้างต้นเป็นเรื่องง่ายมาก แต่คุณสามารถทำ สถานการณ์ที่ซับซ้อนมากขึ้นโดยการแสดงรายการตัวแปรและค่าต่างๆในตัวเลือกการแสดงผลกำไรจะกำหนดหมายเลขให้กับแต่ละสถานการณ์โดยให้ผลลัพธ์เป็นตัวเลขโดยค่าจะถูกระบุโดยใช้ numlist NUMlist คือรายการของตัวเลขเหมือนกับ varlist เป็นรายการของตัวแปรและเช่น varlist มีหลายวิธีที่แตกต่างกันในการกำหนดหมายเลข numlist ช่วยประเภทเพื่อดูพวกเขาทั้งหมดวิธีที่ง่ายที่สุดคือเพียงแค่รายการหมายเลขที่คุณต้องการตามข้างต้นคุณยังสามารถกำหนด numlist กับโดย ระบุช่วงเริ่มต้น end. margins ที่น้ำหนัก 1500 500 5000 คำนวณค่าเฉลี่ยที่คาดการณ์ไว้ของราคาด้วยน้ำหนักที่ตั้งไว้ที่ 1500, 2000, 2500, ฯลฯ ถึง 5000 น้ำหนักที่แท้จริงอยู่ในช่วง 1760 ถึง 4840 อีกครั้งนี้เป็นผู้สมัครที่ดีสำหรับกราฟิกผลกระทบของ Covariate ถ้าคุณต้องการดูผลกระทบเล็กน้อยของตัวแปรร่วมหรืออนุพันธ์ของค่าที่คาดการณ์ไว้โดยเฉลี่ยที่เกี่ยวกับตัวแปรร่วมนั้นให้ใช้ตัวเลือก dydx ในกรณีง่ายๆนี้อนุพันธ์เป็นเพียง ค่าสัมประสิทธิ์ใน mpg ซึ่งจะเป็นกรณีสำหรับแบบจำลองเชิงเส้น แต่พิจารณาการเปลี่ยนแปลงน้ำหนักตั้งแต่รุ่นรวมทั้งน้ำหนักและน้ำหนักยกกำลังสองคุณจะต้องคำนึงถึงความจริงที่ว่าการเปลี่ยนแปลงทั้งสองกรณีนี้เป็นความสับสนโดยเฉพาะ แต่ไม่ผิดปกติเนื่องจากค่าสัมประสิทธิ์ใน น้ำหนักเป็นลบ แต่ค่าสัมประสิทธิ์ในน้ำหนักยกกำลังสองเป็นบวกดังนั้นผลสุทธิของการเปลี่ยนน้ำหนักสำหรับรถใดก็ตามจะมากขึ้นอยู่กับน้ำหนักเริ่มต้นของคำสั่งกำไรได้อย่างง่ายดายสามารถบอกคุณได้ผล mean. What กำไรที่นี่จะใช้เวลา ตัวเลขที่มาของราคาที่คาดว่าจะเกี่ยวกับน้ำหนักสำหรับรถแต่ละคันและจากนั้นคำนวณค่าเฉลี่ยในการทำเช่นนั้นอัตรากำไรจะดูที่ข้อมูลที่เกิดขึ้นจริงดังนั้นจึงพิจารณาผลกระทบของการเปลี่ยนแปลง Hond น้ำหนัก Civic จาก£ 1,760 เช่นเดียวกับการเปลี่ยนลินคอล์นคอนติเนนจาก 4,840 น้ำหนักระยะสี่เหลี่ยมมีความสำคัญกับหลังกว่าอดีตมันแล้วค่าเฉลี่ยพวกเขาพร้อมกับรถคันอื่น ๆ เพื่อให้ได้ผลของ 2 362865 หรือว่า น้ำหนักเพิ่มขึ้นของแต่ละปอนด์จะเพิ่มราคาเฉลี่ยที่คาดไว้ไว้ที่ 2 36 หากต้องการดูว่าผลของการเปลี่ยนแปลงน้ำหนักเมื่อมีการเปลี่ยนแปลงน้ำหนักให้ใช้ตัวเลือกอีกครั้งแล้วค่อยคำนวณผลลัพธ์โดยน้ำหนัก dydx ที่น้ำหนัก 1500 500 5000 marginsplot ซึ่งจะบอก เราว่าสำหรับค่าต่ำของน้ำหนักน้อยกว่าประมาณ 2000 น้ำหนักที่เพิ่มขึ้นจริงจะช่วยลดราคาของรถ แต่สำหรับรถส่วนใหญ่ที่เพิ่มขึ้นการเพิ่มขึ้นของน้ำหนักตัวเลือกราคา dydx ยังทำงานสำหรับตัวแปรไบนารี แต่เนื่องจากต่างประเทศได้เข้าสู่รูปแบบเป็น ขอบรู้ว่ามันไม่สามารถใช้อนุพันธ์ที่เกี่ยวกับต่างประเทศเช่นการคำนวณสิ่งที่จะเกิดขึ้นถ้ารถทั้งหมดกลายเป็นเล็กน้อยต่างประเทศมากขึ้นดังนั้นจึงรายงานความแตกต่างระหว่างสถานการณ์ที่ทุกคัน ต่างประเทศและสถานการณ์ที่รถทั้งหมดอยู่ในประเทศคุณสามารถตรวจสอบได้โดยการรันและทำการลบด้วยตัวคุณเองโมเดลผลลัพธ์ที่คาดการณ์และความคาดหมายที่น่าจะเป็นคำสั่งขอบจะเป็นประโยชน์มากยิ่งขึ้นกับโมเดลผลไบนารีเนื่องจากมีความไม่เป็นเชิงเส้นเสมอ ชุดข้อมูลจากหน่วยความจำแล้วโหลดข้อมูล Gradient จากเว็บไซต์ของ SSCC ซึ่งเป็นชุดข้อมูลสมมุติประกอบด้วยนักเรียน 10,000 คนครึ่งหนึ่งของพวกเขามีสถานะทางสังคมและเศรษฐกิจสูงและครึ่งหนึ่งไม่ตรงกับที่ครึ่งหนึ่งของแต่ละกลุ่มได้รับ การแทรกแซงหรือการบำบัดรักษาที่ออกแบบมาเพื่อเพิ่มโอกาสในการสำเร็จการศึกษาตัวแปร grad บอกเราว่าพวกเขาได้ในความเป็นจริงการศึกษาเป้าหมายของคุณคือการกำหนด 1 ว่าการรักษาทำอะไรแตกต่างและ 2 ว่าผลของการรักษาแตกต่างกันไปตามสถานะทางเศรษฐกิจและสังคม SES คุณสามารถตอบคำถามแรกได้ด้วยตัวแบบ logit ที่เรียบง่าย model. logit ถือว่า highSES ค่าสัมประสิทธิ์ในการรักษาเป็นค่าบวกและมีนัยสำคัญ suggestin g การแทรกแซงเพิ่มความน่าจะเป็นของการสำเร็จการศึกษาหมายเหตุว่า highSES มีผลกระทบที่ยิ่งใหญ่กว่าต่อไปตรวจสอบว่าผลกระทบขึ้นอยู่กับ SES โดยการเพิ่มการปฏิสัมพันธ์ระหว่างการจัดอันดับ double. logit กับ highSES ค่าสัมประสิทธิ์ในการรักษา highSES ไม่แตกต่างกันอย่างมีนัยสำคัญจากศูนย์ แต่จริงๆแล้วการรักษานั้นมีผลเหมือนกันโดยไม่คำนึงถึงผลลัพธ์ของ SES ผลลัพธ์ที่ได้ก็คือการตีความในแง่ของอัตราส่วนการถดถอยดังนั้นการถดถอยก่อนหน้านี้ซ้ำกับตัวเลือกหรือเพื่อดูการไล่ระดับ high-end ของ them. logit หรือนี่แสดงให้เราเห็น ว่าอัตราเดิมพันของการจบการศึกษาหากคุณได้รับการรักษาอยู่ที่ประมาณ 2 83 เท่าของอัตราการจบการศึกษาหากคุณไม่ได้รับการรักษาโดยไม่คำนึงถึงนักวิจัย SES ของคุณบางครั้งอาจสับสนกับอัตราความน่าจะเป็นนั่นคือพวกเขากล่าวว่าคุณมีแนวโน้มที่จะจบการศึกษามากขึ้น ได้รับการปฏิบัตินี้ไม่ถูกต้องถ้าคุณถามขอบเพื่อตรวจสอบการโต้ตอบระหว่างสองตัวแปรเด็ดขาดจะสร้างสถานการณ์สำหรับชุดค่าผสมที่เป็นไปได้ทั้งหมดของผู้ที่ ตัวแปรคุณสามารถใช้วิธีนี้เพื่อให้ได้ความน่าจะเป็นที่คาดการณ์ไว้สำหรับการสำเร็จการศึกษาสำหรับทั้งสี่สถานการณ์ที่เป็นไปได้สูง SES ต่ำ SES ไม่ถือว่าไม่ได้รับการรักษาสำหรับนักเรียน SES ต่ำการรักษาเพิ่มความน่าจะเป็นที่คาดหมายของการสำเร็จการศึกษาจากประมาณ 49 ถึงประมาณ 73 สำหรับนักเรียน SES สูง, การรักษาเพิ่มความน่าจะเป็นที่คาดหมายของการสำเร็จการศึกษาจากประมาณ 96 ถึง 98 ตอนนี้ถ้าคุณเสียบความน่าจะเป็นสูตรในการคำนวณอัตราต่อรองคุณจะพบว่าอัตราต่อรองเป็น 2 83 ในทั้งสองกรณีใช้ตัวเลขเต็มรูปแบบจากอัตรากำไรขั้นต้น ไม่ใช่ตัวเลขสองหลักที่ให้มาที่นี่การรักษาจะเพิ่มจำนวนเงินเดียวกันกับฟังก์ชันเชิงเส้นที่ถูกส่งผ่านฟังก์ชันโลจิสติกในทั้งสองกรณี แต่จำได้ว่ารูปร่างของฟังก์ชันโลจิสติกนั้นการรักษามีผลน้อยมากต่อความน่าจะเป็นของการสำเร็จการศึกษาในระดับสูง นักเรียน SES เนื่องจากความน่าจะเป็นไปได้สูงมากที่จะสามารถรับนักเรียน SES ที่ต่ำกว่าได้เป็นส่วนหนึ่งของโลจิสติกส์ที่ลาด stee ชั้นดังนั้นการเปลี่ยนแปลงในฟังก์ชั่นเชิงเส้นมีผลมากขึ้นในความน่าจะเป็นที่คาดการณ์คำสั่งขอบสามารถตอบคำถามได้โดยตรงมากที่สุดผลของการรักษาแตกต่างกันไปกับ SE ด้วยการรวมกันของ dydx และ atmargins การรักษา dydx ที่ highSES 0 1. คุณสามารถทำเช่นนี้กับขอบ highSES, dydx treat อีกครั้งตัวเลขเหล่านี้เป็นตัวเลขเดียวกันกับที่คุณได้รับโดยการลบระดับที่ได้รับข้างต้นเราขอแนะนำให้มองไปที่ระดับตลอดจนการเปลี่ยนแปลงโดยทราบว่าการเปลี่ยนแปลงเริ่มต้นจากอะไรให้มาก เป็นกฎทั่วไปที่ง่ายที่สุดในการเปลี่ยนความน่าจะเป็นที่คาดการณ์ไว้สำหรับวิชาที่อยู่บนขอบคือผู้ที่คาดการณ์ความน่าจะเป็นเริ่มใกล้ 0 5 อย่างไรก็ตามนี่เป็นสมบัติของฟังก์ชันโลจิสติกไม่ใช่ ข้อมูลมันเป็นสมมติฐานที่คุณทำเมื่อคุณเลือกที่จะเรียกใช้แบบ logit. Multinomial Logit. Multinomial รุ่น logit สามารถแม้กระทั่งยากที่จะตีความเพราะค่าสัมประสิทธิ์เพียงเปรียบเทียบสองรัฐ Clear Stata s หน่วยความจำและลำโพง d ชุดข้อมูลต่อไปนี้ซึ่งได้รับการสร้างขึ้นอย่างระมัดระวังเพื่อแสดงข้อผิดพลาดในการตีความผล logit หลายตัวแปรมันมีสองตัวแปรจำนวนเต็ม y ที่ใช้ค่า 1, 2 และ 3 และตัวแปรต่อเนื่อง x พวกเขามีความสัมพันธ์เชิงลบ cor y x ตอนนี้เรียกใช้รูปแบบต่อไปนี้ค่าสัมประสิทธิ์ของ x สำหรับผลลัพธ์ที่ 2 เป็นค่าลบดังนั้นจึงเป็นการบอกว่าเมื่อ x เพิ่มความน่าจะเป็นของ y จะลดลง แต่ในความเป็นจริงไม่ใช่กรณีดังที่คำสั่ง margins จะแสดงให้คุณ. margins, dydx x predict results 2. ตัวเลือกการคาดการณ์ช่วยให้คุณสามารถเลือกอัตรากำไรตอบสนองคือการตรวจสอบผลการคาดการณ์ 2 ระบุว่าคุณสนใจในความเป็นไปได้ที่คาดหวังของผลลัพธ์ 2 และในความเป็นจริงความน่าจะเป็นของผลลัพธ์ 2 เพิ่มขึ้นด้วย x อนุพันธ์เป็น 0 016. สามารถทราบได้อย่างไรว่าค่าสัมประสิทธิ์ของ mlogit เพียงเปรียบเทียบความน่าจะเป็นของผลลัพธ์ที่ให้ไว้กับผลลัพธ์พื้นฐานดังนั้นค่าสัมประสิทธิ์ x จาก -5 34 สำหรับผลลัพธ์ 2 บอกว่าเมื่อ x เพิ่มขึ้น observa tions มีแนวโน้มที่จะย้ายจากผล 2 ถึงผลลัพธ์ 1 ในขณะที่ค่าสัมประสิทธิ์ x เท่ากับ -21 292 สำหรับผลลัพธ์ที่ 3 บอกว่าเมื่อ x เพิ่มการสังเกตมีแนวโน้มที่จะย้ายจากผลลัพธ์ที่ 3 ไปเป็นผลลัพธ์ 1 สิ่งที่ไม่บอกคุณก็คือเมื่อ x เพิ่มขึ้น การสังเกตยังย้ายจากผล 3 ถึง 2 ผลและในความเป็นจริงที่มีผล dominates เคลื่อนไหวจาก 2 เพื่อ 1.You สามารถดูได้ถ้าคุณเปลี่ยนประเภทฐานของ regression. mlogit yx ฐาน 2.Now ค่าสัมประสิทธิ์บอกคุณเกี่ยวกับ ความเป็นไปได้ของแต่ละผลลัพธ์เปรียบเทียบกับผลลัพธ์ที่ 2 และความจริงที่ว่าค่าสัมประสิทธิ์ x เชิงลบสำหรับผลลัพธ์ 3 มีค่ามากกว่าสัมบูรณ์ที่เป็นค่าสัมบูรณ์สำหรับผลลัพธ์ที่ 1 แสดงให้เห็นว่าการเพิ่ม x เพิ่มความน่าจะเป็นของผลลัพธ์ 2. เราขอแนะนำให้ใช้อัตรากำไร เพื่อดูว่าผลลัพธ์การถดถอยของคุณมีความหมายอะไรบ้าง 14 2014.3 Stata Graphics. Stata มีสิ่งอำนวยความสะดวกทางด้านกราฟิกที่ยอดเยี่ยมเข้าถึงได้จากคำสั่งกราฟดูกราฟความช่วยเหลือสำหรับภาพรวมกราฟที่ใช้บ่อยที่สุดในสถิติ s เป็นแปลง XY ที่แสดงจุดหรือเส้นเหล่านี้มีอยู่ใน Stata ผ่านทาง subommand twoway ซึ่งจะมี 31 sub-subcommands หรือพล็อตชนิดที่สำคัญที่สุดที่มีการกระจายและบรรทัดนอกจากนี้เราจะอธิบายพล็อตบาร์สั้น ๆ พร้อมใช้งานผ่าน แถบคำสั่งย่อยและประเภทพล็อตอื่น ๆ สเตท 10 แนะนำตัวแก้ไขกราฟิกที่สามารถใช้เพื่อปรับเปลี่ยนการโต้ตอบได้เราไม่แนะนำการปฏิบัตินี้ แต่เนื่องจากความขัดแย้งกับเป้าหมายของการจัดทำเอกสารและสร้างความมั่นใจว่าการทำสำเนาของขั้นตอนทั้งหมดในการวิจัยของคุณ .3 1 Scatterplots ในส่วนนี้เราจะแสดงแผนภาพไม่กี่แห่งโดยใช้ข้อมูลเกี่ยวกับการลดลงของภาวะเจริญพันธุ์ที่ใช้ครั้งแรกในส่วนที่ 2 1 ในการอ่านข้อมูลจากชนิด Stata ที่ทราบโดยทั่วไป net เพื่อทราบความอยากอาหารของคุณนี่เป็นพล็อตที่เราจะผลิต ในส่วนนี้ 1 1 Simple Scatterplot เพื่อสร้าง scatterplot ง่ายๆของการเปลี่ยนแปลงความอุดมสมบูรณ์โดยการตั้งค่าทางสังคมที่คุณใช้คำสั่งทราบว่าคุณระบุ y ก่อนแล้ว x Stata ป้ายแกนโดยใช้ป้ายชื่อตัวแปรถ้า th ey มีการกำหนดหรือชื่อตัวแปรถ้าไม่คำสั่งอาจจะสั้นเพื่อกระจาย twoway หรือกระจายเพียงหากที่เป็นพล็อตเฉพาะในกราฟตอนนี้เราจะเพิ่มระฆังและ whistles บาง 3 1 2 เส้นประให้สมมติว่าเราต้องการที่จะแสดง สายการถดถอยพอดีเช่นกันในแพคเกจบางอย่างที่คุณจะต้องเรียกใช้การถดถอยคำนวณเส้นติดตั้งแล้ววางแผนมัน Stata สามารถทำทุกอย่างที่ในขั้นตอนเดียวโดยใช้ประเภทพล็อต lfit นอกจากนี้ยังมีพล็อต qfit สำหรับพอดีสมการนี้สามารถ สามารถรวมพล็อตย่อยในวงเล็บหนึ่งยังสามารถรวมพล็อตโดยใช้สองแถบแนวนอน แต่ฉันหาวิธีการใช้วงเล็บ clearer. Now สมมติว่าเราต้องการที่จะนำความเชื่อมั่นวงรอบเส้นถดถอย Stata สามารถทำเช่นนี้กับ ประเภท lfitci พล็อตที่ดึงภาคความเชื่อมั่นเป็นวงดนตรีสีเทานอกจากนี้ยังมีแถบ qfitci สำหรับสมการกำลังสองเนื่องจากวงความมั่นใจสามารถปิดบังบางจุดที่เราวาดภาคแรกและจุดต่อมาโปรดทราบว่าคำสั่งนี้ไม่ได้ t ป้ายชื่อ เขาแกน y แต่ใช้ตำนานแทนคุณสามารถระบุป้ายกำกับสำหรับแกน y โดยใช้ตัวเลือก ytitle และข้ามคำอธิบายที่ค่อนข้างชัดเจนโดยใช้คำอธิบายจากที่นี่เราระบุทั้งสองอย่างเป็นตัวเลือกของคำสั่ง twoway เพื่อให้ตัวเลือกชัดเจนยิ่งขึ้น ผู้อ่านที่ฉันใส่เครื่องหมายจุลภาคที่จุดเริ่มต้นของบรรทัดใหม่ 3 1 3 การติดฉลาก Points. There มีหลายทางเลือกที่ช่วยให้คุณสามารถควบคุมเครื่องหมายที่ใช้สำหรับจุดรวมถึงรูปร่างและสีของพวกเขาดู markeroptions ความช่วยเหลือนอกจากนี้ยังสามารถ ตั้งชื่อจุดโดยใช้ข้อความที่รวมอยู่ในตัวแปรอื่นโดยใช้ตัวเลือก varname mlabel ในขั้นตอนต่อไปเราจะเพิ่มชื่อประเทศลงในพล็อตปัญหาเล็ก ๆ น้อย ๆ หนึ่ง ๆ กับป้ายกำกับคือทับซ้อนกันของคอสตาริก้าและตรินิแดดโตเบโกและในระดับปานามาและปานามา นิการากัวเราสามารถแก้ปัญหานี้โดยการระบุตำแหน่งของฉลากที่สัมพันธ์กับเครื่องหมายโดยใช้นาฬิกา 12 ชั่วโมงดังนั้น 12 จะอยู่ด้านบน 3 คือด้านขวา 6 อยู่ด้านล่างและ 9 อยู่ทางด้านซ้ายและตัวเลือก mlabv เราสร้าง ตัวแปรที่จะถือตำแหน่งที่กำหนดโดย เริ่มต้นเป็น 3 นาฬิกาแล้วย้ายคอสตาริกาไปที่ 9 นาฬิกาและ Trinidad Tobago จนถึงเวลา 11 โมงเรายังสามารถย้ายนิการากัวและปานามาขึ้นเล็กน้อยพูดถึงกราฟ 2 นาฬิกาจากนั้นดูดังนี้ .3 1 4 Titles, Legends and Captions. There มีตัวเลือกที่ใช้กับกราฟสองทางรวมถึงชื่อเรื่องป้ายชื่อและตำนานกราฟ Stata สามารถมีชื่อและคำบรรยายได้โดยทั่วไปที่ด้านบนและคำอธิบายแผนภูมิและคำอธิบายเฉพาะ ที่ด้านล่างประเภท titleuptitle ช่วยให้เรียนรู้ได้มากขึ้นโดยปกติชื่อเรื่องคือสิ่งที่คุณต้องการ Stata 11 ช่วยให้ข้อความในกราฟรวมตัวหนาตัวเอียงตัวอักษรกรีกสัญลักษณ์ทางคณิตศาสตร์และทางเลือกของแบบอักษรพิมพ์ช่วยพิมพ์ข้อความเพื่อเรียนรู้เพิ่มเติม สุดท้ายปรับแต่งกราฟจะเพิ่มตำนานเพื่อระบุพอดีเชิงเส้นและ 95 ช่วงความเชื่อมั่น แต่ไม่ลดลงความอุดมสมบูรณ์ของตัวเองเราทำเช่นนี้โดยใช้คำสั่ง 2 พอดีกับเส้นตรง 1 95 CI ตัวเลือกของตำนานในการติดฉลากรายการที่สองและครั้งแรกใน เรายังใช้วงแหวน 0 เพื่อย้ายตำนานภายในพื้นที่วางแผน และ pos 5 เพื่อวางกล่องตำนานไว้ใกล้กับตำแหน่งนาฬิกา 5 o คำสั่งที่สมบูรณ์ของเราคือผลที่ได้คือกราฟที่แสดงในตอนต้นของส่วนนี้ถ้ากราฟของคุณมีลักษณะแตกต่างกันเล็กน้อยอาจเป็นเพราะเราใช้โทนสีที่แตกต่างกัน รุ่นที่กำหนดเองของ s2color ดู 3 2 5 ด้านล่างสำหรับข้อมูลเพิ่มเติมเกี่ยวกับโครงร่าง 3 แกนเครื่องชั่งน้ำหนักและฉลาก 1 มีตัวเลือกที่ควบคุมการปรับขนาดและช่วงของแกนรวมถึง xscale และ yscale ซึ่งสามารถคำนวณเลขลำดับหรือย้อนกลับได้ ชนิด help axisscaleoptions เพื่อเรียนรู้เพิ่มเติมตัวเลือกอื่น ๆ จะควบคุมการวางและการติดฉลากของทิกและทิปหลัก ๆ และป้ายกำกับเช่น xlabel xtick และ xmtick และในทำนองเดียวกันสำหรับแกน y ให้ดูที่ axislabeloptions ที่ช่วยให้ค่าเริ่มต้นเป็นที่ยอมรับได้ รู้ว่าคุณสามารถเปลี่ยนได้ 3 2 พล็อตไลน์ผมจะแสดงแผนงานบรรทัดโดยใช้ข้อมูลเกี่ยวกับอายุขัยของสหรัฐอเมริกาซึ่งมีให้เป็นหนึ่งในชุดข้อมูลที่จัดส่งพร้อมกับ Stata ลองใช้งานไดเร็กทอรี sysuse เพื่อดูว่ามีอะไรให้บริการอีกบ้าง อายุขัยของผู้ชายและผู้ชายสีดำในศตวรรษที่ 20 อีกครั้งเพื่อกระตุ้นความกระหายของคุณฉันจะเริ่มจากการแสดงผลิตภัณฑ์ขั้นสุดท้ายจากนั้นเราจะสร้างบิตของกราฟโดย bit.3 2 1 พล็อต Simple Line พล็อตที่ง่ายที่สุดใช้ ค่าเริ่มต้นทั้งหมดหากคุณกำลังงงงวยโดยการจุ่มก่อนปีพ. ศ. 2463 Google สหรัฐอเมริกาอายุขัยเฉลี่ย 1918 เราสามารถย่อคำสั่งให้บรรทัด twoway หรือแม้แต่บรรทัดถ้าทั้งหมดที่เรากำลังวางแผนทางลัดนี้ทำงานเฉพาะสำหรับ scatter และเส้น line line ช่วยให้ คุณสามารถระบุตัวแปร y ได้มากกว่าหนึ่งตัวแปรลำดับของ y คือ y 1 y 2 ymx ในตัวอย่างของเราเราระบุว่ามีความยาวสองเท่าของอายุขัยเฉลี่ยของสีขาวและสีดำเราสามารถใช้เส้นควบคุมเส้นสองเส้นได้ปีละ 2 ปี 2 2 Titles และ Legends กราฟเริ่มต้นค่อนข้างดี แต่ดูเหมือนว่าตำนานจะมีมากเกินไปเราจะย้ายข้อมูลส่วนใหญ่ไปยังชื่อและเก็บเฉพาะเผ่าพันธุ์ในตำนานที่นี่เราใช้สามตัวเลือกซึ่งตามปกติใน Stata ไปหลังจากเครื่องหมายจุลภาค ชื่อเรื่องคำบรรยายและตำนานตำนานเลือก ไอออนมีตัวเลือกย่อยจำนวนมากที่เราใช้ในการระบุคีย์และป้ายกำกับของพวกเขากล่าวว่าบรรทัดแรกแสดงถึงคนผิวขาวและคนผิวดำคนที่สองเพื่อละเว้นคีย์ที่คุณทิ้งไว้ออกจากรายการเมื่อต้องการเพิ่มข้อความโดยไม่มีคีย์การจับคู่ใช้ยัติภังค์หรือ เครื่องหมายลบสำหรับคีย์มีหลายตัวเลือกตำนานอื่น ๆ โปรดดู legendoption ช่วยเหลือเพื่อเรียนรู้เพิ่มเติมเราต้องการใช้พื้นที่เล็กน้อยดีกว่าโดยการย้ายตำนานภายในพื้นที่แปลงพูดรอบตำแหน่งนาฬิกา 5 ซึ่งการปรับปรุงอายุขัยมี ปล่อยให้บางห้องว่างตามที่ระบุไว้ก่อนหน้านี้เราสามารถย้ายตำนานภายในพื้นที่วางแผนโดยใช้วงแหวน 0 วงกลมด้านในและวางไว้ใกล้ตำแหน่ง 5 o ใช้ pos 5 เนื่องจากเหล่านี้เป็นตำนานตัวเลือกย่อยที่พวกเขาต้องไปภายในตำนาน 3 ฉันไม่ทราบเกี่ยวกับตัวคุณ แต่ฉันพบว่ายากที่จะแยกแยะบรรทัดเริ่มต้นในพล็อต Stata ช่วยให้คุณสามารถควบคุมสไตล์เส้นได้หลายแบบตัวเลือก clstyle ช่วยให้คุณสามารถใช้สไตล์ที่มีชื่อเช่น yxline foreground grid หรือ p1-p15 สำหรับรูปแบบที่ใช้ b y บรรทัดที่ 1 ถึง 15 ดูวิธีใช้ linestyle นี่เป็นประโยชน์ถ้าคุณต้องการเลือกองค์ประกอบสไตล์ของคุณจากโครงร่างตามที่ระบุไว้ด้านล่างนอกจากนี้คุณสามารถระบุองค์ประกอบสามส่วนของสไตล์ลายเส้นความกว้างและสีได้กำหนดรูปแบบไว้ โดยใช้ตัวเลือก clpattern รูปแบบที่พบมากที่สุดคือเส้นประที่เป็นของแข็งและจุดช่วย linepatternstyle สำหรับข้อมูลเพิ่มเติมความกว้างของเส้นที่ระบุโดยใช้ clwidth ตัวเลือกที่มีให้เลือกรวมถึงขนาดกลางและหนาบางมากขึ้นสำหรับ elel linewidthstyle เพิ่มเติมสำหรับสีสามารถระบุได้โดยใช้ตัวเลือก clcolor โดยใช้ ชื่อสีเช่นสีแดงสีขาวและสีฟ้านกเป็ดน้ำนกเป็ดน้ำและอื่น ๆ อีกมากมายหรือค่า RGB โปรดดูวิธีใช้ colorstyle นี่เป็นวิธีการระบุสีน้ำเงินสำหรับคนผิวขาวและสีแดงสำหรับคนผิวดำโปรดทราบว่า clcolor เป็นตัวเลือกของพล็อตบรรทัดดังนั้นเราจึงใส่วงเล็บรอบ คำสั่งบรรทัดและแทรกมันมี 3 2 4 ตัวเลือกมาตราส่วนดูเหมือนว่าการปรับปรุงในชีวิตคาดหวังชะลอตัวลงเล็กน้อยในช่วงครึ่งหลังของศตวรรษนี้สามารถชื่นชมดีขึ้นโดยใช้ขนาดล็อกที่ เส้นตรงจะบ่งบอกถึงการปรับปรุงเปอร์เซ็นต์ที่คงที่นี่ทำได้โดยใช้ตัวเลือกแกนของคำสั่งสองทางให้ดูแกนการช่วยและโดยเฉพาะ yscale ซึ่งจะช่วยให้คุณสามารถเลือกการบันทึกเลขคณิตหรือเครื่องชั่งย้อนกลับได้นอกจากนี้ยังมีช่วงย่อยเพื่อควบคุมการวางแผน ช่วงนี้ฉันจะระบุช่วง y เป็น 25 ถึง 80 เพื่อเลื่อนเส้นโค้งขึ้นเล็กน้อย 3 2 5 Schematy กราฟแผนผังใช้โครงร่างเพื่อควบคุมลักษณะที่ปรากฏของกราฟให้ดูที่วิธีใช้วิธีใช้คุณสามารถกำหนดรูปแบบค่าเริ่มต้นที่จะใช้ใน กราฟทั้งหมดที่มีชื่อชุดนอกจากนี้คุณยังสามารถแสดงกราฟล่าสุดโดยใช้เทมเพลตที่แตกต่างกันด้วยการแสดงกราฟแผนผังโครงร่างหากต้องการดูรายการแผนผังแบบสอบถามที่มีอยู่ให้เลือกแผนผังโครงร่างลองใช้ s2color สำหรับกราฟหน้าจอ s1manual สำหรับสไตล์ที่ใช้ในคู่มือ Stata และนักเศรษฐศาสตรสําหรับรูปแบบที่ใชใน The Economist การใชเบื้องตนเราไดกราฟที่แสดงในตอนเริ่มตนของหัวขอนี้ 3 3 การจัดการ Graphs. Stata จะติดตามกราฟล่าสุดที่วาดซึ่งเก็บไวในหนวยความจําและ เรียกว่ากราฟคุณสามารถเก็บมากกว่าหนึ่งกราฟในหน่วยความจำได้ถ้าคุณใช้ตัวเลือกชื่อเพื่อตั้งชื่อกราฟเมื่อคุณสร้างข้อมูลนี้จะเป็นประโยชน์สำหรับการรวมกราฟกราฟช่วยชนิดรวมกันเพื่อเรียนรู้เพิ่มเติมทราบว่ากราฟที่เก็บไว้ในหน่วยความจำหายไปเมื่อคุณ ออกจาก Stata แม้ว่าคุณจะบันทึกข้อมูลไว้เว้นแต่คุณจะบันทึกกราฟไว้เองเพื่อบันทึกกราฟปัจจุบันบนดิสก์โดยใช้รูปแบบของ Stata ให้พิมพ์กราฟ save filename คำสั่งนี้มีสองทางเลือกให้ใช้แทนถ้าคุณต้องการใช้ไฟล์ มีอยู่และ asis ซึ่งตรึงกราฟไว้ในรูปแบบปัจจุบันแล้วบันทึกค่าเริ่มต้นคือบันทึกกราฟในรูปแบบสดที่สามารถแก้ไขได้ในเซสชันต่อไปตัวอย่างเช่นโดยการเปลี่ยนโครงร่างหลังจากบันทึกกราฟในรูปแบบ Stata คุณสามารถทำได้ โหลดจากดิสก์ที่มีกราฟคำสั่งใช้ชื่อไฟล์โปรดทราบว่าการบันทึกกราฟและการใช้กราฟจะคล้ายกับการบันทึกและใช้กับไฟล์ Stata กราฟที่จัดเก็บในหน่วยความจำสามารถแสดงผลได้โดยใช้การแสดงกราฟนอกจากนี้คุณยังสามารถแสดงรายการเปลี่ยนเปลี่ยนชื่อคัดลอกหรือวางกราฟที่เก็บไว้ในหน่วยความจำชนิดช่วย graphmanipulation เพื่อเรียนรู้เพิ่มเติมหากคุณวางแผนที่จะรวมกราฟในเอกสารอื่นคุณอาจจะต้องบันทึกในรูปแบบพกพามากขึ้น Stata ของคำสั่งกราฟชื่อแฟ้มส่งออกสามารถส่งออกกราฟโดยใช้ความหลากหลายของ รูปแบบเวกเตอร์หรือแรสเตอร์ซึ่งมักจะเข้าใจจากนามสกุลไฟล์รูปแบบเวกเตอร์เช่น Windows metafile wmf หรือ emf หรือ Adobe's PostScript และตัวแปร ps, eps, pdf มีคำแนะนำในการวาดภาพเป็นหลักและมีความละเอียดที่เป็นอิสระดังนั้นจึงเป็นวิธีที่ดีที่สุดสำหรับการรวม ในเอกสารอื่น ๆ ที่สามารถปรับขนาดได้รูปแบบ Raster เช่น Portable Network Graphics png บันทึกพิกเซลภาพตามพิกเซลโดยใช้ความละเอียดในการแสดงผลปัจจุบันและเหมาะที่สุดสำหรับการรวมไว้ในเว็บเพจนอกจากนี้คุณยังสามารถพิมพ์กราฟโดยใช้กราฟพิมพ์หรือคัดลอกและวาง ลงในเอกสารโดยใช้คลิปบอร์ดของ Windows ให้คลิกขวาที่หน้าต่างที่มีกราฟแล้วคัดลอกจากเมนูบริบท 2017 Germ n Rodr guez , Princeton University ฉันสามารถใช้คำสั่ง margins เพื่อทำความเข้าใจกับการโต้ตอบหลายอย่างในการถดถอยโลจิสติก Stata 11 Stata FAQ คำสั่ง margins ใน Stata 11 อาจเป็นเครื่องมือที่มีประโยชน์มากในการทำความเข้าใจและตีความการโต้ตอบเราจะอธิบายคำสั่งสำหรับ a แบบจำลองการถดถอยโลจิสติกกับสองประเภทโดยการติดต่อกันอย่างต่อเนื่องเราเริ่มต้นด้วยการโหลดชุดข้อมูล mlogcatcon ในชุดข้อมูล y นี้เป็นตัวแปรการตอบสนองแบบไบนารีและ m และ s เป็นตัวทำนายอย่างต่อเนื่องตัวแปร f ซึ่งหมายถึงเพศหญิงเป็นตัวทำนายแบบไบนารีเราจะโต้ตอบกับ f ทั้ง m และ s นี่คือรูปแบบการถดถอยโลจิสติกคุณจะสังเกตได้ว่า f โดย s interaction มีความสำคัญทางสถิติในขณะที่ f โดย m interaction ไม่ได้เนื่องจากเป็นแบบไม่เป็นเชิงเส้นเราจะต้องใช้ค่าของตัวแปรร่วมทั้งหมดใน เข้าใจสิ่งที่เกิดขึ้นในแบบจำลองเราจะเริ่มต้นด้วยคำสั่งขอบที่มองไปที่ความแตกต่างไม่ต่อเนื่องในความน่าจะเป็นระหว่างเพศชายและเพศหญิงเป็นเวลาห้า d ifferent ของ s ในขณะที่ถือครองที่ค่าเฉลี่ยของเราได้รับความแตกต่างโดยสิ้นเชิงในความน่าจะเป็นโดยใช้ตัวเลือก dydx กับตัวทำนายเลขฐานสองตัวแปร m จะจัดขึ้นที่ค่าเฉลี่ยของมันโดยใช้ตัวเลือก atmeans ในขณะที่ผลของคำสั่งข้างต้นขอบเป็น ถูกต้องสมบูรณ์สะท้อนให้เห็นถึงการเปลี่ยนแปลงที่ไม่ต่อเนื่องในความน่าจะเป็นเพียงค่าเดียวของ m ถ้าเราลบตัวเลือก atmeans ที่เราได้รับผลกระทบเฉลี่ยคือการเปลี่ยนแปลงโดยสิ้นเชิงในความน่าจะเป็นสำหรับแต่ละค่าของค่าเฉลี่ยของ s ข้ามค่าที่สังเกตของ m นี่เป็นวิธีที่คำสั่ง margins ปรากฏขึ้นไปข้างหน้าและกราฟผลลัพธ์เหล่านี้รวมถึงช่วงความเชื่อมั่น 95 เราจะเริ่มต้นด้วยการวางค่าที่จำเป็นลงในเมทริกซ์โดยใช้เทคนิคที่แสดงใน Stata FAQ ฉันจะกราฟผลลัพธ์ของคำสั่ง margins ได้อย่างไร คำสั่งเมทริกซ์จะตามด้วยกราฟเส้น twoway คำสั่งขอบและกราฟข้างต้นทำให้เรามีความคิดที่ดีงามเกี่ยวกับการเปลี่ยนแปลงที่ไม่ต่อเนื่องของความน่าจะเป็นใน diff ค่าต่างๆของ s แต่เรายังไม่ทราบว่าการเปลี่ยนแปลงนี้มีค่าที่แตกต่างกันของ m ลองลองคำสั่ง margins อีกครั้งคราวนี้แตกต่างกันทั้ง s และ m ห้าแถวแรกให้การเปลี่ยนแปลงโดยสิ้นเชิงสำหรับห้าค่าของ s ในขณะที่ ถือครองที่ 30 ถัดไปห้า hold m ที่ 40 และอื่น ๆ หนึ่งในคุณสมบัติที่น่าสนใจมากขึ้นคือกี่ของการเปลี่ยนแปลงอย่างไม่ต่อเนื่องมีนัยสำคัญทางสถิติแม้ว่า f โดยการปฏิสัมพันธ์อย่างมีนัยสำคัญเป็นสำคัญตอนนี้เราสามารถเก็บค่าที่จำเป็นลงใน เมทริกซ์ในการเตรียมตัวสำหรับ graphing. Let s เริ่มต้นด้วยกราฟผลกระทบของค่าที่แตกต่างกันของ s กับเส้นแยกแต่ละค่าของ m. Although มีไม่มากค่าสำคัญในตารางขอบด้านบนเส้นสำหรับแต่ละค่าของ m ดูค่อนข้างแตกต่างจากที่อื่นในขณะที่บรรทัดสำหรับ m เท่ากับ 30 ค่อนข้างแบนเส้นสำหรับ m เท่ากับ 70 แสดงความแปรปรวนมากขึ้นลดลงครั้งแรกแล้วปีนเขาชันรอบ s เท่ากับ 50.Now ที่เรารู้ว่าสิ่งที่แตกต่างใน s สำหรับค่า ของ m ดูเหมือนว่าเราสามารถย้อนกลับตัวแปรในบรรทัดคำสั่ง twoway กราฟิกเพื่อดูว่ามีความแตกต่างของ m สำหรับค่าของ s อย่างไรตัวอย่างเช่นเรากำลังมองหาค่า 25 ค่าเดียวกันกับกราฟก่อนหน้านี้ บรรทัดสำหรับเท่ากับ 70 เป็นที่ที่โดดเด่นจากคนอื่น ๆ ถ้าแบบจำลองของคุณมีความซับซ้อนมากกว่านี้คุณต้องตัดสินใจว่าจะทำอย่างไรกับแต่ละตัวแปรร่วมคุณสามารถถือค่าคงที่ที่ค่าอย่างน้อยหนึ่งค่าหรือคุณสามารถทำได้ ค่าเฉลี่ยของพวกเขาไม่ว่าคุณจะเลือกอะไรที่คุณต้องตระหนักว่าค่าของตัวแปรร่วมทั้งหมดมีความสำคัญในรูปแบบที่ไม่เป็นไปตามธรรมชาติคุณอาจลองทำตามขั้นตอนสามขั้นตอนนี้ 1 ให้ความช่วยเหลือทางการเงินกลับคืนมาในการแข่งขัน 2 ได้รับค่าที่คาดการณ์ไว้โดยมีระยะขอบ 3 สร้างแถบ กราฟใช้ marginsplot. Something เช่น this. reg ช่วยเหลือทางการเงินให้แน่ใจว่าได้ใช้ i-dot ก่อนการแข่งขันเพื่อแสดงให้ Stata ว่าการแข่งขันเป็นตัวแปรไม่มีเงื่อนไขเรียงตามลำดับเหนือ Marksplot Race, x Race rec. bar. I m แน่ใจว่ามีทาง การทำเช่นนี้กับ twoway นอกจากนี้ยังช่วยถ้าคุณโพสต์รหัสที่คุณเคยใช้จะลองขอบคุณที่แม้ว่าจะดูเหมือนบิตที่เกี่ยวข้องกับการได้รับตัวเลขสรุปง่ายๆของสัดส่วนของผู้คนในการช่วยเหลือทางการเงินรหัสฉันเคยใช้ในขณะนี้คือ. histogram FinancialAid, เปอร์เซ็นต์โดยสิ้นเชิงโดย Race รหัสนี้เกือบจะเป็นสิ่งที่ฉันต้องการยกเว้นว่ามันแสดงให้เห็นถึง 0s โดยการแข่งขันเช่นกันและไม่ได้แสดงเปอร์เซ็นต์ที่แม่นยำของแต่ละ - คุณเรียงลำดับต้อง guesstimate สัดส่วนเป็นเอกสารใช้ blabel option. You กล่าวว่าตัวแปรของคุณคือ 0-1 ซึ่งในกรณีนี้ค่าเฉลี่ยของมันจะอยู่ในช่วงนั้นอย่างใดคุณมีระดับเปอร์เซ็นต์ดังนั้นนั่นคือสิ่งที่คุณต้องการชื่อเปอร์เซ็นต์ของค่าเฉลี่ยของ FinancialAid จะดีกว่าเมื่อเทียบกับเปอร์เซ็นต์ ความช่วยเหลือทางการเงินคุณไม่จำเป็นต้องมีตำนานที่นี่หมวดหมู่ของคุณจะพอดีกับแกนป้ายชื่อแสดงถึงรูปแบบที่แน่นอนที่คุณใช้ขอแนะนำแก้ไขล่าสุดโดย Nick Cox 28 เม. ย. 2014, 02 14. วิธีที่ดีกว่าในการแสดงข้อมูลของคุณคือการใช้ แถบแนวนอนช่วยให้ข้อความในตำนานสามารถยกเลิกได้ d ผู้อ่านสามารถอ่านข้อมูลประจำตัวของประเภทและร้อยละในการเคลื่อนไหวในแนวนอนเดียวฉันไม่ได้ใช้สีที่แตกต่างกันสำหรับการแข่งขันที่แตกต่างกันเนื่องจากแถบทั้งหมดแสดงสิ่งเดียวกันและสีจะไม่จำเป็นต้องเชื่อมโยงแต่ละบาร์ ป้ายกำกับของพวกเขานอกจากนี้ฉันยังใช้มิติข้อมูลในแนวตั้งของแผนภูมิเพื่อแสดงขนาดสัมพัทธ์ของแต่ละหมวดหมู่มากกว่าการจัดเรียงตามลำดับตามที่คุณได้ทำขึ้นด้วยคำสั่ง Nick Cox s - catplot - คำสั่งฉันใช้น้ำหนักความถี่ไปที่ ระบุขนาดของแต่ละ bar. catplot rvrace fw percent. An Introduction to Stata Graphics. Stata รวมถึงชุดเครื่องมือที่หลากหลายสำหรับการสร้างกราฟิกที่มีคุณภาพเป็นสิ่งพิมพ์ระหว่างความหลากหลายของกราฟที่คุณสามารถทำได้และจำนวนรายละเอียดที่คุณสามารถควบคุมได้ กราฟกราฟิก Stata อาจเป็นเรื่องที่น่ากลัวอย่างไรก็ตามคุณอาจจำเป็นต้องสร้างกราฟที่แตกต่างกันเพียงเล็กน้อยและในกรณีส่วนใหญ่การตั้งค่าเริ่มต้นของ Stata จะได้รับการปรับให้ดียิ่งขึ้นอะไรคือ Stata's Graphical User Interface GUI จัดตัวเลือกกราฟต่างๆในแบบที่ใช้งานง่ายเพื่อให้คุณสามารถหาได้เมื่อคุณต้องการโดยไม่ต้องจำไวยากรณ์สำหรับแต่ละคนที่ไม่ได้หมายความว่าคุณไม่ควรใส่คำสั่งกราฟของคุณในการทำไฟล์เมื่อคุณได้สร้างไว้แล้ว แต่ก็หมายความว่า สำหรับกราฟที่ซับซ้อนคุณสามารถใช้ GUI เพื่อสร้างคำสั่งที่คุณจะเก็บได้นอกจากนี้สเตต้า 10 ยังเพิ่มตัวแก้ไขกราฟซึ่งจะช่วยให้คุณสามารถปรับเปลี่ยนกราฟหลังจากที่คุณได้สร้างขึ้นแล้วซึ่งจะช่วยให้คุณสามารถควบคุมกราฟของคุณได้มากขึ้น แต่ไม่เหมือน GUI สำหรับการสร้างกราฟโปรแกรมแก้ไขจะไม่ให้คำสั่งที่คุณสามารถเรียกใช้งานได้อีกในภายหลังหากภายหลังคุณทำการเปลี่ยนแปลงข้อมูลของคุณคุณจะต้องเริ่มต้นกราฟจากขั้นเริ่มต้นดังนั้นจึงเป็นการดีที่จะสร้างกราฟที่คุณต้องการในตอนแรก ที่เป็นไปได้ แต่ตัวแก้ไขยังคงเป็นบทความที่มีประโยชน์มากบทความนี้จะกล่าวถึงการสร้างกราฟโดยใช้ Stata GUI โครงสร้างไวยากรณ์คำสั่งกราฟโดยไม่ต้องอาศัยรายละเอียดมากเกินไปรูปแบบทั่วไปของกราฟและโปรแกรมแก้ไขกราฟ คุณควรจะมีความคุ้นเคยกับพื้นฐาน Stata ก่อนที่จะเริ่มต้นหากคุณ don t พิจารณาเริ่มต้นด้วย Stata สำหรับนักวิจัยหรือ Stata สำหรับนักเรียนวิธีที่ดีที่สุดในการใช้บทความนี้คือการอ่านได้ที่เครื่องคอมพิวเตอร์และดำเนินการตามขั้นตอนที่อธิบายตัวอย่างในนี้ บทความจะใช้ชุดข้อมูลรถยนต์ที่มาพร้อมกับ Stata ดังนั้นให้เริ่มด้วยการพิมพ์เพื่อโหลดคุณสามารถทดลองได้ทุกเมื่อโดยเฉพาะอย่างยิ่งกับการตั้งค่าที่เราไม่ค่อยพูดคุยกันเนื่องจากมักเป็นแบบที่เห็นได้ชัดหรือไม่ค่อยสร้าง เปลี่ยนข้อมูลของคุณดังนั้นที่เลวร้ายที่สุดที่สามารถเกิดขึ้นได้ก็คือกราฟของคุณเปลี่ยนไปเป็นประโยชน์หรือเพียงธรรมดา ugly. Creating กราฟการใช้ส่วนติดต่อผู้ใช้แบบกราฟิกเราจะเริ่มต้นด้วยแผนกระจายง่ายกับน้ำหนักเป็นตัวแปร X และ mpg เป็น ตัวแปร Y Stata หมายถึงกราฟใด ๆ ที่มีตัวแปร Y และตัวแปร X เป็นกราฟ twoway ดังนั้นให้คลิกกราฟกราฟิก Twoway graph ขั้นตอนต่อไปคือการกำหนดพล็อตในแง่ Stata พล็อตคือข้อมูลบางอย่างที่มองเห็นได้ ในรูปแบบเฉพาะตัวอย่างเช่นการกระจายของ mpg บนน้ำหนักกราฟเป็นภาพรวมทั้งแกนชื่อเรื่องตำนาน ฯลฯ นอกจากนี้กราฟเดียวอาจมีหลายแปลงกล่องโต้ตอบ twoway ขั้นพื้นฐานจะช่วยให้คุณสามารถกำหนดเป็นจำนวนมาก แปลงตามที่คุณต้องการรวมทั้งการควบคุมลักษณะอื่น ๆ ของกราฟเพื่อกำหนดพล็อตคลิกสร้างจากนั้นคุณจะได้รับกล่องโต้ตอบที่คุณสามารถอธิบายพล็อตที่คุณต้องการให้วางหมวดหมู่ไว้เป็นพล็อตพื้นฐานและประเภทที่ตั้งไว้สำหรับกระจายสำหรับ ตัวแปร Y เลือกหรือพิมพ์ mpg และสำหรับตัวแปร X เลือกหรือพิมพ์น้ำหนักหมายเหตุ Linux Stata ไม่อนุญาตให้คุณเลือกตัวแปรดังนั้นคุณจะต้องพิมพ์ชื่อของพวกเขาใน Windows Stata คุณสามารถทำได้ทั้งถ้าคุณคลิกส่งกราฟจะเป็น created without closing the dialog box This allows you to look over the results and then easily make adjustments and try again Click Submit now and you should get a simple but professional looking scatter plot. Adding More Variables. If you want to add a second Y variable to the scatterplot, the easiest way is to type its name into the Y variable box after the one you ve already selected Stata does not allow you to select multiple variables from the list with the mouse, but it has no trouble understanding multiple variables in the Y variables box as long as you put them there yourself. To make a sensible graph with two Y variables without having multiple scales we need variables with similar values The trunk variable qualifies, so type it in the Y variable box after mpg and click Submit again. The result will be a scatter plot with both variables Note how Stata automatically puts the two variables in different colors and adds a legend explaining which is which The legend text is drawn from the variable labels, but you could override all these default behaviors if you so desired. Plotting a Subset of the Data. If you only want to include certain observations, you can specify which ones by clicking on the if in tab You can then type a condition in the If box, and on ly observations that meet the condition will be included in the plot Do not type the word if as that is assumed. To only plot foreign cars, type foreign in the If box. Recall that in Stata one is true and zero is false, and foreign is coded accordingly Thus if foreign is equivalent to if foreign 1 Click Submit and you ll get a much sparser graph. You can also use more complicated expressions For example, type foreign price 10000 and you ll get just the cars which are both foreign and cost less than 10,000 in 1978 dollars. Controlling the Markers. By default Stata marks each point with a small dot, but you can change this First click on the Plot tab again, and for best results set the Y variable back to just mpg Then click Marker Properties Set Symbol to Hollow circle Next check Add labels to markers and set the Variable to make then click Submit. As you see, each point is now a hollow circle with the name of the car printed next to it, but many of the names overlap You can improve the situat ion somewhat by changing Label angle to 45 degrees but in general you can only put useful labels on a scatter plot if it has a small number of observations and they re spread out. Overlaying Plots. Next we ll combine multiple plots Uncheck Add labels to markers Click Accept to accept these settings for Marker properties and go back to the Plot 1 window, then click Accept again to accept the plot as it is and go back to the main twoway window Click Create to add another plot to the graph This time we ll make a line plot Set the plot type to Line and again choose mpg and weight as the Y and X variables Click Submit to see the result. It s probably not what you expected--in fact it looks like a scribble That s because by default Stata draws the line from observation one to observation two to observation three and so forth What you want is a line from the observation with the lowest weight to the one with the next lowest weight, etc That s why Stata included the checkbox Sort on x variable Th is does not change the actual order of the observations in your data set, just the order in which they are connected in your line plot Check it and click Submit again This time you should get the graph you expected. Note that while the line connects all the points in the scatter plot, it goes to a lot of points that the scatter plot does not include That s because you didn t set an if condition for the line plot, so it s plotting all the observations in the data The ability to set different if conditions for different plots is very useful, though you ll note that the twoway window has its own if in tab which applies to all the plots. Line properties. You can control what the line looks like by clicking Line Properties The most commonly used option here is Pattern By default Stata distinguishes different line plots by color, but that doesn t help if the graph needs to be printed in black and white So instead you can set a pattern for each line Alternatively you can choose a scheme designed for printing To see it in action set Pattern to Dash Also try setting Connecting method to Stairstep. Plotting Subsamples. Let s go back to just plotting mpg vs weight but this time let s make the foreign cars one color and the domestic cars another You can do this by creating two plots, one for the foreign cars and one for the domestic cars, each having an if condition that limits it to the proper subpopulation Then Stata will make them different colors automatically. Begin by resetting everything Click Accept twice to get back to the main twoway window, then click the R button in the lower left to reset the plots Next click Create leave the type as Scatter set the Y variable to mpg and set the X variable to weight Then click if in and in the If box type foreign The exclamation mark is Stata for not so this means not foreign and is equivalent to foreign 0 Thus this plot will only include the domestic cars. Click Accept to get back to the main twoway window, then click Create again and re peat the entire process with one vital difference this time in the If box just type foreign This plot will include only the foreign cars Click Submit to see the result. The resulting graph very nicely makes the domestic cars blue and the foreign cars red However, the legend gives you no indication which is which To do that you ll need to take control of the legend yourself. Controlling the Appearance of a Graph. You haven t seen any options for controlling the legend, because thus far we ve been focused on the properties of individual plots The legend is not associated with a particular plot because it potentially contains information from all the plots Thus to get to it you need to click Accept and get back to the twoway window This is where you control aspects of the graph as a whole, including the legend. Click on the Legend tab The Legend behavior just controls whether the legend is shown or not Since Stata thinks our graph should have one and we agree, we can leave it set to Default O n the other hand, the default keys don t provide any useful information for this graph, so we need to override them Check Override default keys Then in the box below you need to type the number of each plot followed by how you want it to be labeled in quotation marks For this graph type.1 Domestic Cars 2 Foreign Cars. Now click Submit and you ll get a graph with a useful legend Note that the order in which you list the plots is the order in which they ll appear in the legend if you typed 2 Foreign Cars 1 Domestic Cars the legend would put the foreign cars first. The Organization Appearance button opens up a dialog box with all sorts of options relating to how the legend looks Click the Organization tab and set Rows Columns to Columns leaving it set to just one column. The Labels and Region tabs allow you to control the appearance of the legend text and the entire legend box respectively The various options like sizes and colors are self-explanatory, but these same options appear in many d ifferent contexts so it s worth taking a moment to experiment and see how they work Choose 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 in 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 aga in, 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 f or 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 choosing 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, an d 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 to 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. E very 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, which 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 Obvi ously 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 working 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 f or 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 Accept 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 t o 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 printi ng 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 gr aph 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 using 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 standalone 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 Plot s. 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 translat es 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 Title 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 be comes. 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 r e 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