Sunday 21 January 2018

Perform f test in stata forex


ستاتا: تحليل البيانات والبرامج الإحصائية كريستين ماكدونالد، أوامر تقدير ستاتاكورب توفر اختبار تي أو اختبار z لفرضية نول أن معامل يساوي الصفر. يمكن لأمر الاختبار إجراء اختبارات والد للفرضيات الخطية البسيطة والمركبة على المعلمات، ولكن اختبارات والد هذه تقتصر أيضا على اختبارات المساواة. اختبارات من جانب واحد لإجراء اختبارات من جانب واحد، يمكنك أولا إجراء اختبار والد على الوجهين المقابلة. ثم يمكنك استخدام النتائج لحساب إحصائية الاختبار و p - value للاختبار من جانب واحد. ليترسكوس يقول أن إجراء الانحدار التالي: إذا كنت ترغب في اختبار أن معامل على الوزن. بيتا الوزن. هو سالب (أو إيجابي)، يمكنك أن تبدأ بإجراء اختبار والد للفرضية الصفرية أن هذا المعامل يساوي الصفر. اختبار والد أعطى هنا هو اختبار F مع 1 البسط درجة الحرية و 71 المقاسم درجات الحرية. يرتبط توزيع ستودنترسكوس t مباشرة بتوزيع F في أن مربع التوزيع ستودنتسكوس t مع د درجات الحرية يعادل التوزيع F مع 1 البسط درجة الحرية ودرجة مقاسم الحرية. وطالما أن الاختبار F لديه درجة بسط من الحرية، فإن الجذر التربيعي للإحصاء F هو القيمة المطلقة للإحصائية t للاختبار أحادي الجانب. لتحديد ما إذا كانت هذه الإحصائية t إيجابية أو سلبية، تحتاج إلى تحديد ما إذا كان معامل المجهزة موجبة أو سلبية. للقيام بذلك، يمكنك استخدام الدالة (). ثم، باستخدام الدالة تيل () جنبا إلى جنب مع النتائج التي تم إرجاعها من أمر الاختبار، يمكنك حساب p - القيم للاختبارات من جانب واحد على النحو التالي: في حالة خاصة حيث كنت مهتما في اختبار ما إذا كان معامل هو أكبر من، أو أقل من، أو يساوي الصفر، يمكنك حساب p - القيم مباشرة من الناتج الانحدار. عندما يكون المعامل المقدر موجبا، أما بالنسبة للوزن. يمكنك القيام بذلك على النحو التالي: p-القيمة 0.008 (المعطى في الناتج الانحدار) p-القيمة 0.567 / 2 0.284 من ناحية أخرى، إذا كنت ترغب في إجراء اختبار مثل H 0. بيتا الوزن لتر 1، لا يمكنك حساب p - قيمة مباشرة من نتائج الانحدار. هنا سيكون لديك لإجراء اختبار والد أولا. اختبارات من جانب واحد z في الإخراج لبعض أوامر التقدير، وسوف تجد أن يتم الإبلاغ عن إحصاءات z بدلا من إحصاءات t. في هذه الحالات، عند استخدام الأمر اختبار، سوف تحصل على اختبار تشي مربع بدلا من اختبار F. والعلاقة بين التوزيع العادي المعياري والتوزيع في مربعات تشي تشبه العلاقة بين توزيع ستودنتسكوس والتوزيع F. في الواقع، الجذر التربيعي للتوزيع تشي مربع مع 1 درجة من الحرية هو التوزيع العادي العادي. لذلك، يمكن إجراء اختبارات z من جانب واحد على نحو مماثل للاختبارات t من جانب واحد. على سبيل المثال، هنا يعود الأمر اختبار r (chi2). والتي يمكن استخدامها جنبا إلى جنب مع الدالة العادية () لحساب p - القيم المناسبة. وأخيرا، إذا كنت ترغب في إجراء اختبار عدم المساواة لاثنين من المعاملات الخاصة بك، مثل H 0. بيتا سن غ بيتا الصف. يمكنك أولا إجراء اختبار والد التالي: ثم حساب قيمة p المناسبة: مرة أخرى، هذا النهج (إجراء اختبار والد واستخدام النتائج لحساب p - قيمة لاختبار من جانب واحد) هو المناسب فقط عندما يكون الوالد F إحصائية لديها 1 درجة من الحرية في البسط أو الإحصائية تشي تشي مربع لديه درجة 1 من الحرية. علاقات التوزيع التي نوقشت أعلاه ليست صحيحة إذا كانت درجات الحرية هذه أكبر من 1. مرحبا بكم في معهد للبحوث الرقمية والتعليم ستاتا المشروح الإخراج تي اختبار أداء تيست اختبار t لعينة واحدة، عينتين والملاحظات المقترنة. يقارن اختبار t - عينة واحدة متوسط ​​العينة إلى رقم معين (الذي تقوم بتوريده). تقارن العينات t - اختبار مستقل الفرق في الوسائل من المجموعتين إلى قيمة معينة (عادة 0). وبعبارة أخرى، فإنه يختبر ما إذا كان الاختلاف في الوسائل هو 0. يقارن اختبار عينة أو الاقتران t المقترنة الفرق في الوسائل من المتغيرين تقاس على نفس مجموعة من المواضيع إلى عدد معين (عادة 0)، مع الأخذ في الاعتبار حقيقة أن الدرجات ليست مستقلة. في أمثلةنا، سوف نستخدم مجموعة بيانات hsb2. عينة واحدة اختبار t اختبار واحد عينة تي اختبار الفرضية نول أن متوسط ​​السكان يساوي العدد المحدد المحدد باستخدام الكتابة الخيار. في هذا المثال، سنقارن متوسط ​​الكتابة المتغيرة مع قيمة محددة مسبقا 50. في الممارسة العملية، يجب أن تستند القيمة التي يقارن بها المتوسط ​​على اعتبارات نظرية و / أو أبحاث سابقة. وتحسب ستاتا الإحصائي t وقيمته p تحت افتراض أن العينة تأتي من توزيع طبيعي تقريبا. إذا كانت قيمة p المقترنة بالاختبار t صغيرة (0.05 غالبا ما تستخدم كعتبة)، هناك دليل على أن المتوسط ​​يختلف عن القيمة المفترضة. إذا كانت قيمة p المرتبطة اختبار t ليست صغيرة (p غ 0.05)، ثم لا يتم رفض فرضية فارغة ويمكن أن نستنتج أن المتوسط ​​لا يختلف عن القيمة المفترضة. في هذا المثال، إحصاء t هو 4.1403 مع 199 درجة من الحرية. القيمة p المقابلة ذات الذيلين هي .0001، وهي أقل من 0.05. نستنتج أن متوسط ​​الكتابة المتغيرة يختلف عن 50. ملخص الإحصائيات أ. متغير - هذا هو المتغير الذي أجري الاختبار. ب. ملاحظة - عدد الملاحظات الصالحة (أي غير المفقودة) المستخدمة في حساب الاختبار t. ج. متوسط ​​- هذا هو متوسط ​​المتغير. د. الأمراض المنقولة جنسيا. يخطئ. - هذا هو الانحراف المعياري المقدر لمتوسط ​​العينة. إذا رسمنا عينات متكررة من حجم 200، فإننا نتوقع الانحراف المعياري للعينة يعني أن تكون قريبة من الخطأ القياسية. ويقدر الانحراف المعياري لتوزيع عينة العينة على أنه الانحراف المعياري للعينة مقسوما على الجذر التربيعي لحجم العينة: 9.478586 / (سرت (200)) .6702372. ه. الأمراض المنقولة جنسيا. ديف. - هذا هو الانحراف المعياري للمتغير. F. 95 فترة الثقة - هذه هي الحد الأدنى والعلوي من فترة الثقة للمتوسط. وتحدد فترة الثقة للمتوسط ​​مجموعة من القيم التي قد تقع فيها المعلمة السكانية غير المعروفة، في هذه الحالة المتوسط. ويعطى بواسطة حيث s هو انحراف العينة من الملاحظات و N هو عدد الملاحظات الصحيحة. يمكن حساب القيمة t في الصيغة أو العثور عليها في أي كتاب إحصائي بدرجات الحرية هي N-1 وتكون القيمة p هي 1 ألفا / 2، حيث ألفا هو مستوى الثقة ويكون افتراضيا هو 95. اختبار الاحصائيات g. يعني - هذا هو متوسط ​​يجري اختبارها. في هذا المثال هو متوسط ​​الكتابة. ح. t - هذا هو الطالب t الإحصائية. وهي نسبة الفرق بين متوسط ​​العينة والعدد المعطى للخطأ المعياري للمتوسط: (52.775 - 50) / .6702372 4.1403. وبما أن الخطأ المعياري للمتوسط ​​يقيس تباين متوسط ​​العينة، كلما قل الخطأ المعياري للمتوسط، زاد احتمال أن يكون متوسط ​​عينتنا قريبا من المتوسط ​​الحقيقي للسكان. ويتضح ذلك من الأرقام الثلاثة التالية. في جميع الحالات الثلاث، الفرق بين الوسائل السكانية هو نفسه. ولكن مع تباين كبير من وسائل العينة، الرسم البياني الثاني، اثنين من السكان تتداخل الكثير. ولذلك، فإن الفرق قد تأتي بشكل جيد عن طريق الصدفة. من ناحية أخرى، مع التباين الصغير، والفرق هو أكثر وضوحا كما هو الحال في الرسم البياني الثالث. وكلما قل الخطأ المعياري للمتوسط، كلما زاد حجم القيمة t، وبالتالي كلما كانت قيمة p أصغر. أنا. هو - هذه هي الفرضية الفارغة التي يتم اختبارها. ويقيم الاختبار التجريبي للعينة الواحدة الفرضية الصفرية بأن متوسط ​​السكان يساوي العدد المعطى. ي. درجات الحرية - درجات الحرية للاختبار التجريبي للعينة الواحدة هي ببساطة عدد الملاحظات الصحيحة ناقص 1. لقد فقدنا درجة واحدة من الحرية لأننا قدرنا المتوسط ​​من العينة. وقد استخدمنا بعض المعلومات من البيانات لتقدير المتوسط، وبالتالي فإنه غير متوفر للاستخدام للاختبار ودرجات الحرية لحساب ذلك. ك. بيأر (T tt t)، بيأر (T غ t) - هذه هي قيم p-تايلد واحد التي تقيم قيمة صفرية مقابل البدائل التي يقل متوسطها عن 50 (الاختبار الأيسر) وأكبر من 50 (الاختبار الصحيح). وتحسب هذه الاحتمالات باستخدام التوزيع t. مرة أخرى، إذا كانت قيمة P أقل من مستوى ألفا المحدد مسبقا (عادة 0.05 أو .01) سوف نستنتج أن المتوسط ​​يكون أكبر إحصائيا أو أقل من القيمة الافتراضية الفارغة. ل. بيأر (T غ t) - هذه هي القيمة p ثنائية الذيل التي تقيم القيمة الفارغة مقابل بديل أن المتوسط ​​لا يساوي 50. وهو يساوي احتمال مراقبة قيمة مطلقة أكبر t تحت الفرضية الفارغة. إذا كانت قيمة P أقل من مستوى ألفا المحدد مسبقا (عادة .05 أو .01، هنا الأول) سنخلص إلى أن المتوسط ​​يختلف إحصائيا عن الصفر. على سبيل المثال، قيمة p للكتابة أصغر من 0.05. لذا نخلص إلى أن متوسط ​​الكتابة يختلف عن 50. اختبار t المقترن يستخدم اختبار t المقترن (أو كوتديبندنتكوت) عندما تكون الملاحظات غير مستقلة عن بعضها البعض. في المثال أدناه، أخذ الطلاب أنفسهم كلا من الكتابة واختبار القراءة. وبالتالي، تتوقع أن تكون هناك علاقة بين الدرجات التي يقدمها كل طالب. حسابات الاختبار t المقترنة لهذا. لكل طالب، نحن ننظر أساسا إلى الاختلافات في قيم المتغيرين والاختبار إذا كان متوسط ​​هذه الاختلافات يساوي الصفر. في هذا المثال، فإن الإحصاء t هو 0.8673 مع 199 درجة من الحرية. القيمة p المقابلة ذات الذيلين هي 0.3868، وهي أكبر من 0.05. نستنتج أن متوسط ​​الفرق بين الكتابة والقراءة لا يختلف عن 0. ملخص الإحصائيات أ. متغير - هذه هي قائمة المتغيرات المستخدمة في الاختبار. ب. ملاحظة - عدد الملاحظات الصالحة (أي غير المفقودة) المستخدمة في حساب الاختبار t. ج. متوسط ​​- هذه هي قائمة وسائل المتغيرات. يعرض الصف الأخير الفرق البسيط بين الوسيلتين. د. الأمراض المنقولة جنسيا. يخطئ. - هذا هو الانحراف المعياري المقدر لمتوسط ​​العينة. إذا رسمنا عينات متكررة من حجم 200، فإننا نتوقع الانحراف المعياري للعينة يعني أن تكون قريبة من الخطأ القياسية. ويقدر الانحراف المعياري لتوزيع متوسط ​​العينة على أنه الانحراف المعياري للعينة مقسوما على الجذر التربيعي لحجم العينة. وهذا يوفر مقياسا لتقلب متوسط ​​العينة. نظرية الحد المركزي يخبرنا أن وسيلة العينة توزع عادة تقريبا عندما يكون حجم العينة 30 أو أكبر. ه. الأمراض المنقولة جنسيا. ديف. - هذا هو الانحراف المعياري للمتغير. يعرض الصف الأخير الانحراف المعياري للفرق الذي لا يساوي الفرق بين الانحرافات المعيارية لكل مجموعة. F. 95 فترة الثقة - هذه هي الحد الأدنى والعلوي من فترة الثقة للمتوسط. وتحدد فترة الثقة للمتوسط ​​مجموعة من القيم التي قد تقع فيها المعلمة السكانية غير المعروفة، في هذه الحالة المتوسط. ويعطى بواسطة حيث s هو انحراف العينة من الملاحظات و N هو عدد الملاحظات الصحيحة. يمكن حساب القيمة t في الصيغة أو العثور عليها في أي كتاب إحصائي بدرجات الحرية هي N-1 وتكون القيمة p هي 1 ألفا / 2، حيث ألفا هو مستوى الثقة ويكون افتراضيا هو 95. (متوسط) غ 0.8673 h هو: مين (ديف) 0 درجة الحرية 199 i ها: يعني (ديف) لوت 0 k ها: يعني (ديف) 0 j ها: مين (ديف) غ 0 k بيأر (T لوت t) 0.8066 بيأر (T غ t) 0.3868 بيأر (T غ t) 0.1934 g. متوسط ​​(ديف) يعني (var1 - فار 2) - اختبار t للمجموعات التابعة يشكل عينة عشوائية واحدة من الاختلاف المقترن، الذي يعمل كاختبار عينة عشوائية بسيطة. وتفسير قيمة t وقيمة p هو نفسه كما هو الحال في عينة عشوائية بسيطة. ح. t - هذا هو الإحصاء t. وهي نسبة متوسط ​​الفرق إلى الخطأ المعياري للفرق (.545 / .6283822). أنا. درجات الحرية - درجات الحرية للملاحظات المقترنة هي ببساطة عدد الملاحظات ناقص 1. وذلك لأن الاختبار يتم على عينة واحدة من الاختلافات المقترنة. ي. بيأر (T غ t) - هذه هي القيمة p ثنائية الذيل المحسوبة باستعمال التوزيع t. هو احتمال مراقبة قيمة مطلقة أكبر من t تحت فرضية فارغة. إذا كانت قيمة p أقل من مستوى ألفا المحدد مسبقا (عادة 0.05 أو 0.01، هنا الأول) سوف نستنتج أن متوسط ​​الفرق بين الكتابة والقراءة يختلف إحصائيا عن الصفر. على سبيل المثال، قيمة p للفرق بين الكتابة والقراءة أكبر من 0.05 لذلك نستنتج أن الفرق المتوسط ​​لا يختلف إحصائيا بشكل ملحوظ عن 0. k. بيأر (T لوت t)، بيأر (T غ t) - هذه هي قيم p ذيل واحد لتقييم البدائل (متوسط ​​قيمة لوت H0) و (متوسط ​​قيمة غ H0)، على التوالي. مثل بيأر (T غ t). يتم حسابها باستخدام التوزيع t. مرة أخرى، إذا كانت قيمة p أقل من مستوى ألفا المحدد مسبقا (عادة .05 أو .01) سوف نستنتج أن الفرق يعني إحصائيا أكبر بكثير من الصفر أو أقل منه. مجموعة اختبار t المستقلة تم تصميم هذا الاختبار t لمقارنة وسائل المتغير نفسه بين مجموعتين. في مثالنا، نقارن متوسط ​​درجات الكتابة بين مجموعة الطالبات ومجموعة الطلاب الذكور. من الناحية المثالية، يتم اختيار هذه المواضيع عشوائيا من عدد أكبر من السكان. ويفترض الاختبار أن الفروق بين المجموعتين هي نفسها. تفسير لقيمة p هو نفسه كما هو الحال في نوع آخر من الاختبارات t. في هذا المثال، الإحصاء t هو -3.7341 مع 198 درجة من الحرية. القيمة p المقابلة ذات الذيلين هي 0.0002، وهي أقل من 0.05. نستنتج أن اختلاف الوسائل في الكتابة بين الذكور والإناث يختلف عن 0. ملخص الإحصائيات أ. المجموعة - هذا العمود يعطي فئات المتغير المستقل، في حالتنا الأنثى. يتم تحديد هذا المتغير بواسطة عبارة (أنثى). ب. ملاحظة - هذا هو عدد الملاحظات الصالحة (أي غير المفقودة) في كل مجموعة. ج. متوسط ​​- هذا هو متوسط ​​المتغير التابع لكل مستوى من المتغيرات المستقلة. على السطر الأخير يتم إعطاء الفرق بين الوسائل. د. ستد إر - هذا هو الخطأ المعياري للمتوسط ​​لكل مستوى من المتغير المستقل. ه. ستد ديف - هذا هو الانحراف المعياري للمتغير التابع لكل من مستويات المتغير المستقل. وفي السطر الأخير، يعطى الانحراف المعياري للفرق. F. 95 كونف. الفاصل الزمني - هذه هي حدود الثقة الدنيا والعليا للوسائل. (إناث) غ - -3.7341 h المعدل: 0 درجة الحرية: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (T غ t) 0.0002 بيأر (T غ t) 0.9999 g. متوسط ​​(ذكر) - متوسط ​​(أنثى) - يقارن الاختبار t بين الوسائل بين المجموعتين، الفرضية الفارغة هي أن الفرق بين الوسيلة هو صفر. ح. t - هذا هو الإحصاء t. وهي نسبة متوسط ​​الفرق إلى الخطأ المعياري للفرق: (-4.869947 / 1.304191). أنا. درجات الحرية - درجات الحرية للملاحظات المقترنة هي ببساطة عدد الملاحظات ناقص 2. نحن نستخدم درجة واحدة من الحرية لتقدير متوسط ​​كل مجموعة، ولأن هناك مجموعتين، نطرح درجتين من الحرية. ي. بيأر (T غ t) - هذه هي القيمة p ثنائية الذيل المحسوبة باستعمال التوزيع t. هو احتمال مراقبة قيمة مطلقة أكبر من t تحت فرضية فارغة. إذا كانت قيمة P أقل من مستوى ألفا المحدد مسبقا (عادة .05 أو .01، هنا الأول) سنخلص إلى أن المتوسط ​​يختلف إحصائيا عن الصفر. على سبيل المثال، قيمة p للفرق بين الإناث والذكور أقل من 0.05، لذلك نستنتج أن الفرق في الوسائل يختلف إحصائيا بشكل ملحوظ عن 0. k. بيأر (T لوت t)، بيأر (تغت) - هذه هي قيم p ذيل واحد للفرضيات البديلة (متوسط ​​الفرق لوت 0) و (متوسط ​​الفرق غ 0)، على التوالي. مثل بيأر (T غ t). يتم حسابها باستخدام التوزيع t. كالمعتاد، إذا كانت قيمة P أقل من مستوى ألفا المحدد مسبقا (عادة 0.05 أو .01) سوف نستنتج أن المتوسط ​​إحصائيا أكبر بكثير أو أقل من الصفر. عينة مستقلة اختبار T بافتراض وجود فروق غير متكافئة ونحن مرة أخرى لمقارنة وسائل من نفس المتغير بين مجموعتين. في مثالنا، نقارن متوسط ​​درجات الكتابة بين مجموعة الطالبات ومجموعة الطلاب الذكور. من الناحية المثالية، يتم اختيار هذه المواضيع عشوائيا من عدد أكبر من السكان. لقد افترضنا سابقا أن الفروق بين المجموعتين هي نفسها. هنا، وسوف تسمح للتباين غير متكافئ في عينات لدينا. تفسير لقيمة p هو نفسه كما هو الحال في نوع آخر من الاختبارات t. في هذا المثال، T - الإحصائية هي -3.6564 مع 169.707 درجة من الحرية. وتكون قيمة p المقابلة ذات الذيلين 0.0003، وهي أقل من 0.05. نستنتج أن اختلاف الوسائل في الكتابة بين الذكور والإناث يختلف عن 0، مما يسمح بالاختلافات في الفروق بين المجموعات. ملخص الإحصاءات أ. المجموعة - قائمة المجموعات التي تتم مقارنة وسائلها. ب. طب التوليد. - هذا هو عدد الملاحظات الصحيحة (أي غير المفقود) من كل مجموعة وكذلك مجتمعة. ج. متوسط ​​- هذا هو متوسط ​​متغير الفائدة لكل مجموعة نقارنها. في السطر الثالث يعطى المتوسط ​​المجمع، وفي السطر الأخير يعطى الفرق بين الوسائل. د. الأمراض المنقولة جنسيا. يخطئ. - هذا هو الخطأ القياسي للمتوسط. ه. الأمراض المنقولة جنسيا. ديف. - هذا هو الانحراف المعياري للمتغير التابع لكل من المجموعات. F. 95 فترة الثقة - هذه هي الحدود الدنيا والعليا لفترة الثقة 95 للمتوسط ​​لكل مجموعة من المجموعات. اختبار الاحصائيات g. ديف - هذه هي القيمة التي نقوم باختبارها: الفرق في وسائل المجموعة الذكور والإناث. ح. t - هذا هو الإحصاء t. إنها إحصائية الاختبار التي سنستخدمها لتقييم فرضيتنا. وهي نسبة الوسط إلى الخطأ المعياري للفرق بين المجموعتين: (-4.869947 / 1.331894). أنا. ساترثويتس درجات الحرية - ساترثويتس هو وسيلة بديلة لحساب درجات الحرية التي تأخذ في الاعتبار أن الفروق يفترض أن تكون غير متكافئة. وهو نهج أكثر تحفظا من استخدام درجات الحرية التقليدية. هذه هي درجات الحرية تحت هذا الحساب. ي. بيأر (T غ t) - هذه هي القيمة p ثنائية الذيل المحسوبة باستعمال التوزيع t. هو احتمال مراقبة قيمة مطلقة أكبر من t تحت فرضية فارغة. إذا كانت قيمة P أقل من مستوى ألفا المحدد مسبقا (عادة .05 أو .01، هنا الأول) سنخلص إلى أن الفرق في الوسائل يختلف إحصائيا عن الصفر. على سبيل المثال، قيمة p للفرق بين الإناث والذكور أقل من 0.05، لذلك نستنتج أن الفرق في الوسائل يختلف إحصائيا بشكل ملحوظ عن 0. لتر. بيأر (T لوت t)، بيأر (T غ t) - هذه هي القيم p ذيل واحد للفرضيات البديلة (الفرق لوت 0) و (الفرق غ 0)، على التوالي. مثل بيأر (T غ t). يتم حسابها باستخدام التوزيع t. كالمعتاد، إذا كانت قيمة P أقل من مستوى ألفا المحدد مسبقا (عادة 0.05 أو .01) سوف نستنتج أن المتوسط ​​إحصائيا أكبر بكثير أو أقل من الصفر. محتوى هذا الموقع لا ينبغي أن يفسر على أنه تأييد لأي موقع على شبكة الإنترنت، كتاب، أو منتج معين من قبل جامعة كاليفورنيا. مرحبا بكم في معهد للبحوث الرقمية والتعليم الانحدار مع ستاتا الفصل 1 - بسيطة والانحدار متعددة الفصل الخطوط العريضة 1.0 مقدمة 1.1 تحليل الانحدار الأول 1.2 فحص البيانات 1.3 الانحدار الخطي البسيط 1.4 الانحدار المتعدد 1.5 المتغيرات التحويلية 1.6 الملخص 1.7 التقييم الذاتي 1.8 لمزيد من المعلومات يتكون هذا الكتاب من أربعة فصول تغطي مجموعة متنوعة من الموضوعات حول استخدام ستاتا للانحدار. يجب أن نؤكد على أن هذا الكتاب هو حول كواتاتا أناليسيسكوت وأنه يوضح كيف ستاتا يمكن استخدامها لتحليل الانحدار، بدلا من كتاب الذي يغطي الأساس الإحصائي للانحدار المتعدد. نحن نفترض أن لديك دورة واحدة على الأقل الإحصاءات التي تغطي تحليل الانحدار وأن لديك كتاب الانحدار التي يمكنك استخدامها كمرجع (انظر الانحدار مع صفحة ستاتا وكتاب الإحصاءات لدينا للحصول على صفحة القروض للكتب تحليل الانحدار الموصى بها). تم تصميم هذا الكتاب لتطبيق معرفتك الانحدار، والجمع بين ذلك مع تعليمات على ستاتا، لأداء وفهم وتفسير تحليلات الانحدار. سيغطي هذا الفصل الأول الموضوعات في الانحدار البسيط والمتعدد، فضلا عن المهام الداعمة التي تعد مهمة في التحضير لتحليل البيانات الخاصة بك، على سبيل المثال. والتحقق من البيانات، والحصول على دراية ملف البيانات الخاصة بك، وفحص توزيع المتغيرات الخاصة بك. سوف نقوم بتوضيح أساسيات الانحدار البسيط والمتعدد وإظهار أهمية فحص البيانات والتحقق منها والتحقق منها قبل قبول نتائج التحليل. بشكل عام، نأمل أن نبين أن نتائج تحليل الانحدار الخاص بك يمكن أن تكون مضللة دون مزيد من التحقق من البيانات الخاصة بك، والتي يمكن أن تكشف عن العلاقات التي يمكن أن يتجاهلها تحليل عارضة. في هذا الفصل، وفي الفصول اللاحقة، سوف نستخدم ملف البيانات الذي تم إنشاؤه من قبل عشوائيا أخذ العينات 400 المدارس الابتدائية من وزارة التعليم كاليفورنيا من أبي 2000 مجموعة البيانات. يحتوي ملف البيانات هذا على مقياس لأداء المدرسة الأكاديمي بالإضافة إلى سمات أخرى للمدارس الابتدائية، مثل حجم الصف، والالتحاق، والفقر، وما إلى ذلك. يمكنك الوصول إلى ملف البيانات هذا عبر الويب من داخل ستاتا باستخدام الأمر ستاتا ك ظاهر أدناه. ملاحظة: لا تكتب النقطة الرائدة في الأمر - النقطة هي اتفاقية تشير إلى أن البيان هو أمر ستاتا. بعد أن تقرأ الملف، ربما تحتاج إلى تخزين نسخة منه على جهاز الكمبيوتر الخاص بك (لذلك لا تحتاج لقراءته عبر الويب في كل مرة). يتيح القول أنك تستخدم ويندوز وتريد تخزين الملف في مجلد يسمى ج: ريجستاتا (يمكنك اختيار اسم مختلف إذا أردت). أولا، يمكنك جعل هذا المجلد داخل ستاتا باستخدام الأمر مكدير. يمكننا بعد ذلك تغيير إلى هذا الدليل باستخدام الأمر سد. ثم إذا قمت بحفظ الملف سيتم حفظها في المجلد c: ريجستاتا. يتيح حفظ الملف كما إليمابي. الآن يتم حفظ ملف البيانات كما c: regstataelemapi. dta ويمكنك إنهاء ستاتا وملف البيانات لا يزال هناك. عندما كنت ترغب في استخدام الملف في المستقبل، يمكنك فقط استخدام الأمر سد لتغيير إلى c: ريجستاتا الدليل (أو ما كنت اسمه) ثم استخدام ملف إليمابي. 1.1 تحليل الانحدار الأول يتيح الغوص في وإجراء تحليل الانحدار باستخدام المتغيرات api00. acsk3. وجبات كاملة. ويقيس هذا األداء األكادميي للمدرسة) api00 (، ومتوسط ​​حجم الصفوف من رياض األطفال حتى الصف الثالث) أسك 3 (، ونسبة الطالب الذين يتلقون وجبات مجانية) وجبات (- وهو مؤشر على الفقر، ونسبة املعلمني الذين لديهم أوراق اعتماد التدريس الكامل (الكامل). ونتوقع أن يرتبط األداء األكادميي األفضل مع انخفاض حجم الصف، وعدد أقل من الطالب الذين يتلقون وجبات مجانية، ونسبة أعلى من املعلمني الذين يحملون شهادات تفويض كاملة. أدناه، نعرض الأمر ستاتا لاختبار هذا النموذج الانحدار تليها الإخراج ستاتا. يتيح التركيز على المتنبئين الثلاثة، سواء كانت ذات دلالة إحصائية، وإذا كان الأمر كذلك، فإن اتجاه العلاقة. متوسط ​​حجم الفصول (أسك 3-b-2.68)، ليس ذو دلالة إحصائية عند مستوى 0.05 (p0.055)، ولكن فقط فقط. والمعامل سلبي مما يشير إلى أن حجم الصف الأكبر يرتبط بالأداء الأكاديمي المنخفض - وهو ما نتوقعه. بعد ذلك، يكون تأثير الوجبات (b-3.70، p.000) كبيرا ومعاملها سلبي يشير إلى أنه كلما زادت نسبة الطلاب الذين يتلقون وجبات مجانية، انخفض الأداء الأكاديمي. يرجى ملاحظة، أننا لا نقول أن وجبات مجانية تسبب انخفاض الأداء الأكاديمي. ويتعلق متغير الوجبات ارتباطا وثيقا بمستوى الدخل ويؤدي وظائفه كدليل للفقر. وبالتالي، فإن مستويات الفقر المرتفعة ترتبط بانخفاض الأداء الأكاديمي. هذه النتيجة أيضا منطقية. وأخيرا، يبدو أن النسبة المئوية للمعلمين الذين يحملون أوراق اعتماد كاملة (كاملة، b0.11، p.232) لا علاقة لها بالأداء الأكاديمي. ويبدو أن هذا يشير إلى أن نسبة المعلمين الذين يحملون أوراق اعتماد كاملة ليست عاملا مهما في التنبؤ بالأداء الأكاديمي - وكانت هذه النتيجة غير متوقعة إلى حد ما. يجب أن نتخذ هذه النتائج ونكتبها للنشر من هذه النتائج، نستنتج أن أحجام الطبقة الدنيا ترتبط بأداء أعلى، وأن عددا أقل من الطلاب الذين يتلقون وجبات مجانية يرتبط بأداء أعلى، وأن نسبة المعلمين الذين لديهم أوراق اعتماد كاملة كانت لا علاقة لها بالأداء الأكاديمي في المدارس. قبل أن نكتب هذا للنشر، ينبغي لنا أن نفعل عددا من الشيكات للتأكد من أننا يمكن أن تقف بحزم وراء هذه النتائج. نبدأ من خلال الحصول على أكثر دراية ملف البيانات، والقيام التحقق من البيانات الأولية، وتبحث عن أخطاء في البيانات. 1.2 فحص البيانات أولا، يتيح استخدام الأمر وصف لمعرفة المزيد حول ملف البيانات هذا. يمكننا التحقق من عدد الملاحظات لديه ونرى أسماء المتغيرات أنه يحتوي. للقيام بذلك، ونحن ببساطة اكتب ونحن لن تذهب إلى كل من تفاصيل هذا الناتج. لاحظ أن هناك 400 رصد و 21 متغيرات. لدينا متغيرات حول الأداء الأكاديمي في عامي 2000 و 1999 والتغير في الأداء، api00. api99 والنمو على التوالي. لدينا أيضا خصائص مختلفة من المدارس، على سبيل المثال. وحجم الصف، وتعليم أولياء الأمور، ونسبة المعلمين الذين لديهم أوراق اعتماد كاملة وحالات الطوارئ، وعدد الطلاب. لاحظ أنه عندما فعلنا تحليل الانحدار الأصلي قال أنه كان هناك 313 الملاحظات، ولكن الأمر وصف يشير إلى أن لدينا 400 الملاحظات في ملف البيانات. إذا كنت ترغب في معرفة المزيد عن ملف البيانات، هل يمكن أن قائمة كل أو بعض الملاحظات. على سبيل المثال، نورد أدناه الملاحظات الخمسة الأولى. هذا يأخذ الكثير من المساحة على الصفحة، ولكن لا يعطينا الكثير من المعلومات. يمكن أن تكون قائمة بياناتنا مفيدة جدا، ولكنها أكثر فائدة إذا كنت قائمة فقط المتغيرات كنت مهتما في. يتيح قائمة أول 10 ملاحظات للمتغيرات التي نظرنا في تحليلنا الانحدار الأول. ونحن نرى أنه من بين الملاحظات العشرة الأولى، لدينا أربعة قيم مفقودة للوجبات. ومن المرجح أن البيانات المفقودة للوجبات كان لها علاقة بحقيقة أن عدد الملاحظات في تحليلنا الانحداري الأول كان 313 وليس 400. وهناك أداة أخرى مفيدة لمعرفة المتغيرات الخاصة بك هي أمر الكودبوك. يتيح القيام بكودبوك للمتغيرات التي شملناها في تحليل الانحدار، وكذلك متغير يرند. لقد اختلطنا بعض التعليقات على هذا الناتج بين أقواس معقوفة وبخط عريض. كشف أمر الكودبوك عددا من الخصائص التي تستحق المزيد من الدراسة. يتيح استخدام الأمر تلخيص لمعرفة المزيد عن هذه المتغيرات. كما هو مبين أدناه، يكشف الأمر الموجز أيضا العدد الكبير من القيم المفقودة للوجبات (400 - 315 85) ونرى الحد الأدنى غير العادي ل acsk3 من -21. يتيح الحصول على ملخص أكثر تفصيلا ل acsk3. في ستاتا، الفاصلة بعد قائمة المتغيرات تشير إلى أن الخيارات تتبع، في هذه الحالة، الخيار هو التفاصيل. كما ترون أدناه، وخيار التفاصيل يمنحك النسب المئوية، وأكبر أربعة وأصغر القيم، ومقاييس الميل المركزي والتباين، الخ لاحظ أن تلخيص. وأوامر أخرى، يمكن اختصارها: كنا يمكن أن يكون قد كتبتها مجموع acsk3، د. يبدو كما لو أن بعض أحجام الفصول أصبحت سلبية نوعا ما، كما لو كانت علامة سلبية كتبت بشكل غير صحيح أمامها. يتيح القيام بجدولة من حجم الفصل لمعرفة ما إذا كان هذا يبدو معقولا. في الواقع، يبدو أن بعض أحجام الفصول الدراسية حصلت على بعض العلامات السلبية وضعت أمامهم. دعونا ننظر إلى المدرسة ورقم حي لهذه الملاحظات لمعرفة ما إذا كانوا يأتون من نفس المنطقة. في الواقع، يأتون جميعا من منطقة 140. دعونا ننظر في جميع الملاحظات لمنطقة 140. ويبدو أن جميع الملاحظات من المنطقة 140 لديها هذه المشكلة. عندما تجد مثل هذه المشكلة، تريد العودة إلى المصدر الأصلي للبيانات للتحقق من القيم. علينا أن نكشف أننا قمنا بتصنيع هذا الخطأ لأغراض التوضيح، وأن البيانات الفعلية لم يكن لديها مثل هذه المشكلة. دعونا نتظاهر أننا فحصنا مع حي 140 وكانت هناك مشكلة مع البيانات هناك، وضعت الواصلة عن طريق الخطأ أمام أحجام الفصول مما يجعلها سلبية. ونحن سوف تجعل مذكرة لإصلاح هذا يتيح مواصلة التحقق من البيانات لدينا. يتيح إلقاء نظرة على بعض الأساليب الرسومية لفحص البيانات. لكل متغير، فإنه من المفيد لفحصها باستخدام الرسم البياني، بوكسبلوت، و الجذعية ورقة ورقة. يمكن أن تعرض لك هذه الرسوم البيانية معلومات حول شكل المتغيرات بشكل أفضل من الإحصاءات الرقمية البسيطة. نحن نعرف بالفعل عن المشكلة مع acsk3. ولكن دعونا نرى كيف أن هذه الأساليب الرسومية قد كشفت عن مشكلة مع هذا المتغير. أولا، نعرض الرسم البياني ل acsk3. هذا يبين لنا الملاحظات حيث متوسط ​​حجم الصف سلبي. وبالمثل، فإن بكسلوت كان قد دعا هذه الملاحظات إلى اهتمامنا أيضا. يمكنك أن ترى في طريقة الملاحظات السلبية النائية في الجزء السفلي من بوكسبلوت. وأخيرا، كان من المؤكد أن مؤامرة الجذعية والأوراق قد ساعدت في تحديد هذه الملاحظات. هذه المؤامرة يظهر القيم الدقيقة للملاحظات، مشيرا إلى أن هناك ثلاثة -21s، اثنين -20s، واحد -19. نوصي بتخطيط كل هذه الرسوم البيانية للمتغيرات التي سيتم تحليلها. ونحن سوف حذف، نظرا لاعتبارات الفضاء، والتي تبين هذه الرسوم البيانية لجميع المتغيرات. ومع ذلك، في دراسة المتغيرات، ومؤامرة الجذعية والأوراق للكامل يبدو غير عادية إلى حد ما. حتى الآن، لم نر أي مشكلة مع هذا المتغير، ولكن ننظر إلى الجذعية ومؤامرة ورقة كاملة أدناه. فإنه يظهر 104 الملاحظات حيث النسبة المئوية مع الاعتماد الكامل هو أقل من واحد. هذا هو أكثر من 25 من المدارس، ويبدو غير عادي جدا. دعونا ننظر في توزيع التردد الكامل لمعرفة ما اذا كنا نستطيع فهم هذا أفضل. القيم تذهب من 0.42 إلى 1.0، ثم القفز إلى 37 وترتفع من هناك. يبدو كما لو أن بعض النسب يتم إدخالها في الواقع كنسب، على سبيل المثال. تم إدخال 0.42 بدلا من 42 أو 0.96 الذي كان يجب أن يكون 96. دعونا نرى أي منطقة (ق) هذه البيانات جاءت من. نلاحظ أن جميع الملاحظات ال 104 التي كانت كاملة أقل من أو تساوي واحدة جاءت من منطقة 401. دعونا نحصي عدد الملاحظات هناك في منطقة 401 باستخدام الأمر العد ونرى حي 401 لديه 104 الملاحظات. جميع الملاحظات من هذه المنطقة يبدو أن تسجل كنسب بدلا من النسب المئوية. Again, let us state that this is a pretend problem that we inserted into the data for illustration purposes. If this were a real life problem, we would check with the source of the data and verify the problem. We will make a note to fix this problem in the data as well. Another useful graphical technique for screening your data is a scatterplot matrix. While this is probably more relevant as a diagnostic tool searching for non-linearities and outliers in your data, it can also be a useful data screening tool, possibly revealing information in the joint distributions of your variables that would not be apparent from examining univariate distributions. Lets look at the scatterplot matrix for the variables in our regression model. This reveals the problems we have already identified, i. e. the negative class sizes and the percent full credential being entered as proportions. We have identified three problems in our data. There are numerous missing values for meals . there were negatives accidentally inserted before some of the class sizes ( acsk3 ) and over a quarter of the values for full were proportions instead of percentages. The corrected version of the data is called elemapi2 . Lets use that data file and repeat our analysis and see if the results are the same as our original analysis. First, lets repeat our original regression analysis below. Now, lets use the corrected data file and repeat the regression analysis. We see quite a difference in the results In the original analysis (above), acsk3 was nearly significant, but in the corrected analysis (below) the results show this variable to be not significant, perhaps due to the cases where class size was given a negative value. Likewise, the percentage of teachers with full credentials was not significant in the original analysis, but is significant in the corrected analysis, perhaps due to the cases where the value was given as the proportion with full credentials instead of the percent. Also, note that the corrected analysis is based on 398 observations instead of 313 observations, due to getting the complete data for the meals variable which had lots of missing values. From this point forward, we will use the corrected, elemapi2 . data file. You might want to save this on your computer so you can use it in future analyses. So far we have covered some topics in data checking/verification, but we have not really discussed regression analysis itself. Lets now talk more about performing regression analysis in Stata. 1.3 Simple Linear Regression Lets begin by showing some examples of simple linear regression using Stata. In this type of regression, we have only one predictor variable. This variable may be continuous, meaning that it may assume all values within a range, for example, age or height, or it may be dichotomous, meaning that the variable may assume only one of two values, for example, 0 or 1. The use of categorical variables with more than two levels will be covered in Chapter 3. There is only one response or dependent variable, and it is continuous. In Stata, the dependent variable is listed immediately after the regress command followed by one or more predictor variables. Lets examine the relationship between the size of school and academic performance to see if the size of the school is related to academic performance. For this example, api00 is the dependent variable and enroll is the predictor. Lets review this output a bit more carefully. First, we see that the F-test is statistically significant, which means that the model is statistically significant. The R-squared of .1012 means that approximately 10 of the variance of api00 is accounted for by the model, in this case, enroll . The t-test for enroll equals -6.70, and is statistically significant, meaning that the regression coefficient for enroll is significantly different from zero. Note that (-6.70) 2 44.89, which is the same as the F-statistic (with some rounding error). The coefficient for enroll is -.1998674, or approximately -.2, meaning that for a one unit increase in enroll . we would expect a .2-unit decrease in api00 . In other words, a school with 1100 students would be expected to have an api score 20 units lower than a school with 1000 students. The constant is 744.2514, and this is the predicted value when enroll equals zero. In most cases, the constant is not very interesting. We have prepared an annotated output which shows the output from this regression along with an explanation of each of the items in it. In addition to getting the regression table, it can be useful to see a scatterplot of the predicted and outcome variables with the regression line plotted. After you run a regression, you can create a variable that contains the predicted values using the predict command. You can get these values at any point after you run a regress command, but remember that once you run a new regression, the predicted values will be based on the most recent regression. To create predicted values you just type predict and the name of a new variable Stata will give you the fitted values. For this example, our new variable name will be fv . so we will type If we use the list command, we see that a fitted value has been generated for each observation. Below we can show a scatterplot of the outcome variable, api00 and the predictor, enroll . We can combine scatter with lfit to show a scatterplot with fitted values. As you see, some of the points appear to be outliers. If you use the mlabel(snum) option on the scatter command, you can see the school number for each point. This allows us to see, for example, that one of the outliers is school 2910. As we saw earlier, the predict command can be used to generate predicted (fitted) values after running regress . You can also obtain residuals by using the predict command followed by a variable name, in this case e . with the residual option. This command can be shortened to predict e, resid or even predict e, r . The table below shows some of the other values can that be created with the predict option. 1.4 Multiple Regression Now, lets look at an example of multiple regression, in which we have one outcome (dependent) variable and multiple predictors. Before we begin with our next example, we need to make a decision regarding the variables that we have created, because we will be creating similar variables with our multiple regression, and we dont want to get the variables confused. For example, in the simple regression we created a variable fv for our predicted (fitted) values and e for the residuals. If we want to create predicted values for our next example we could call the predicted value something else, e. g. fvmr . but this could start getting confusing. We could drop the variables we have created, using drop fv e . Instead, lets clear out the data in memory and use the elemapi2 data file again. When we start new examples in future chapters, we will clear out the existing data file and use the file again to start fresh. For this multiple regression example, we will regress the dependent variable, api00 . on all of the predictor variables in the data set. Lets examine the output from this regression analysis. As with the simple regression, we look to the p-value of the F-test to see if the overall model is significant. With a p-value of zero to four decimal places, the model is statistically significant. The R-squared is 0.8446, meaning that approximately 84 of the variability of api00 is accounted for by the variables in the model. In this case, the adjusted R-squared indicates that about 84 of the variability of api00 is accounted for by the model, even after taking into account the number of predictor variables in the model. The coefficients for each of the variables indicates the amount of change one could expect in api00 given a one-unit change in the value of that variable, given that all other variables in the model are held constant. For example, consider the variable ell . We would expect a decrease of 0.86 in the api00 score for every one unit increase in ell . assuming that all other variables in the model are held constant. The interpretation of much of the output from the multiple regression is the same as it was for the simple regression. We have prepared an annotated output that more thoroughly explains the output of this multiple regression analysis. You may be wondering what a 0.86 change in ell really means, and how you might compare the strength of that coefficient to the coefficient for another variable, say meals . To address this problem, we can add an option to the regress command called beta . which will give us the standardized regression coefficients. The beta coefficients are used by some researchers to compare the relative strength of the various predictors within the model. Because the beta coefficients are all measured in standard deviations, instead of the units of the variables, they can be compared to one another. In other words, the beta coefficients are the coefficients that you would obtain if the outcome and predictor variables were all transformed standard scores, also called z-scores, before running the regression. Because the coefficients in the Beta column are all in the same standardized units you can compare these coefficients to assess the relative strength of each of the predictors. In this example, meals has the largest Beta coefficient, -0.66 (in absolute value), and acsk3 has the smallest Beta, 0.013. Thus, a one standard deviation increase in meals leads to a 0.66 standard deviation decrease in predicted api00 . with the other variables held constant. And, a one standard deviation increase in acsk3 . in turn, leads to a 0.013 standard deviation increase in predicted api00 with the other variables in the model held constant. In interpreting this output, remember that the difference between the numbers listed in the Coef. column and the Beta column is in the units of measurement. For example, to describe the raw coefficient for ell you would say quotA one-unit decrease in ell would yield a .86-unit increase in the predicted api00.quot However, for the standardized coefficient (Beta) you would say, quotA one standard deviation decrease in ell would yield a .15 standard deviation increase in the predicted api00.quot The listcoef command gives more extensive output regarding standardized coefficients. It is not part of Stata, but you can download it over the internet like this. and then follow the instructions (see also How can I use the findit command to search for programs and get additional help for more information about using findit ). Now that we have downloaded listcoef . we can run it like this. Let us compare the regress output with the listcoef output. You will notice that the values listed in the Coef. t, and Pgtt values are the same in the two outputs. The values listed in the Beta column of the regress output are the same as the values in the bStadXY column of listcoef . The bStdX column gives the unit change in Y expected with a one standard deviation change in X. The bStdY column gives the standard deviation change in Y expected with a one unit change in X. The SDofX column gives that standard deviation of each predictor variable in the model. For example, the bStdX for ell is -21.3, meaning that a one standard deviation increase in ell would lead to an expected 21.3 unit decrease in api00 . The bStdY value for ell of -0.0060 means that for a one unit, one percent, increase in english language learners, we would expect a 0.006 standard deviation decrease in api00 . Because the bStdX values are in standard units for the predictor variables, you can use these coefficients to compare the relative strength of the predictors like you would compare Beta coefficients. The difference is BStdX coefficients are interpreted as changes in the units of the outcome variable instead of in standardized units of the outcome variable. For example, the BStdX for meals versus ell is -94 versus -21, or about 4 times as large, the same ratio as the ratio of the Beta coefficients. We have created an annotated output that more thoroughly explains the output from listcoef . So far, we have concerned ourselves with testing a single variable at a time, for example looking at the coefficient for ell and determining if that is significant. We can also test sets of variables, using the test command, to see if the set of variables are significant. First, lets start by testing a single variable, ell . using the test command. If you compare this output with the output from the last regression you can see that the result of the F-test, 16.67, is the same as the square of the result of the t-test in the regression (-4.0832 16.67). Note that you could get the same results if you typed the following since Stata defaults to comparing the term(s) listed to 0. Perhaps a more interesting test would be to see if the contribution of class size is significant. Since the information regarding class size is contained in two variables, acsk3 and acs46 . we include both of these with the test command. The significant F-test, 3.95, means that the collective contribution of these two variables is significant. One way to think of this, is that there is a significant difference between a model with acsk3 and acs46 as compared to a model without them, i. e. there is a significant difference between the quotfullquot model and the quotreducedquot models. Finally, as part of doing a multiple regression analysis you might be interested in seeing the correlations among the variables in the regression model. You can do this with the correlate command as shown below. If we look at the correlations with api00 . we see meals and ell have the two strongest correlations with api00 . These correlations are negative, meaning that as the value of one variable goes down, the value of the other variable tends to go up. Knowing that these variables are strongly associated with api00 . we might predict that they would be statistically significant predictor variables in the regression model. We can also use the pwcorr command to do pairwise correlations. The most important difference between correlate and pwcorr is the way in which missing data is handled. With correlate . an observation or case is dropped if any variable has a missing value, in other words, correlate uses listwise. also called casewise, deletion. pwcorr uses pairwise deletion, meaning that the observation is dropped only if there is a missing value for the pair of variables being correlated. Two options that you can use with pwcorr . but not with correlate . are the sig option, which will give the significance levels for the correlations and the obs option, which will give the number of observations used in the correlation. Such an option is not necessary with corr as Stata lists the number of observations at the top of the output. 1.5 Transforming Variables Earlier we focused on screening your data for potential errors. In the next chapter, we will focus on regression diagnostics to verify whether your data meet the assumptions of linear regression. Here, we will focus on the issue of normality. Some researchers believe that linear regression requires that the outcome (dependent) and predictor variables be normally distributed. We need to clarify this issue. In actuality, it is the residuals that need to be normally distributed. In fact, the residuals need to be normal only for the t-tests to be valid. The estimation of the regression coefficients do not require normally distributed residuals. As we are interested in having valid t-tests, we will investigate issues concerning normality. A common cause of non-normally distributed residuals is non-normally distributed outcome and/or predictor variables. So, let us explore the distribution of our variables and how we might transform them to a more normal shape. Lets start by making a histogram of the variable enroll . which we looked at earlier in the simple regression. We can use the normal option to superimpose a normal curve on this graph and the bin(20 ) option to use 20 bins. The distribution looks skewed to the right. You may also want to modify labels of the axes. For example, we use the xlabel() option for labeling the x-axis below, labeling it from 0 to 1600 incrementing by 100. Histograms are sensitive to the number of bins or columns that are used in the display. An alternative to histograms is the kernel density plot, which approximates the probability density of the variable. Kernel density plots have the advantage of being smooth and of being independent of the choice of origin, unlike histograms. Stata implements kernel density plots with the kdensity command. Not surprisingly, the kdensity plot also indicates that the variable enroll does not look normal. Now lets make a boxplot for enroll . using graph box command. Note the dots at the top of the boxplot which indicate possible outliers, that is, these data points are more than 1.5(interquartile range) above the 75th percentile. This boxplot also confirms that enroll is skewed to the right. There are three other types of graphs that are often used to examine the distribution of variables symmetry plots, normal quantile plots and normal probability plots. A symmetry plot graphs the distance above the median for the i-th value against the distance below the median for the i-th value. A variable that is symmetric would have points that lie on the diagonal line. As we would expect, this distribution is not symmetric. A normal quantile plot graphs the quantiles of a variable against the quantiles of a normal (Gaussian) distribution. qnorm is sensitive to non-normality near the tails, and indeed we see considerable deviations from normal, the diagonal line, in the tails. This plot is typical of variables that are strongly skewed to the right. Finally, the normal probability plot is also useful for examining the distribution of variables. pnorm is sensitive to deviations from normality nearer to the center of the distribution. Again, we see indications of non-normality in enroll . Having concluded that enroll is not normally distributed, how should we address this problem First, we may try entering the variable as-is into the regression, but if we see problems, which we likely would, then we may try to transform enroll to make it more normally distributed. Potential transformations include taking the log, the square root or raising the variable to a power. Selecting the appropriate transformation is somewhat of an art. Stata includes the ladder and gladder commands to help in the process. Ladder reports numeric results and gladder produces a graphic display. Lets start with ladder and look for the transformation with the smallest chi-square. The log transform has the smallest chi-square. Lets verify these results graphically using gladder . This also indicates that the log transformation would help to make enroll more normally distributed. Lets use the generate command with the log function to create the variable lenroll which will be the log of enroll. Note that log in Stata will give you the natural log, not log base 10. To get log base 10, type log10(var) . Now lets graph our new variable and see if we have normalized it. We can see that lenroll looks quite normal. We would then use the symplot . qnorm and pnorm commands to help us assess whether lenroll seems normal, as well as seeing how lenroll impacts the residuals, which is really the important consideration. In this lecture we have discussed the basics of how to perform simple and multiple regressions, the basics of interpreting output, as well as some related commands. We examined some tools and techniques for screening for bad data and the consequences such data can have on your results. Finally, we touched on the assumptions of linear regression and illustrated how you can check the normality of your variables and how you can transform your variables to achieve normality. The next chapter will pick up where this chapter has left off, going into a more thorough discussion of the assumptions of linear regression and how you can use Stata to assess these assumptions for your data. In particular, the next lecture will address the following issues. Checking for points that exert undue influence on the coefficients Checking for constant error variance (homoscedasticity) Checking for linear relationships Checking model specification Checking for multicollinearity Checking normality of residuals See the Stata Topics: Regression page for more information and resources on simple and multiple regression in Stata. 1.7 Self Assessment Make five graphs of api99 . histogram, kdensity plot, boxplot, symmetry plot and normal quantile plot. What is the correlation between api99 and meals Regress api99 on meals . What does the output tell you Create and list the fitted (predicted) values. Graph meals and api99 with and without the regression line. Look at the correlations among the variables api99 meals ell avged using the corr and pwcorr commands. Explain how these commands are different. Make a scatterplot matrix for these variables and relate the correlation results to the scatterplot matrix. Perform a regression predicting api99 from meals and ell . Interpret the output. Click here for our answers to these self assessment questions. 1.8 For More Information The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.

No comments:

Post a Comment