2016-04-04 20:08 GMT-03:00 Allin Cottrell <cottrell(a)wfu.edu>:
On Mon, 4 Apr 2016, Henrique Andrade wrote:
Dear Gretl Team,
>
> Is it possible to allow the accessors $test and $pvalue after the
> correlation (corr) command?
>
> It is important to me because I'm developing some programs that tries to
> automatically choose regressors.
>
How about this?
<hansl>
function matrix hanslcorr (series x, series y)
r = corr(x, y)
n = sum(ok(x) && ok(y))
test = r * sqrt((n-2) / (1 - r*r))
pval = pvalue(t, n-2, test)
return {r, test, pval}
end function
# example usage
open data4-10
corr CATHOL ENROLL
m = hanslcorr(CATHOL, ENROLL)
print m
</hansl>
Dear Allin,
Thanks a lot for your help. It solved my problem, but I think this is a
situation where we should try to make accessors as universal as possible. I
see no reason to not provide $test and $pvalue in this case ;-)
One more comment... I think "n = sum(ok(x) && ok(y))" is only correct
when
x and y have the same size. Am I right?
Best,
Henrique Andrade