/* firefly1.sas */ options ls=72 ps=60; data firefly0; infile 'firefly.dat'; input date condition $ time temp light; code = condition; if condition = 'cloudy' then code = 'y'; proc plot data=firefly0; plot time*light = code; plot time*temp = code; plot light*temp = code; title 'plots with overcast included'; /* remove observations for overcast days */ data firefly; set firefly0; if condition = 'overcast' then delete; proc plot data=firefly; plot time*light = code; plot time*temp = code; plot light*temp = code; title 'plots with overcast excluded'; /* fit models */ /* regression of time on temp and light (full model) */ proc glm data=firefly; model time = temp light / ss1 ss2 clparm; output out=new1 predicted=yhat residual=resid lcl=clpl ucl=clpu lclm=clml uclm=clmu; title 'regression of time on temp and light (full model)'; proc print data=new1; var time temp light clml clmu clpl clpu yhat resid; proc plot data=new1; plot resid*yhat / vref=0; plot resid*temp / vref=0; plot resid*light / vref=0; plot resid*date / vref=0; title 'residual plots: full model'; /* regression of time on light and temp (full model) */ proc glm data=firefly; model time = light temp / ss1 ss2 clparm; title 'regression of time on temp and light (full model)'; /* regression of time on temp (reduced model) */ proc glm data=firefly; model time = temp / ss1 ss2 clparm; output out=new2 predicted=yhat residual=resid lcl=clpl ucl=clpu lclm=clml uclm=clmu; title 'regression of time on temp (reduced model)'; proc print data=new2; var time temp clml clmu clpl clpu yhat resid; proc plot data=new2; plot resid*yhat / vref=0; plot resid*temp / vref=0; plot resid*light / vref=0; plot resid*date / vref=0; title 'residual plots: reduced model (temp only)'; /* regression of time on light (reduced model) */ proc glm data=firefly; model time = light / ss1 ss2 clparm; output out=new3 predicted=yhat residual=resid lcl=clpl ucl=clpu lclm=clml uclm=clmu; title 'regression of time on light (reduced model)'; proc print data=new3; var time temp clml clmu clpl clpu yhat resid; proc plot data=new3; plot resid*yhat / vref=0; plot resid*temp / vref=0; plot resid*light / vref=0; plot resid*date / vref=0; title 'residual plots: reduced model (light only)'; /* use proc reg to get sequential regression coefficients */ proc reg data=firefly; model time = temp light / seqb ss1 ss2; model time = light temp / seqb ss1 ss2; title 'regressions with sequential coefficients'; /* get adjusted explanatory variables */ /* regression of light on temp for adjustment of light */ proc glm data=firefly; model light = temp / ss1 ss2; output out=newlight r=adjlight; title 'regression of light on temp for adjustment of light'; proc print data=newlight; var time temp adjlight; proc plot data=newlight; plot adjlight*temp; plot time*adjlight; proc glm data=newlight; model time = temp adjlight /ss1 ss2; title 'regression of time on temp and adjlight'; /* regression of temp on light for adjustment of temp */ proc glm data=firefly; model temp = light / ss1 ss2; output out=newtemp r=adjtemp; title 'regression of temp on light for adjustment of temp'; proc print data=newtemp; var time light adjtemp; proc plot data=newtemp; plot adjtemp*light; plot time*adjtemp; proc glm data=newtemp; model time = light adjtemp /ss1 ss2; title 'regression of time on light and adjtemp'; run;