Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65082

store p-values

$
0
0
Dear Statalist-Users,

I would like to store the p-values of a looped regress-code. This is the code I currently have:

Code:
//creating the matrix
unab x : ER_1_Day- ER_12_Month
local l : word count `x'

matrix p = J(`l',10,.)
matrix rownames p = `x'
matrix colnames p = 1 2 3 4 5 6 7 8 9 10

//regressing
local j = 1
foreach var of local x {
foreach y of varlist NegWords{
    quietly regress `var' `y' Market Price Mom if Industry_ID==1
    matrix p[`j++',1] = 2*ttail(e(df_r), abs(_b[`y']/_se[`y']))
}
}
This code stores the p-Values for Industry 1 in column 2 of the matrix. Now I would like to have the p-values for Industry 2 in column 3, for Industry 3 in column 4, ....
I tried the following, but there is a conformability error. I think the codeline for the matrix is wrong... How can I address the correct column of the matrix? And how can I address the p-values of each industry correctly?

Code:
local j = 1
foreach var of local x {
foreach y of varlist NegWords{
forvalues i = 1/10 {
    quietly regress `var' `y' Market Price Mom if Industry_ID==`i'
    matrix p[`j++',`i'] = 2*ttail(e(df_r), abs(_b[`y']/_se[`y']))
}
}
}

Any help is highly appreciated!

Viewing all articles
Browse latest Browse all 65082

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>