%stat351-kernel.m %Unempolyement rate plot(unemployment,'.'); t=[1:252]'; X=[ones(252,1),t,t.^2]; >> X X = 1 1 1 1 2 4 1 3 9 ..... 1 251 63001 1 252 63504 >>a=inv(X'*X)*X'*unemployment a = 4.2911 0.0510 -0.0002 Y=4.2911 + 0.0510*t-0.0002*t.^2; hold plot(t,Y) >>mu_0=mean(unemployment); mu_0 = 6.6913 Y=unemployment-mu_0; plot(Y,'.'); %Shape of a Gaussian kernel x=[-10:0.1:10]; plot(x,normpdf(x,0,1)) x=[-10:1:10]; plot(x,normpdf(x,0,1)) >>normpdf(x,0,4)' ans = 0.0044 0.0079 0.0135 0.0216 0.0324 0.0457 0.0605 0.0753 0.0880 0.0967 0.0997 0.0967 0.0880 0.0753 0.0605 0.0457 0.0324 0.0216 0.0135 0.0079 0.0044 W= [0.0135 0.0216 0.0324 0.0457 0.0605 0.0753 0.0880 0.0967 0.0997 0.0967 0.0880 0.0753 0.0605 0.0457 0.0324 0.0216 0.0135] mu=convn(Y,W,'same'); hold on plot(mu+mu_0,'-')