Kernel regression - kreg

Dear Friends/Colleagues

I am quite new to this.

I have been trying to implement kernel regression in Gauss using the kreg function/program. I have compiled the following codes based on the simulation codes by Wang and Phillips (2009). The code appears to run OK but I can't seem to able to print/show the regression results. A key command at the which prints/shows results is probably missing.

new;

load x[43,2]=xvar.txt;
load y[43,1]=yvar.txt;

proc( 2 ) = kreg(y,x,xf,hpower);
    local n,tvec,gam,arg,ker,ghat,m,denom;
    n = rows(y); @ rows x & y the same @
    m = rows(xf); @ rows of xf in : mt(xf) = sum{(K(xf-xs)*ys}/sum(K(xf-xs)@
    tvec = x;
    gam = 1/n^hpower;
    arg = (xf*ones(1,n)-ones(m,1)*tvec')/gam;
    ker = pdfn(arg);
    denom = sumc(ker');
    ghat = (ker*y)./sumc(ker');
    retp(ghat,denom);
endp;

Can anyone kindly help me complete the code so that I can immediately begin empirical applications. My current paper is in limbo just because of this. Any help would be highly appreciated.

Thanks in advance.

Kind regards,

Muhammad Shafiullah

2 Answers



1



accepted

Hello Muhammad,

The code that you posted loads your data and then defines a GAUSS procedure that you can use, but never calls the procedure. You need to define what all the inputs should be, call the procedure and then print out the results with the print command like this:

//Clear all matrices and data from workspace
new;

//Load in data
load x[43,2]=xvar.txt;
load y[43,1]=yvar.txt;

//TODO: Define 'xf' input
//Don't forget to end line with semi-colon
xf = 

//TODO: Define 'hpower' input
//Don't forget to end line with semi-colon
hpower = 

//Call kreg procedure
{ ghat, denom } = kreg(y, x, xf, hpower);

//Print output
print "ghat = " ghat;
print "denom = " denom;

//Define what 'kreg' procedure should do
proc( 2 ) = kreg(y,x,xf,hpower);
    local n,tvec,gam,arg,ker,ghat,m,denom;
    n = rows(y); @ rows x & y the same @
    m = rows(xf); @ rows of xf in : mt(xf) = sum{(K(xf-xs)*ys}/sum(K(xf-xs)@
    tvec = x;
    gam = 1/n^hpower;
    arg = (xf*ones(1,n)-ones(m,1)*tvec')/gam;
    ker = pdfn(arg);
    denom = sumc(ker');
    ghat = (ker*y)./sumc(ker');
    retp(ghat,denom);
endp;

aptech

1,338


0



Dear Sir/Madam

I can't thank you enough for your prompt polishing of my codes. This will improve the quality of research greatly.

Sincerely,

Muhammad Shafiullah

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy