[Limdep Nlogit List] Weighted mean and standard deviation

Yen, Steven T syen at utk.edu
Thu May 21 13:32:13 EST 2009


Uh-huh! Thank you very much!
 
________________________________

From: limdep-bounces at limdep.itls.usyd.edu.au on behalf of William Greene
Sent: Wed 5/20/2009 10:42 PM
To: Limdep and Nlogit Mailing List
Subject: Re: [Limdep Nlogit List] Weighted mean and standard deviation

Steven. The way it would be done internally is as follows:
Suppose x is the variable in question and w is the weighting variable.
CALC ; A = n / sum(w) $
Create ; xw = w*x*A $
now, xbr and sdv applied to xw produce the weighted mean and
standard deviation.
/Bill

----- Original Message -----
From: "Steven Yen" <syen at utk.edu>
To: "Limdep and Nlogit Mailing List" <limdep at limdep.itls.usyd.edu.au>
Sent: Wednesday, May 20, 2009 5:31:50 PM GMT -05:00 Columbia
Subject: [Limdep Nlogit List] Weighted mean and standard deviation

Dear fellow Limdepers

Is there a way to calculate and save the weighted sample means and
standard deviation with the "calc" command, the way "xbr" and "sdv"
do for the unweighted mean and standard deviation? Or, is  there a
way to do this with the matrix command?

In other words, can somebody help me finish the fourth line of code
below? I need the weighted mean/sd in further calculation. Thank you.

dstat   ;rhs=m12 $
calc    ;list ;xb=xbr(m12) ;sd=sdv(m12) $

dstat   ;rhs=m12 ;wts=mweight $
?calc   ;list ;xbw=??? ;sdw=??? $


Output from the first three lines follow:

--> dstat   ;rhs=m12 $
Descriptive Statistics
All results based on nonmissing observations.
===============================================================================
Variable     Mean       Std.Dev.     Minimum      Maximum        Cases Missing
===============================================================================
------------------------------------------------------------------------------
All observations in current sample
------------------------------------------------------------------------------
M12     |  .304133E-01  .825750     -.967448      42.1079         3611       0
--> calc    ;list ;xb=xbr(m12) ;sd=sdv(m12) $
+------------------------------------+
| Listed Calculator Results          |
+------------------------------------+
  XB      =       .030413
  SD      =       .825750
Calculator: Computed   2 scalar results
--> dstat   ;rhs=m12 ;wts=mweight $
Descriptive Statistics
All results based on nonmissing observations.
===============================================================================
Variable     Mean       Std.Dev.     Minimum      Maximum        Cases Missing
===============================================================================
------------------------------------------------------------------------------
All observations in current sample
------------------------------------------------------------------------------
M12     |  .242638E-01  .747578     -.967448      42.1079         3611       0




Steven T. Yen
http://web.utk.edu/~syen/
Check out our postdoc opening at:
http://web.utk.edu/~syen/postdoc.html
_______________________________________________
Limdep site list
Limdep at limdep.itls.usyd.edu.au
http://limdep.itls.usyd.edu.au <http://limdep.itls.usyd.edu.au/> 
_______________________________________________
Limdep site list
Limdep at limdep.itls.usyd.edu.au
http://limdep.itls.usyd.edu.au <http://limdep.itls.usyd.edu.au/> 



More information about the Limdep mailing list