Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

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
the mean using -egen-. The -egenmore- package, downloadable from -ssc-
also contains a function for creating a variable containing the
standard error. To download -egenmore- type -ssc instal egenmore-.

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.
(A pre-publication draft can be downloaded from
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. 
(A pre-publication draft can be downloaded from
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

visiting address:
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.
http://uk.answers.yahoo.com/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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