forked from Ronggui/SOCI620004
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Multiple regression.do
82 lines (73 loc) · 1.59 KB
/
Multiple regression.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use Prestige
** slide 4-6
reg prestige income education
** talk about: ereturn list
reg income education
predict resid, residual
reg prestige resid
** slide 11
reg prestige income education
predict fitted
cor prestige fitted
disp `r(rho)'^2
** slide 9-10
** SST
local ybar = `r(mean)'
gen yy = (prestige - `ybar')^2
sum yy, detail
return list
local sst = `r(sum)'
display `sst'
** SSR
predict r, residual
gen r2 = r^2
sum r2, detail
local ssr = `r(sum)'
display `ssr'
** SSE
predict yhat
gen yyy = yhat - `ybar'
gen yyy2 = yyy^2
sum yyy2, detail
local sse = `r(sum)'
display `sse'
**
display `sst'
display `sse' + `ssr'
display 1 - `ssr'/`sst'
** slide 12
reg prestige income education
local sigma = e(rmse)
reg prestige
local sigmanull = e(rmse)
display 1 - `sigma'^2/`sigmanull'^2
** slide 14
reg prestige income education
display `e(rank)'
gen newX = 10 + 0.7 * income
** what happens?
reg prestige income education newX
** slide 16-19
reg prestige income education
cor income education
** both are positive, omitted education and positive bias
** coef of income will become larger
reg prestige income
** calc sigma^2
reg prestige income education
local sigmahat2 =`ssr'/(`e(N)' - `e(rank)')
** sigma hat or Root MSE
display sqrt(`sigmahat2')
** slide 24
qui: reg income education
local den = (`e(rss)' + `e(mss)')*(1-`e(r2)')
display sqrt( `sigmahat2' / `den' )
** std. err of income, please check
reg prestige income education
** Statistical tests
use Prestige.dta
reg prestige education income women
test income education
test income-education=0
test income+education=0
test income women education