* This is file MARSINVD.SAS ; options noovp; title 'Martian Invasion Data'; DATA raw; infile marsinvd; input time I; * Grid Search ; proc NLIN; parameters Imax=10 to 30 by 2 T=10 to 30 by 2; model I=Imax*(cos(2*3.14159*time/T)+1)/2; DER.Imax=(cos(2*3.14159*time/T)+1)/2; DER.T=Imax*sin(2*3.14159*time/T)*(3.14159*time/T**2); output OUT=PlotGrid PREDICTED=Ihat RESIDUAL=resid; proc PLOT data=PlotGrid; plot I*time='+' Ihat*time='P' / OVERLAY VPOS=25; plot resid*time / VREF=0 VPOS=25; * Steepest descent ; * Good first guess ; * Global minimum ; proc NLIN METHOD=GRADIENT CONVERGENCE=.005 data=raw; parameters Imax=20 T=20; model I=Imax*(cos(2*3.14159*time/T)+1)/2; DER.Imax=(cos(2*3.14159*time/T)+1)/2; DER.T=Imax*sin(2*3.14159*time/T)*(3.14159*time/T**2); output OUT=PlotG1 PREDICTED=Ihat RESIDUAL=resid; proc PLOT data=PlotG1; plot I*time='+' Ihat*time='P' / OVERLAY VPOS=25; plot resid*time / VREF=0 VPOS=25; * Gauss - Newton ; proc NLIN METHOD=GAUSS CONVERGENCE=.00000001 data=raw; parameters Imax=20 T=20; model I=Imax*(cos(2*3.14159*time/T)+1)/2; DER.Imax=(cos(2*3.14159*time/T)+1)/2; DER.T=Imax*sin(2*3.14159*time/T)*(3.14159*time/T**2); output OUT=PlotGaus PREDICTED=Ihat RESIDUAL=resid; proc PLOT data=PlotGaus; plot I*time='+' Ihat*time='P' / OVERLAY VPOS=25; plot resid*time / VREF=0 VPOS=25; * Marquardt ; proc NLIN METHOD=MARQUARDT CONVERGENCE=.00000001 data=raw; parameters Imax=20 T=20; model I=Imax*(cos(2*3.14159*time/T)+1)/2; DER.Imax=(cos(2*3.14159*time/T)+1)/2; DER.T=Imax*sin(2*3.14159*time/T)*(3.14159*time/T**2); output OUT=PlotMarq PREDICTED=Ihat RESIDUAL=resid; proc PLOT data=PlotMarq; plot I*time='+' Ihat*time='P' / OVERLAY VPOS=25; plot resid*time / VREF=0 VPOS=25;