Thank you Marcin.
I feel really ashamed. I didn't realize what I was doing when I changed that part.
Best, Juan Pablo.
Date: Thu, 6 Dec 2012 06:46:19 +0100
From: marcin(a)wrzosy.nsb.pl
To: gretl-devel(a)lists.wfu.edu
Subject: Re: [Gretl-devel] Function error: variable 0 is duplicated in the list of
instructions
Hi,
IMHO xlist includes 'const'.
Regards,
Marcin
W dniu 06.12.2012 06:37, juan de botton pisze:
Hi everyone,
Fist of all I want to say thanks to Sven and Ignacio
because his suggestions about inserting a statistical table in
a function have been very helpful.
Now, I have some problems with my function script and I
don't really understand what is actually the problem.
When I trie to run my sample script, I get the following
error message:
"the variable 0 is duplicated in the list of
instructions"
Here is my function script. I ommit A and B matrices
because are quite large, but everything else is there:
function bundle DeWallis_test (series
y "Explained variable",
list
xlist "Explanatory variables (Note: constant term is
included by default)",
bool
dummy[0] "Are dummy variables included in the regression?
(remember that constant is included by default)")
T = $nobs
list xlist = const xlist
if T<16
funcerr "Insufficient
observations"
endif
ols y xlist --quiet
scalar SCE = $ess
matrix uhat = $uhat
scalar ut = 0
loop i = 5..T --quiet
scalar ui = (uhat[i,1] -
uhat[i-4,1])^2
ut = ut + ui
endloop
scalar DeWallis_stat = ut/SCE
#A : DeWallis_stat_table_nodummy
#B : DeWallis_stat_table_dummy
#De Wallis test
if dummy
matrix xlist = xlist
scalar k = cols(xlist) - 4
if k>5
funcerr "The number of
regressors has to be less or equal to 5 (withot considering
the constant term nor the dummy variables)"
endif
if k<1
funcerr "Insufficient number of
regressors. Please make sure you input at least one
independent variable and the three dummy")
endif
scalar row = T/4 -3
scalar row = floor(row)
scalar col_left = 2*k
scalar col_right = 2*k +1
if DeWallis_stat < B[row ,
col_left]
string DeWallis_test_result =
"We reject H0, there is evidence of negative
autocorrelation"
else
if DeWallis_stat > B[row,
col_right]
string DeWallis_test_result =
"We reject H0, there is evidence of positive
autocorrelation"
else
string DeWallis_test_result =
"The test does not provide enough evidence to suggest
autocorrelation"
endif
endif
else
matrix xlist = xlist
scalar k = cols(xlist) - 1
if k>5
funcerr "The number of
regressors has to be less or equal to 5 (withot considering
the constant term)"
endif
if k<1
funcerr "Insufficient number of
regressors. Please make sure you input at least one
independent variable")
endif
scalar row = T/4 -3
scalar row = floor(row)
scalar col_left = 2*k
scalar col_right = 2*k +1
if DeWallis_stat < A[row ,
col_left]
string DeWallis_test_result =
"We reject H0, there is evidence of negative
autocorrelation"
else
if DeWallis_stat > A[row,
col_right]
string DeWallis_test_result =
"We reject H0, there is evidence of positive
autocorrelation"
else
string DeWallis_test_result =
"The test does not provide enough evidence to suggest
autocorrelation"
endif
endif
endif
DeWallis_test["De Wallis
statisitic"] = DeWallis_stat
DeWallis_test["Test result"] =
DeWallis_test_result
print
"--------------------------------------------\n"
printf "The value of the De Wallis
statistic is: %g\n", DeWallis_stat
print
"--------------------------------------------\n"
return DeWallis_test
end function
#Sample script
include DeWallis_test.gfn
open
'C:\Users\Owner\Documents\MATLAB\BasesDeDatos\np.xlsx'
--quiet
series y = v1
list xlist = const v2
bundle results = DeWallis_test(y,xlist,0)
print results
Thanks in advance for your help.
Sincerely, Juan Pablo de Botton Falcón.
_______________________________________________
Gretl-devel mailing list
Gretl-devel(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel
_______________________________________________
Gretl-devel mailing list
Gretl-devel(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel