Intro to Statistical Learning (2nd Ed), Solution to Problem 3.11A (Py) | Exploring t-stat

preview_player
Показать описание
In this problem we will investigate the t-statistic for the null hypothesis H0:β=0 in simple linear regression without an intercept. To begin, we generate a predictor x and a response y as follows.

import numpy as np

(a) Perform a simple linear regression of y onto x, without an intercept. Report the coefficient estimate β^, the standard error of this coefficient estimate, and the t-statistic and p-value associated with the null hypothesis H0:β=0. Comment on these results.

(b) Now perform a simple linear regression of x onto y without an intercept, and report the coefficient estimate, its standard error, and the corresponding t-statistic and p-values associated with the null hypothesis H0:β=0. Comment on these results.

(c) What is the relationship between the results obtained in (a) and (b)?

(d) For the regression of Y onto X without an intercept, the t-statistic for H0:β=0 takes the form β^/SE(β^), where β^ is given by (3.38),

β^=∑ni=1xiyi∑ni=1x2i

and where

SE(β^)=∑ni=1(yi−xiβ^)2(n−1)∑ni=1x2i−−−−−−−−−√

(These formulas are slightly different from those given in Sections 3.1.1 and 3.1.2, since here we are performing regression without an intercept.) Show algebraically, and confirm numerically in R, that the t-statistic can be written as

(n−1√)∑ni=1xiyi(∑ni=1x2i)(∑ni=1y2i)−(∑ni=1xiyi)2√

(e) Using the results from (d), argue that the t-statistic for the regression of 'y' onto 'x' is the same as the t-statistic for the regression of 'x' onto 'y'.

(f) In Python, show that when regression is performed with an intercept, the t-statistic for H0:β1=0 is the same for the regression of y onto x as it is for the regression of x onto y.

Рекомендации по теме
Комментарии
Автор

I was looking for some up-to-date solutions in Python to help me check my output. Thank you very much!

JonesDawg
welcome to shbcf.ru