全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1238 0
2015-04-05
將兩個檔案依date這個變數joinby,然後希望個別regress取得residuals。

----------------------以下為我的code-----------------------------

use"C:\Users\Survivor\Desktop\上市週報酬率.dta", clear

joinby  date using"C:\Users\Survivor\Desktop\大盤週報酬率.dta"

statsby _b, by(code date) saving(test.dta, replace): reg r ir mr            (regress)

merge m:1 code date using test.dta            

gen yhat = ir*_b_ir + mr*_b_mr +  _b_cons        (yhat)

gen res2 = r - ir*_b_ir -mr*_b_mr - _b_cons         (residual)

------------------------------------------------------------------------------------


[size=13.3333330154419px](以下是結果)

[size=13.3333330154419px]

[size=13.3333330154419px] merge m:1 code date using 上市週報酬率.dta            

[size=13.3333330154419px]

[size=13.3333330154419px]    Result                           # of obs.

[size=13.3333330154419px]    -----------------------------------------

[size=13.3333330154419px]    not matched                             0

[size=13.3333330154419px]    matched                            65,535  (_merge==3)

[size=13.3333330154419px]    -----------------------------------------

[size=13.3333330154419px]

[size=13.3333330154419px]. gen yhat = ir*_b_ir + mr*_b_mr +  _b_cons        

[size=13.3333330154419px](65535 missing values generated)

[size=13.3333330154419px]

[size=13.3333330154419px]. gen res2 = r - ir*_b_ir - mr*_b_mr - _b_cons        

[size=13.3333330154419px](65535 missing values generated)

[size=13.3333330154419px]

[size=13.3333330154419px]end of do-file

[size=13.3333330154419px]

joinby之前沒問題直到regress時出現65535個 missing values,請問為什麼我的regress會失敗呢?





附件列表

大盤週報酬率.dta

大小:17.08 KB

 马上下载

market return

上市週報酬率.dta

大小:2.5 MB

 马上下载

return

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群