# Re: st: store means as a new variable

 From Maarten buis <[email protected]> To [email protected] Subject Re: st: store means as a new variable Date Sat, 23 Feb 2008 14:08:33 +0000 (GMT)

```--- Wencke <[email protected]> wrote:
> how can I store estimates of mean values as well as their standard
> deviation as new variables in my dataset?
>
> This is the command for the mean-values, I am using:
> mean maxgrip, over(gender ph013_)

Given your choice of words I am assuming you do not want the standard
deviation of maxgrip but the standard error of the mean. The standard
deviation is a measure of the degree in which observations differ to
one another with respect to maxgrip, the standard error of the mean is
a measure of how precise the estimate of the mean is.

There are various ways of doing what you ask. Which one is best depends
on what you want to do with it. First notice that -mean- is an
estimation command so all tricks discussed in (Newson 2003) and (Buis
2007) are available to you. You can also create a variable containing
also contains a function for creating a variable containing the

The example below illustrates all three methods.

*------------- begin example ---------------
set more off
sysuse auto, clear
sort rep78
mean mpg, over(rep78)

// discussed in (Buis 2007)
mata:
b = st_matrix("e(b)")'
V = st_matrix("e(V)")
se = diagonal(cholesky(diag(V)))
b, se
end

by rep78: egen m = mean(mpg)
by rep78: egen se = semean(mpg)
list rep78 m se

// discussed in (Newson 2003)
parmest, norestore
list
*---------- end example ---------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

Buis, Maarten L. (2007), "Stata tip 54: Where did my p-values go?", The
Stata Journal, 7(4), pp.584-586.
http://home.fsw.vu.nl/m.buis/wp/pvalue.html )

Newson R. (2003) "Confidence intervals and p-values for delivery to the
end user." The Stata Journal, 3(3), pp. 245-269.
http://www.imperial.ac.uk/nhli/r.newson/papers.htm )

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.