Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: saving test results

From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: saving test results
Date   Fri, 8 Jul 2005 09:55:10 -0400

Christoph wrote

Scott and Nick, thank you very much for your help!
I am now using the following command, to save the test result in a variable:
gen test=r(t)

A really bad idea. Say that you have 150 000 observations. Do you really want 150 000 copies of that particular number? Save it as a local macro, or a scalar, or as an element of a matrix. It is often very useful to use matrices to store results from a whole set of tests: e.g.

mat testres = J(5,3,0)
mat list testres
qui {
forvalues i = 1/5 {
reg price if rep78==`i'
test _cons = 8000
mat testres[`i',1] = r(F)
mat testres[`i',2] = r(df_r)
mat testres[`i',3] = r(p)
local rn "`rn' rep78_`i'"
mat colnames testres = F den_df p_val
mat rownames testres = `rn'
mat list testres

There are probably more elegant ways to achieve this in Stata v9, but this will work in Stata v8.
If you are using ttest rather than test, just change the r() values accordingly.

Kit Baum, Boston College Economics

* For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index