/* SAS program for SAS v. 6.12 */
/* Sine-Hole fitting using Maximum Likelihood */
/* Written by Bart Faulkner, 1998 */
/* RS Kerr Environmental Research Center */
/* PO Box 1198 */
/* Ada, OK 74820 */
title1 'maxlike_sh.sas';
data vario;
input lag gam std;
upper=gam+2*std;
lower=gam-2*std;
cards;
/* User must replace this data with their own */
/* Format: LAG SEMIVARIANCE ST.DEVIATION */
0.669971 0.005441 0.003441
1.134005 0.029324 0.005567
2.294657 0.016279 0.002527
3.140263 0.017439 0.002401
4.031059 0.025771 0.004113
4.968072 0.023770 0.003296
5.893752 0.039182 0.004879
6.865795 0.040424 0.003645
7.634520 0.044532 0.003446
8.523052 0.039650 0.003824
9.445079 0.046151 0.004799
10.308818 0.035698 0.004667
11.199346 0.028174 0.004387
12.122913 0.021290 0.004279
13.092132 0.061075 0.008020
;
proc nlin method=marquardt maxiter=600 best=1;
/* User should specify their own initial guesses: */
parameters nugget=0.0025
sill=0.033
range=9.93;
bounds nugget>0, sill>0, range>0;
model.gam = nugget+(sill-nugget)*(1.-sin(4.4934*lag/range)/(4.4934*lag/range));
/* Derivatives can be uncommented */
/* arg = (4.4934*lag/range)/(4.4934*lag/range);*/
/* DER.nugget = sin(arg);*/
/* DER.sill = 1-sin(arg);*/
/* DER.range = ((8.9868*lag*cos(4.4934*lag/range))/range)*(sill-nugget);*/
_weight_ = 1/std;
output out=b1 predicted=p_gam residual=r_gam sse=sse;
run;
proc means data=vario noprint css;
var gam;
output out=b2 css=css;
run;
data _null_;
set b1(obs=1); set b2(obs=1);
rsq=1-sse/css;
file print;
put // +10 'R-SQUARE' /
+10 '(Can be negative)' //
+10 'R-SQUARE =' +5 RSQ 8.6;
run;
proc print data=b1;
run;
proc plot data=b1;
plot gam*lag='*' p_gam*lag='.' upper*lag='-' lower*lag='-' /overlay;
run;
quit;