Page 1 of 1

Calculating the probability via @tdist

Posted: Tue Jun 11, 2013 2:36 am
by jeffreylankhaar
Good day,

I'm trying to calculate the p-value through the @tdist function and extract in a matrix which I copy to excel. I already did the programming of the coefficients, t-stats and r-squared, but facing issues with the calculations of the p-value and putting them automated in the summarizing matrix. Below you will find my coding, can you please have a look were is going wrong?

'Create X variable
%bebci= "x"

'Create X** variable
rename bebci* x*

'Create matrix to store coefseu
matrix(2,5) coefseu

'Create vector to store r-square
rowvector(5) r2eu

'Create matrix to store t-stats
matrix(2,5) tstatseu

'Create matrix to store p-value
matrix(2,5) pvaleu

'Create matrix to summarize
matrix(7,5) Sum1eu

''counter of how many equations we have run
!columncounter=1

'run pairwise regressions between Y(EUUSD) and X
for !i=1 to 5
equation eqeu{!i}.ls xeu{!i} c x
r2eu(!columncounter)=eqeu{!i}.@r2
!columncounter = !columncounter+1
' pval{!i} = @tdist(eqeu{!i}.@tstat, @regobs -@ncoef)

'store p-value into matrix
colplace(pvaleu,eqeu{!i}.@tdist(eqeu{!i}.@tstat, eqeu{!i}.@regobs -eqeu{!i}.@ncoef),!i)

'store tstats into matrix
colplace(tstatseu,eqeu{!i}.@tstats,!i)

'store coefficients into matrix
colplace(coefseu,eqeu{!i}.@coefs,!i)

'delete equations 1 to 5
delete eqeu{!i}

'Combine matrices
matplace(Sum1eu,coefseu,1,1)

'Combine matrices
matplace(Sum1eu,tstatseu,3,1)

'Combine matrices
matplace(Sum1eu,pvaleu,5,1)

'Combine matrices
matplace(Sum1eu,r2eu,7,1)
next

Hope to hear from you guys soon.

Thank you in advance!!