Wednesday 13 December 2017

ستاتا - marginsplot ثنائي - خيارات


استكشاف نتائج الانحدار باستخدام الهوامش. بمجرد أن تقوم بتشغيل الانحدار، فإن التحدي التالي هو معرفة ما تعني النتائج هوامش الأمر هو أداة قوية لفهم نموذج، وهذه المادة سوف تظهر لك كيفية استخدامه يحتوي على ما يلي يتم اتخاذ الأقسام 1 و 2 مباشرة من قسم الإحصاءات من ستاتا للباحثين أنها مستنسخة هنا لصالح أولئك الذين يبحثون على وجه التحديد للحصول على معلومات حول استخدام الهوامش إذا كنت إعادة دراية بهذه المادة يمكنك تخطي إلى القسم 3.OLS الانحدار مع شروط غير الخطية. ويمكن استخدام الأمر هوامش فقط بعد تشغيل في الانحدار، ويعمل على نتائج الأمر الانحدار الأخير لدينا المثال الأول، تحميل مجموعة بيانات السيارات التي تأتي مع ستاتا وتشغيل الانحدار التالي. sysuse السيارات ريج السعر مبغ النزوح. المستويات من متغير النتيجة. إذا كنت فقط type. all في حد ذاته، سوف ستاتا حساب القيمة المتوقعة للمتغير التابع لكل ملاحظة، ر (هين) متوسط ​​قيمة تلك التنبؤات مع الخطأ المعياري، t-ستاتيستيك، إلخ. إذا كان الهامش متبوعا بمتغير فئوي، يحدد ستاتا أولا جميع مستويات المتغير الفئوي، ثم يحسب لكل قيمة ما توقعه المتوسط تكون قيمة المتغير التابع إذا كانت جميع المشاهدات لها قيمة للمتغير الفئوي. جميع المتغيرات الأخرى تركت دون تغيير. يسأل الأول، ماذا سيكون السعر المتوسط ​​إذا كانت جميع السيارات محلية ولكن لا تزال لديها الأوزان الحالية، والتشريد، وما إلى ذلك ومن ثم يسأل ماذا سيكون متوسط ​​السعر إذا كانت جميع السيارات أجنبية. نفس الشيء بالنسبة لجميع القيم الخمس من rep78 ولكن نظرا لوجود الكثير منهم أنها جيدة المرشح لعرض بياني يأخذ الأمر هاميرمزبلوت نتائج السابقة هوامش الأمر وتحويلها إلى رسم بياني. للمتغيرات المتواصلة الهوامش من الواضح يمكن أن ننظر في كل القيم الممكنة، ولكن يمكنك تحديد القيم التي تريد فحص مع الخيار في. margins، في الوزن 2000 4000.This بحساب متوسط ​​القيمة المتوقعة من السعر مع الوزن تعيين إلى 2000 جنيه، ثم مرة أخرى مع الوزن تعيين إلى 4000 جنيه التفكير في كل قيمة كسيناريو السيناريوهات أعلاه هي بسيطة جدا، ولكن يمكنك جعل سيناريوهات أكثر تعقيدا من خلال إدراج متغيرات وقيم متعددة في الخيار عند تعيين الهامش الناتج أولا عددا لكل سيناريو، ثم يعطي نتائجها حسب number. The يتم تحديد القيم باستخدام نومليست A نومليست هي قائمة من الأرقام تماما مثل فارليست هي قائمة من المتغيرات و، مثل فارليست، وهناك العديد من الطرق المختلفة لتحديد نومليست اكتب نومليست مساعدة لنرى كل منهم أبسط طريقة ليست سوى قائمة الأرقام التي تريدها، كما هو موضح أعلاه يمكنك أيضا تحديد نومليست مع من قبل وتحديد نهاية الفاصلة نهاية. الرخام، في الوزن 1500 500 5000.This بحساب متوسط ​​القيمة المتوقعة من السعر مع الوزن تعيين إلى 1500، 2000، 2500، الخ تصل إلى 5000 الأوزان الفعلية تتراوح من 1760 إلى 4840 مرة أخرى، وهذا هو مرشح جيدللحصول على رسم. تأثير كوفاريت. إذا كنت تريد أن ننظر إلى التأثير الهامشي المتغير، أو مشتق من متوسط ​​القيمة المتوقعة فيما يتعلق هذا المتغير، استخدم خيار ديدكس. في هذه الحالة البسيطة، مشتق هو مجرد معامل ميلا في الغالون الذي سيكون دائما بالنسبة لنموذج خطي ولكن النظر في تغيير الوزن لأن النموذج يتضمن كلا من الوزن والوزن تربيع لديك أن تأخذ في الاعتبار حقيقة أن كلا التغيير هذه الحالة هي مربكة بشكل خاص ولكن ليس غير عادي لأن معامل على والوزن هو سلبي ولكن معامل على الوزن التربيعي هو إيجابي وبالتالي فإن صافي تأثير تغيير الوزن لأي سيارة معينة تعتمد كثيرا على وزنه بدءا. يمكن للأوامر الهوامش بسهولة جدا اقول لكم يعني تأثير. ما هو الهوامش هنا هو اتخاذ مشتق عددي من السعر المتوقع فيما يتعلق بالوزن لكل سيارة، ومن ثم يحسب المتوسط ​​في القيام بذلك، هوامش ينظر في البيانات الفعلية وهكذا يعتبر تأثير تغيير هوند ووزن المدني من 1،760 جنيه فضلا عن تغيير لينكولن كونتيننتال ق من 4،840 وزن مربع المدى هو أكثر أهمية مع هذا الأخير من السابق ثم المتوسطات لهم جنبا إلى جنب مع جميع السيارات الأخرى للحصول على نتائجه من 2 362865، أو أن كل رطل إضافي من الوزن يزيد من متوسط ​​السعر المتوقع بمقدار 2 36.للاطلاع على كيفية تغير تأثير الوزن كتغيرات في الوزن، استخدم الخيار في مرة أخرى ومن ثم رسم النتائج. الهامش، وزن ديدكس بالوزن 1500 500 5000 الهامش. لنا أن لقيم منخفضة من الوزن أقل من حوالي 2000، وزيادة الوزن في الواقع يقلل من سعر السيارة ومع ذلك، لمعظم السيارات زيادة الوزن يزيد من السعر. يعمل خيار ديدكس أيضا للمتغيرات الثنائية. ومع ذلك، لأنه تم إدخال الأجانب في نموذج كما هوامش يعرف أنه لا يمكن أن تأخذ مشتق فيما يتعلق الأجنبية أي حساب ما سيحدث إذا أصبحت جميع السيارات قليلا أكثر الأجنبية وبالتالي فإنه يبلغ الفرق بين السيناريو حيث جميع السيارات هي الأجنبية والسيناريو حيث جميع السيارات المحلية يمكنك التحقق من ذلك عن طريق run. and القيام الطرح نفسك. تحقق نماذج النتائج الثنائية والاحتمالات المتوقعة. هوامش حتى أكثر فائدة مع نماذج النتائج الثنائية لأنها دائما غير الخطية مسح السيارات مجموعة البيانات من الذاكرة ومن ثم تحميل غراد من موقع سك s. This هو مجموعة بيانات خيالية تتألف من 10،000 طالب واحد فقط نصفهم من الوضع الاجتماعي والاقتصادي عالية هايسيس ونصف ليست بالضبط واحد من كل مجموعة أعطيت العلاج أو العلاج لعلاج تهدف إلى زيادة احتمال التخرج المتغير غراد يخبرنا ما إذا كانوا في الواقع تخرج أهدافك هي لتحديد 1 ما إذا كان العلاج أي فرق، و 2 ما إذا كان تأثير العلاج تختلف حسب الحالة الاجتماعية والاقتصادية سيس. يمكنك الإجابة على السؤال الأول مع لوجيت بسيط log. logit علاج غراد عالج. المعامل على علاج إيجابي وكبير، اقتراح ز لم التدخل زيادة احتمالات التخرج لاحظ أن هيسس كان لها تأثير أكبر. لتحقق ما إذا كان تأثير يعتمد على سيس بإضافة التفاعل بين هيسس علاج two. logit علاج مرتفع. لا يختلف معامل على هيسس علاج كبير من الصفر ولكن هذا يعني حقا أن العلاج كان بالضبط نفس التأثير بغض النظر عن SES. B وغالبا ما تفسر النتائج الثنائية من حيث نسب الأرجحية، لذلك كرر الانحدار السابق مع أو خيار لرؤية them. logit غراد علاج هايسيس، أو. هذا يخبرنا أن احتمالات التخرج إذا تم علاجك هي ما يقرب من 2 83 مرات من احتمالات التخرج إذا كنت لا يعامل، بغض النظر عن سيس الخاص بك الباحثون أحيانا الخلط بين نسب الأرجحية مع نسب الاحتمال أي يقولون أنك 2 83 مرات أكثر عرضة للتخرج إذا كنت يتم التعامل مع هذا غير صحيح. إذا كنت تسأل الهوامش لدراسة التفاعل بين متغيرين فئوية، فإنه سيتم إنشاء سيناريوهات لجميع توليفات ممكنة من تلك المتغيرات يمكنك استخدام هذا بسهولة للحصول على احتمال توقع التخرج لجميع السيناريوهات الأربعة المحتملة ارتفاع سيس منخفض سيس، يعامل لم يعالج. للطلاب سيس منخفضة، والعلاج يزيد من احتمال توقع التخرج من حوالي 49 إلى حوالي 73 للطلاب سيس عالية، العلاج يزيد الاحتمال المتوقع للتخرج من حوالي 96 إلى حوالي 98 الآن، إذا قمت بتوصيل تلك الاحتمالات في صيغة لحساب نسبة الأرجحية، وسوف تجد أن نسبة الأرجحية هو 2 83 في كلتا الحالتين استخدام الأرقام الكاملة من الناتج الهوامش ، وليس التقريب رقمين أعطى هنا العلاج يضيف نفس المبلغ إلى الدالة الخطية التي يتم تمريرها من خلال وظيفة لوجستية في كلتا الحالتين ولكن أذكر شكل وظيفة لوجستية. العلاج له تأثير أقل بكثير على احتمال التخرج لارتفاع طلاب سيس لأن احتمالهم هو بالفعل عالية جدا يمكن أن تحصل ر أعلى بكثير الطلاب سيس منخفض في جزء من منحنى لوجستي المنحدرات ستي رقائق، لذلك التغييرات في وظيفة خطية يكون لها آثار أكبر بكثير على احتمال الاحتمال. هو أمر الهوامش يمكن الإجابة مباشرة على السؤال هل تأثير العلاج تختلف مع سي مع مزيج من ديدكس و at. margins، علاج ديدكس في هايسيس 0 1. يمكنك أيضا القيام بذلك مع هوامشس هوامشس، علاج ديدكس مرة أخرى، وهذه هي نفس الأرقام التي د الحصول عليها عن طريق طرح المستويات التي تم الحصول عليها أعلاه نقترح دائما النظر في مستويات وكذلك التغييرات مع العلم حيث تبدأ التغييرات من يمنحك الكثير شعور أفضل من ما يحدث على. قاعدة عامة أنه من الأسهل لتغيير الاحتمالات المتوقعة للموضوعات الذين هم على الهامش أي أولئك الذين احتمال المتوقع يبدأ بالقرب من 0 5 ومع ذلك، وهذا هو خاصية وظيفة لوجستية، وليس البيانات هو الافتراض الذي تقوم به عند اختيار تشغيل نموذج لوجيت. يمكن أن تكون نماذج السجل المنطقي المتعدد الثقيل أكثر صعوبة لتفسير لأن المعاملات فقط مقارنة دولتين ذاكرة واضحة ستاتا و لوا د مجموعة البيانات التالية، التي تم بناؤها بعناية لتوضيح المزالق لتفسير نتائج لوجيت متعدد الحدود. وهو يحتوي على متغيرين، عدد صحيح y الذي يأخذ على القيم 1 و 2 و 3 ومتغير مستمر x وهي ترتبط سلبا كور y س. Now تشغيل النموذج التالي. معامل x للنتيجة 2 هو سلبي، لذلك فإنه من المغري أن نقول أن x يزيد من احتمال أن يجري 2 ينقص ولكن في الواقع هذا ليس هو الحال، كما أمر الهوامش سوف تظهر لك. mgingin، ديدكس x التنبؤ النتيجة 2.الخيارات التنبؤ يسمح لك باختيار هوامش الاستجابة هو دراسة توقع النتيجة 2 يحدد أن كنت مهتما في احتمال المتوقع من النتيجة 2 وفي الواقع احتمال النتيجة 2 يزيد مع x مشتقة يجري 0 016. كيف يمكن أن نذكر أن المعاملات التي قدمها ملوجيت تقارن فقط احتمال نتيجة معينة مع النتيجة الأساسية وبالتالي فإن معامل x من -5 34 للنتيجة 2 يخبرك أنه كلما زاد x، من المرجح أن تتحرك النتائج من النتيجة 2 إلى النتيجة 1 وفي الوقت نفسه فإن معامل x -21 292 للنتيجة 3 يخبرك بأنه كلما زادت الزيادات من المرجح أن تتحرك النتائج من النتيجة 3 إلى النتيجة 1 ما الذي لا يخبرك هو أنه كلما زادت x الملاحظات أيضا الانتقال من النتيجة 3 إلى النتيجة 2، وفي الواقع أن تأثير يهيمن على الحركة من 2 إلى 1.You يمكن أن نرى ذلك إذا قمت بتغيير فئة قاعدة الانحدار. mlogit يكس، قاعدة 2.Now المعاملات اقول لكم عن احتمال كل نتيجة مقارنة مع النتيجة 2، وحقيقة أن معامل x السلبي للنتيجة 3 هو أكبر بكثير من حيث القيمة المطلقة من معامل x إيجابي للنتيجة 1 يشير إلى أن زيادة س يزيد من احتمال النتيجة 2. ونحن نوصي بشدة باستخدام هوامش لاستكشاف ما يعني نتائج الانحدار الخاص بك. المنقحة المنقحة 2 14 2014.3 ستاتا Graphics. Stata ديه مرافق الرسم ممتازة، يمكن الوصول إليها من خلال الأمر الرسم البياني، انظر الرسم البياني للمساعدة لمحة عامة الرسوم البيانية الأكثر شيوعا في الإحصاء s هي مؤامرات زي تظهر نقاط أو خطوط هذه متوفرة في ستاتا من خلال فرعية فرعية توواي، والذي بدوره لديه 31 الفرعية الفرعية أو أنواع المؤامرة، وأهمها هي مبعثر وخط وسوف نصف أيضا مؤامرات شريط لفترة وجيزة، وهي متاحة من خلال شريط الفرعية، وغيرها من أنواع المؤامرة. البيانات 10 عرض محرر الرسومات التي يمكن استخدامها لتعديل الرسم البياني بشكل تفاعلي نحن لا إعادة هذه الممارسة، ومع ذلك، لأنه يتعارض مع أهداف توثيق وضمان استنساخ جميع الخطوات في البحث الخاص بك .3 1 سكاتيربلوتس. في هذا القسم سوف نقوم بتوضيح عدد قليل من المؤامرات باستخدام البيانات على انخفاض الخصوبة تستخدم لأول مرة في القسم 2 1 لقراءة البيانات من صافي علم ستاتا type. Tw ويت شهيتك، وهنا ق المؤامرة التي سوف تنتج في هذا القسم 3 1 1 A سكاتيربلوت بسيطة. لإنتاج مبعثر بسيط للتغيير في الخصوبة من خلال الإعداد الاجتماعي الذي تستخدم الأمر. ملاحظة أن تحدد y أولا، ثم x ستاتا تسميات المحاور باستخدام تسميات المتغير، إذا ث يتم تعريف العين أو أسماء متغيرة إن لم يكن الأمر قد يتم اختصاره إلى مبعثر توواي أو مجرد مبعثر إذا كان هذا هو المؤامرة الوحيدة على الرسم البياني سنضيف الآن أجراس و صفارات قليلة. 3 1 خطوط جاهزة. نفترض أننا نريد أن تظهر وخط الانحدار المجهزة كذلك في بعض الحزم سوف تحتاج إلى تشغيل الانحدار، حساب خط المجهزة، ومن ثم مؤامرة ستاتا يمكن أن تفعل كل ذلك في خطوة واحدة باستخدام نوع مؤامرة لفيت هناك أيضا مؤامرة كفيت ل يناسب التربيعية هذا يمكن جنبا إلى جنب مع مؤامرة مبعثر بإرفاق كل مؤامرة فرعية بين قوسين ويمكن للمرء أيضا الجمع بين المؤامرات باستخدام اثنين من أشرطة أفقية، ولكن أجد طريقة باستخدام الأقواس أكثر وضوحا. الآن افترض أننا نريد أن تضع فرق الثقة حول خط الانحدار ستاتا يمكن القيام بذلك مع نوع لفيتسي مؤامرة، الذي يرسم منطقة الثقة كفرقة رمادية هناك أيضا فرقة كفيتسي من أجل تربيعية يناسب لأن الفرقة الثقة يمكن أن تحجب بعض النقاط نرسم المنطقة أولا والنقاط في وقت لاحق. لاحظ أن هذا الأمر لا تسمية t هو محور ص ولكن يستخدم أسطورة بدلا من ذلك يمكنك تحديد تسمية للمحور ص باستخدام الخيار يتيتل، وحذف أسطورة واضحة بدلا باستخدام أسطورة إيقاف هنا نحدد كلا كخيار لأوامر توواي لجعل الخيار أكثر وضوحا ل والقارئ أضع الفاصلة في بداية خط جديد. 3 3 نقاط وضع العلامات. هناك العديد من الخيارات التي تسمح لك للسيطرة على علامات المستخدمة للنقاط، بما في ذلك شكل ولون، انظر مساعدة ماركيروبتيونس ومن الممكن أيضا أن تسمية النقاط باستخدام النص المضمنة في متغير آخر، وذلك باستخدام الخيار ملابيل فارنام في الخطوة التالية نضيف أسماء البلدان إلى المؤامرة. واحد مشكلة طفيفة مع التسميات هو تداخل كوستاريكا وترينيداد توباغو وبدرجة أقل بنما و نيكاراغوا يمكننا حل هذه المشكلة عن طريق تحديد موقف التسمية بالنسبة إلى علامة باستخدام ساعة 12 ساعة حتى 12 أعلاه، 3 هو إلى اليمين، و 6 أدناه و 9 هو إلى اليسار والخيار ملابف نحن إنشاء متغير للاحتفاظ بالمركز الذي وضعته الافتراضي إلى 3 س ساعة ثم نقل كوستاريكا إلى 9 س ساعة وترينيداد توباغو إلى قليلا فقط فوق ذلك في 11 س على مدار الساعة يمكننا أيضا نقل نيكاراغوا وبنما حتى قليلا، ويقول ل 2 س على مدار الساعة. الرسم البياني ثم يبدو على النحو التالي 3 1 4 العناوين والأساطير والتسميات التوضيحية. هناك خيارات تنطبق على جميع الرسوم البيانية في اتجاهين، بما في ذلك العناوين، والعلامات، والأساطير يمكن أن يكون الرسوم البيانية ستاتا العنوان والترجمة، وعادة في الجزء العلوي، ومذكرة أسطورة والتسمية التوضيحية عادة في الجزء السفلي، اكتب تيتليوبتيونس مساعدة لمعرفة المزيد عادة عنوان هو كل ما تحتاجه ستاتا 11 يسمح النص في الرسوم البيانية لتشمل جريئة، مائل، والرسائل اليونانية، والرموز الرياضية، واختيار الخطوط، اكتب مساعدة الرسم البياني النص لمعرفة more. Our والقرص النهائي إلى الرسم البياني سيكون لإضافة أسطورة لتحديد تناسب خطي و 95 فترة الثقة، ولكن ليس انخفاض الخصوبة نفسها ونحن نفعل ذلك باستخدام النظام 2 الخطي صالح 1 95 سي الخيار من أسطورة لتسمية العنصرين الثاني والأول في هذا النظام نحن أيضا استخدام حلقة 0 لنقل أسطورة داخل منطقة التآمر ، و بوس 5 لوضع مربع أسطورة بالقرب من موقف الساعة 5 س لدينا أمر كامل هو ثم. النتيجة هي الرسم البياني هو مبين في بداية هذا القسم إذا الرسم البياني الخاص بك تبدو مختلفة قليلا انها s ربما لأننا استخدمنا ألوان مختلفة استخدمت نسخة مخصصة من s2color انظر 3 2 5 أدناه للحصول على مزيد من المعلومات حول المخططات .3 1 5 موازين المحور والتصنيفات. هناك خيارات تتحكم في نطاق ونطاق المحاور، بما في ذلك زسكيل و يسكيل التي يمكن أن تكون حسابية أو تسجيل أو عكس ، اكتب مساعدة أكسيسكالوبتيونس لمعرفة المزيد خيارات أخرى السيطرة على وضع ووضع العلامات من القراد والعلامات الرئيسية والثانوية، مثل زلابيل شتيك و زمتيك وبالمثل للمحور ص، انظر مساعدة أكسيلابيلوبتيونس وعادة ما تكون الافتراضات مقبولة، ولكن من الجميل لمعرفة ما إذا كان بإمكانك تغييرها. 3 سيوضح الخط المؤامرات I خطوط الخط باستخدام بيانات عن متوسط ​​العمر المتوقع في الولايات المتحدة، وهو متاح كأحد مجموعات البيانات التي يتم شحنها مع ستاتا جرب سيسيوس دير لمعرفة ما هو متاح آخر. الفكرة هي مؤامرة متوسط ​​العمر المتوقع للذكور البيض والسوداء على مدى القرن العشرين مرة أخرى، لتهدئة شهيتك سوف تبدأ من خلال تبين لك المنتج النهائي، وبعد ذلك سوف نبني بت الرسم البياني من قبل bit.3 2 1 A بسيط خط مؤامرة. أبسط مؤامرة يستخدم جميع ديفولتس. إذا كنت في حيرة من قبل تراجع قبل عام 1920، جوجل الولايات المتحدة العمر المتوقع 1918 يمكننا اختصار الأمر إلى خط توواي أو حتى خط إذا كان هذا كل ما نقوم بالتآمر هذا الاختصار يعمل فقط ل مبعثر وخط. مؤامرة خط يسمح يمكنك تحديد أكثر من متغير y واحد، الترتيب هو y 1 y 2 يمكس في المثال الذي حددناه اثنين، وهو ما يتناسب مع متوسط ​​العمر الأبيض والأسود بدلا من ذلك، كنا يمكن أن تستخدم خطين المؤامرات خط ليومالي خط السنة ليبال السنة 3. 2 2 العناوين والأساطير. الرسم البياني الافتراضي هو جيد جدا، ولكن يبدو أسطورة جدا وردي ونحن سوف نقل معظم المعلومات إلى العنوان والحفاظ على العرق فقط في أسطورة. هنا استخدمنا ثلاثة خيارات، والتي كالمعتاد في ستاتا الذهاب بعد فاصلة عنوان الترجمة وأسطورة اختيار أسطورة أيون لديها العديد من الخيارات الفرعية استخدمنا النظام لإدراج مفاتيح وعلاماتها، قائلا أن السطر الأول يمثل البيض والثاني السود لإغفال مفتاح كنت مجرد تركه من القائمة لإضافة نص دون مفتاح مطابقة استخدام واصلة أو علامة ناقص للمفتاح هناك العديد من الخيارات أسطورة أخرى، انظر مساعدة ليجيندوبتيون لمعرفة المزيد. نود أن استخدام الفضاء أفضل قليلا عن طريق تحريك أسطورة داخل منطقة المؤامرة، ويقول حول موقف س 5 ساعة، حيث تحسن متوسط ​​العمر المتوقع ترك بعض غرفة الغيار كما ذكرنا سابقا يمكننا نقل أسطورة داخل منطقة التآمر باستخدام حلقة 0 الدائرة الداخلية، ووضعه بالقرب من موقف ساعة 5 س باستخدام بوس 5 لأن هذه هي أسطورة الخيارات الفرعية لديهم للذهاب داخل أسطورة. 3 2 3 لين Styles. I لا أعرف عنك، ولكن أجد من الصعب التمييز بين الخطوط الافتراضية على مؤامرة ستاتا يتيح لك التحكم في نمط الخط بطرق مختلفة الخيار كلستيل يتيح لك استخدام أسلوب اسمه، مثل الشبكة الأمامية يكسلين أو p1-p15 للأساليب المستخدمة ب y خطوط 1 إلى 15، انظر مساعدة لينستيل هذا مفيد إذا كنت ترغب في اختيار عناصر أسلوبك من مخطط كما هو مبين أدناه أدناه. بدلا من ذلك، يمكنك تحديد المكونات الثلاثة من نمط نمط الخط والعرض واللون. يتم تحديد باترنس باستخدام الخيار كليباترن الأنماط الأكثر شيوعا هي اندفاعة الصلبة ونقطة انظر مساعدة لينباترنستيل لمزيد من المعلومات. يتم تحديد عرض لين باستخدام كلويدث الخيارات المتاحة تشمل رقيقة والمتوسطة وسميكة انظر هيلب لينويدثستيل المساعدة ل more. Colors يمكن تحديد باستخدام الخيار كلكولور باستخدام أسماء اللون مثل الأحمر والأزرق والأزرق تيل سيينا وغيرها الكثير أو قيم رغب، انظر مساعدة colorstyle. Here ق كيفية تحديد الأزرق للبيض والأحمر للسود. لاحظ أن كلكولور هو خيار من خط المؤامرة، لذلك وضعنا أقواس جولة أمر الخط وأدخله هناك 3 2 4 خيارات المقياس. يبدو كما لو أن التحسن في متوسط ​​العمر المتوقع تباطأ قليلا في النصف الثاني من القرن ويمكن تقدير ذلك بشكل أفضل باستخدام مقياس سجل، حيث فإن خط مستقيم يشير إلى التحسن المستمر في النسبة المئوية ويتم ذلك بسهولة باستخدام خيارات محور القيادة في اتجاهين، انظر مساعدة أكسيسوبتيونس وعلى وجه الخصوص يسكيل التي تمكنك من اختيار سجل الحساب أو المقاييس عكس هناك أيضا نطاق سوبوبتيون للسيطرة على التآمر مجموعة هنا سوف تحدد y - المدى كما 25 إلى 80 لتحريك المنحنيات قليلا up.3 2 5 الرسم البياني Schemes. Stata يستخدم مخططات للسيطرة على مظهر الرسوم البيانية، راجع مخطط المساعدة يمكنك تعيين المخطط الافتراضي لاستخدامها في جميع الرسوم البيانية مع مجموعة سشيمنام يمكنك أيضا إعادة عرض الرسم البياني الأخير باستخدام مخطط مختلف مع عرض الرسم البياني، مخطط schemename. To رؤية قائمة من المخططات المتاحة نوع الاستعلام الرسم البياني، ومخططات محاولة s2color للرسوم البيانية الشاشة، s1manual للنمط المستخدمة في أدلة ستاتا ، والاقتصادي للأسلوب المستخدم في الإيكونوميست باستخدام هذا الأخير نحصل على الرسم البياني هو مبين في بداية هذا القسم. 3 3 إدارة Graphs. Stata بتتبع الرسم البياني الأخير الذي رسمت، والتي يتم تخزينها في الذاكرة، و ويطلق عليه الرسم البياني يمكنك فعلا الاحتفاظ بأكثر من رسم بياني واحد في الذاكرة إذا كنت تستخدم خيار الاسم لتسمية الرسم البياني عند إنشائه هذا مفيد للجمع بين الرسوم البيانية، اكتب الرسم البياني للمساعدة الجمع بين لمعرفة المزيد لاحظ أن الرسوم البيانية أبقى في الذاكرة تختفي عند الخروج من ستاتا، حتى إذا قمت بحفظ البيانات، إلا إذا قمت بحفظ الرسم البياني نفسه. لحفظ الرسم البياني الحالي على القرص باستخدام تنسيق ستاتا s الخاصة، اكتب الرسم البياني حفظ اسم الملف يحتوي هذا الأمر على خيارين، استبدال التي تحتاج إلى استخدامها إذا كان الملف بالفعل موجود، وآسيس الذي يجمد الرسم البياني بما في ذلك نمطه الحالي ومن ثم يحفظه الافتراضي هو حفظ الرسم البياني في شكل حي التي يمكن تحريرها في الدورات المستقبلية، على سبيل المثال عن طريق تغيير المخطط بعد حفظ الرسم البياني في شكل ستاتا يمكنك تحميله من القرص مع الأمر البياني استخدام اسم الملف لاحظ أن الرسم البياني حفظ واستخدام الرسم البياني هي مماثلة لحفظ واستخدام ملفات ستاتا أي رسم بياني المخزنة في الذاكرة يمكن عرضها باستخدام عرض الرسم البياني يمكنك أيضا قائمة أو تصف أو إعادة تسمية أو نسخ أوإسقاط الرسوم البيانية المخزنة في الذاكرة، اكتب مساعدة غرافمانيبولاتيون لمعرفة المزيد. إذا كنت تخطط لدمج الرسم البياني في مستند آخر قد تحتاج إلى حفظه في شكل أكثر المحمولة يمكن ستاتا الصورة الرسم البياني تصدير اسم الرسم البياني تصدير الرسم البياني باستخدام مجموعة واسعة من ناقلات أو تنسيقات النقطية، والتي عادة ما تكون مفهومة من امتداد الملف تنسيقات المتجهات مثل ويندوز ملف تعريف ومف أو إمف أو أدوبي s بوستسكريبت ومتغيراته بس، إبس، بدف تحتوي أساسا تعليمات الرسم وبالتالي هي قرار مستقل، لذلك هم الأفضل لإدراجها في وثائق أخرى حيث يمكن تغيير حجمها تنسيقات النقطية مثل ينغ شبكة الرسومات المحمولة حفظ بكسل الصورة بكسل عن طريق استخدام دقة العرض الحالية، وأفضل لإدراجها في صفحات الويب. يمكنك أيضا طباعة الرسم البياني باستخدام الرسم البياني طباعة أو نسخ ولصق في وثيقة باستخدام الحافظة ويندوز للقيام بذلك انقر بزر الماوس الأيمن على النافذة التي تحتوي على الرسم البياني ثم حدد نسخة من قائمة السياق .2017 جيرم ن رودر غيز ، جامعة برينستون. كيف يمكنني استخدام الأمر هوامش لفهم التفاعلات المتعددة في الانحدار اللوجستي ستاتا 11 ستاتا التعليمات. هوامش الأمر الجديد في ستاتا 11، يمكن أن تكون أداة مفيدة جدا في فهم وتفسير التفاعلات سوف نقوم بتوضيح الأمر ل نموذج الانحدار اللوجستي مع اثنين من الفئوية من خلال التفاعلات المستمرة نبدأ من خلال تحميل مجموعة البيانات mlogcatcon. In هذه البيانات y هو متغير الاستجابة الثنائية و m و s هي التنبؤات المستمرة المتغير و الذي يقف للإناث، هو التنبؤ ثنائي سوف نتفاعل مع f على حد سواء م و ق هنا هو نموذج الانحدار اللوجستي. لاحظت أن f من قبل s التفاعل ذو دلالة إحصائية في حين أن f من خلال التفاعل م ليس لأن هذا هو نموذج غير الخطية سنضطر إلى أخذ قيم جميع المتغيرات المتغيرة في الاعتبار في فهم ما يجري في النموذج. سنبدأ مع أمر الهامش الذي ينظر إلى الفرق المنفصل في احتمال بين الذكور والإناث لمدة خمسة د مستويات إفرنت s بينما يحمل m عند قيمته المتوسطة نحصل على الفرق المنفصل في الاحتمال باستخدام خيار ديدكس مع المتنبؤ الثنائي سيعقد المتغير m بقيمته المتوسطة باستخدام الخيار أتمانز. في حين أن نتائج أمر الهوامش أعلاه هي صحيح تماما، فإنها تعكس التغير المنفصل في الاحتمال لقيمة واحدة فقط من m إذا قمنا بإزالة الخيار أتمانز نحصل على متوسط ​​التأثير الهامشي، أي التغير المنفصل في الاحتمال لكل من قيم s المتوسط ​​عبر القيم الملحوظة من m هنا هو كيف يبدو الأمر هوامش الآن. لقد ق المضي قدما ورسم بياني هذه النتائج بما في ذلك فترات الثقة 95 سنبدأ بوضع القيم اللازمة في مصفوفة باستخدام التقنيات المعروضة في ستاتا أسئلة وأجوبة كيف يمكنني رسم بياني لنتائج أمر هوامش و سوف تتبع أوامر مصفوفة من قبل الرسم البياني خط توواي. هوامش الأمر والرسم البياني أعلاه تعطينا فكرة جيدة جدا عن كيفية تغيير منفصلة في احتمال يختلف عبر فرق إرنت قيم s ولكن ما زلنا لا نعرف كيف يتغير هذا مع قيم مختلفة من m دعونا نحاول الأمر هوامش مرة أخرى، وهذه المرة متفاوتة على حد سواء s و m. الصفوف الخمسة الأولى تعطي التغيير المنفصل للقيم الخمس ل s عقد م في 30 الخمسة المقبلة عقد م في 40 وهلم جرا واحدة من السمات الأكثر إثارة للاهتمام هو كيف عدد قليل من التغييرات المنفصلة ذات دلالة إحصائية على الرغم من أن f العام من قبل s التفاعل كان كبيرا. الآن يمكننا جمع القيم اللازمة في مصفوفة في التحضير للرسم البياني. تلعب s تبدأ من خلال رسم بياني تأثير قيم مختلفة من s مع خطوط منفصلة لكل قيمة م. على الرغم من أنه لم يكن هناك الكثير من القيم الهامة في الجدول الهوامش أعلاه، خطوط لكل من قيم م تبدو مختلفة نوعا ما عن بعضها البعض في حين أن خط ل m متساوية 30 هو مسطح إلى حد ما خط ل م يساوي 70 يعرض الكثير من التباين، اسقاط الأول ثم تسلق بشكل حاد حول ق المساواة 50.Now أن نعرف ما هي الاختلافات في ق القيم من م يبدو، يمكننا عكس المتغيرات في خط الرسومات الأوامر توواي لمعرفة ما الاختلافات في م لقيم s يبدو مثل. وبطبيعة الحال، ونحن نبحث في نفس القيم 25 كما في الرسم البياني السابق، نظمت فقط بشكل مختلف هذه المرة و خط ل s تساوي 70 هو واحد الذي يبرز من الآخرين. إذا كان النموذج الخاص بك هو أكثر تعقيدا من هذا واحد، عليك أن تقرر ما يجب القيام به مع كل من المتغيرات المتغيرة يمكنك الاحتفاظ بها ثابتة على واحد أو أكثر من القيم أو يمكنك متوسط ​​أكثر منهم أيا كان الخيار الذي تجعلك تحتاج إلى إدراك أن قيم جميع المتغيرات المتناولة في النماذج غير الخطية. هنا قد حاولت هذه العملية من ثلاث خطوات 1 تراجع المساعدة المالية على العرق 2 الحصول على القيم المتوقعة مع هوامش 3 إنشاء شريط الرسم البياني باستخدام هامشsplot. Something مثل this. reg المعونة المالية تأكد من استخدام i - نقطة قبل السباق للإشارة إلى ستاتا أن سباق هو المتغيرات الفئوية غير مرتبة. المرجان، على هامش هامرسبلوت، x سباق ريكاست bar. I م متأكد من وجود طريقة سا للقيام بذلك مع توواي شريط أيضا، فإنه يساعد إذا قمت بنشر التعليمات البرمجية التي استخدمت. وسوف نحاول أن شكرا، على الرغم من أنه يبدو متورطا قليلا للحصول على رقم موجز بسيط من نسبة الناس على المساعدات المالية. الشفرات التي استخدمتها في هذه اللحظة هو هذا. histogram فينانسياليد، نسبة مئوية منفصلة من قبل سباق. هذا الرمز هو ما أريد تقريبا، إلا أنه يدل على 0s من قبل سباق كذلك، و دوسن ر عرض النسب المئوية الدقيقة لكل - عليك أن يكون ل غستيمات النسبة. وثيقة توثيق استخدام بلابيل أوبتيون. وقال ان المتغير الخاص بك كان 0-1 في هذه الحالة سيكون متوسطه في تلك الفترة بطريقة أو بأخرى حصلت على مقياس في المئة، وهذا هو ما كنت want. The نسبة مئوية من متوسط ​​فينانسيال سيكون أفضل كما شيء مثل في المئة على المعونة المالية. أنت لا تحتاج إلى أسطورة هنا الفئات الخاصة بك سوف تناسب جيدا كما تسميات محور. عرض بالضبط بناء الجملة التي استخدمتها هو الموصى بها. حرر تحريره نيك كوكس 28 أبر 2014، 02 14.A أفضل طريقة لعرض البيانات الخاصة بك هو استخدام أشرطة أفقية يسمح هذا بإلغاء نص الأسطورة د القارئ يمكن قراءة هوية الفئة والنسبة المئوية في حركة أفقية واحدة. أنا لم تستخدم ألوان مختلفة لأجناس مختلفة، لأن جميع القضبان تظهر نفس الشيء، والألوان لم تعد هناك حاجة لربط الحانات الفردية إلى كما استخدمت أيضا البعد الرأسي من المخطط لإظهار الحجم النسبي لكل فئة، بدلا من وجودها في ترتيب تعسفي كما كان لديك. وقد تم ذلك مع نيك كوكس ق - كاتبلوت - أمر استخدمت الأوزان تردد إلى تشير إلى حجم كل bar. catplot رفريس مهاجم fw. An مقدمة في ستاتا Graphics. Stata يتضمن مجموعة غنية من الأدوات لخلق الرسومات جودة النشر بين مجموعة واسعة من الرسوم البيانية يمكنك جعل والعدد الهائل من التفاصيل يمكنك التحكم في الرسم البياني، ستاتا الرسومات يمكن أن يكون موضوع شاقة ومع ذلك، سوف ليرة لبنانية ربما تحتاج فقط إلى جعل عدد قليل من أنواع مختلفة من الرسوم البيانية، وفي معظم الحالات ستاتا s الإعدادات الافتراضية سوف يكون على ما يرام ما هو أكثر من ذلك، ستاتا الصورة الرسومية واجهة المستخدم غوي ينظم خيارات الرسوم البيانية المختلفة بطريقة بديهية حتى تتمكن من العثور عليها عندما كنت في حاجة إليها دون حفظ بناء الجملة لكل واحد وهذا لا يعني أنك لا يجب أن تضع الأوامر الرسم البياني الخاص بك في الملفات تفعل بمجرد إنشائها، ولكن هذا يعني أن الرسوم البيانية المعقدة يمكنك استخدام واجهة المستخدم الرسومية لإنشاء الأوامر لك ل store. Stata 10 وأضاف أيضا محرر الرسم البياني الذي يسمح لك لتعديل الرسم البياني بعد قمت بإنشائه هذا يمنحك المزيد من السيطرة على الرسم البياني الخاص بك، ولكن على عكس واجهة المستخدم الرسومية لإنشاء رسم بياني محرر لا تعطيك الأمر يمكنك إعادة تشغيل في وقت لاحق إذا قمت بإجراء أي تغييرات في وقت لاحق على البيانات الخاصة بك، عليك أن تبدأ الرسم البياني الخاص بك من الصفر وهكذا فمن الأفضل لخلق الرسم البياني الذي تريد في المقام الأول حيثما كان ذلك ممكنا، ولكن المحرر لا يزال إضافة مفيدة جدا. هذه المقالة سوف تناقش خلق الرسوم البيانية باستخدام واجهة المستخدم الرسومية ستاتا، بنية بناء جملة الرسم البياني دون مسكن أكثر من اللازم على التفاصيل، وبعض الأنواع الشائعة من الرسوم البيانية، ومحرر الرسم البياني يجب أن يكون لديك بعض الألفة مع ستاتا الأساسي قبل البدء إذا كنت لا ر، والنظر في البدء مع ستاتا للباحثين أو ستاتا للطلاب أفضل طريقة لاستخدام هذه المقالة هو قراءتها على الكمبيوتر وتنفيذ الخطوات المذكورة في الواقع الأمثلة في هذا المادة سوف تستخدم مجموعة بيانات السيارات التي تأتي مع ستاتا، لذلك تبدأ من قبل الكتابة. لتحميل فإنه لا تتردد في التجربة كما تذهب، وخاصة مع الإعدادات التي لا تناقش عادة لأنهم إعادة إما واضحة إلى حد ما أو نادرا ما تستخدم إنشاء رسم بياني أبدا تغيير البيانات الخاصة بك، وبالتالي فإن أسوأ ما يمكن أن يحدث هو أن الرسم البياني الخاص بك تبين أن تكون عديمة الفائدة أو مجرد القبيح عادي. الرسم البياني باستخدام واجهة المستخدم الرسومية. لنبدأ مع مؤامرة مبعثر بسيط مع الوزن كما متغير X و مبغ كما Y المتغير يشير ستاتا إلى أي رسم بياني يحتوي على متغير Y ومتغير X كرسم بياني توواي، لذلك انقر فوق الرسم البياني توواي الرسم البياني الخطوة التالية هي تحديد مؤامرة في مصطلحات ستاتا، والمؤامرة هي بعض البيانات المحددة تصور على سبيل المثال، مؤامرة مبعثر من ميلا في الغالون على الوزن الرسم البياني هو صورة كاملة، بما في ذلك المحاور والعناوين والأساطير، الخ أيضا، قد يحتوي على رسم بياني واحد المؤامرات متعددة سوف مربع حوار توواي الأساسية تسمح لك لتحديد العديد المؤامرات كما تحتاج، بالإضافة إلى السيطرة على خصائص أخرى من الرسم البياني. لتحديد مؤامرة، انقر فوق إنشاء لك ثم الحصول على مربع حوار حيث يمكنك وصف المؤامرة التي تريد ترك مجموعة تعيين إلى المؤامرات الأساسية ونوع تعيين إلى مبعثر ل المتغير Y حدد أو اكتب ميلا في الغالون وبالنسبة للمتغير X حدد أو اكتب الوزن ملاحظة لينوكس ستاتا لا يسمح لك لتحديد المتغيرات لذلك سوف تحتاج إلى كتابة أسمائهم في ويندوز ستاتا يمكنك القيام به. إذا قمت بالنقر فوق تقديم الرسم البياني سيكون 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