Let's get a concrete example:
<hansl>
set verbose off
open denmark.gdt -q
LRM[1] = NA
mean_LRM = mean(LRM)
sd_LRM = sd(LRM)
print mean_LRM sd_LRM
summary LRM --simple
list L = LRM LRY
summary L --simple
</hansl>
yields
<output>
mean_LRM = 11.756663
sd_LRM = 0.15285752
Summary statistics, using the observations 1974:1 - 1987:3
for the variable 'LRM' (54 valid observations)
Mean 11.757
Minimum 11.582
Maximum 12.075
Standard deviation 0.15286
Missing obs. 1
Mean Median S.D. Min Max
LRM 11.76 11.71 0.1529 11.58 12.08
LRY 5.952 5.940 0.07276 5.787 6.099
</output>
Artur
Am 05.06.2017 um 11:28 schrieb Filipe Rodrigues da Costa:
Hi Sven,
I verified this and in fact, missing values aren't ignored. If you have
just a single missing value in one of the series that is part of the
list, the resulting mean or sd is NA. So, for example, if you have three
series: A, B, and C, with values 100, 200 and NA for 1960, the resulting
mean for a list with A, B and C is NA, and not 150, as desirable.
Here is the transcript from the function reference:
"If x is a list, returns a series y such that yt is the sample standard
deviation of the values of the variables in the list at observation t,
or NA if there are any missing values at t. "
It seems that the guide and function reference are not in accordance.
--
*Filipe Rodrigues da Costa*
Send me an email to: filipe(a)pobox.io
Reach me through *Telegram* at:
https://t.me/rodriguesdacosta
On Sat, 3 Jun 2017, at 17:53, Sven Schreiber wrote:
> Am 03.06.2017 um 17:56 schrieb Filipe Rodrigues da Costa:
>
>> I'm trying to use the functions sd(x), and mean(x) in a list instead of
>> a series. From what I understood, these functions ignore NAs when used
>> in a series, but when used in a list they return NA if any missing value.
>
> Hi,
> have you actually verified that this is really what's happening? In the
> guide I see the following explanation:
>
> "The functions max, min, mean, sd, sum and var behave “horizontally”
> rather than “vertically” when their argument is a list. For instance,
> the following commands
> list Xlist = x1 x2 x3
> series m = mean(Xlist)
> produce a series m whose i-th element is the average of x 1,i ,x 2,i and
> x 3,i ; missing values, if any, are implicitly discarded."
>
> To me that sounds as if it works as you intend.
>
> cheers,
> sven
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-users
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users