* Fisher analysis; * Set working directory (Put your directory in place of xxxxxx); %let dir = c:\xxxxxx; %let dir = c:\documents and settings\jbaldwin\Desktop\Fisher manuscript new2\Revisions; * Load all of the SAS macros; %include "&dir.\fisher macros.sas"; * Import data; PROC IMPORT OUT=histories DATAFILE= "&dir.\data by zones.xlsx" DBMS=EXCEL2007 REPLACE; sheet="Data"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; run; * Duplicate data so that "All Zones" is a new zone (so SAS "by" statement can be used); data histories; set histories; output; Zone = "All"; output; run; * Sort by zone; proc sort data=histories out=histories; by zone; run; * Set the number of seasons; %let nSeasons = 8; * Perform analyses of each model; * Prob of presence: psiType = dot, Year, logit; * Persistence: phiType = dot, 0, Year; * Detection probability: pType = dot, Year, TwoGroup, YearTwoGroup; %Analysis(histories,8,psiType=dot,phiType=dot,pType=dot) %Analysis(histories,8,psiType=dot,phiType=dot,pType=Year) %Analysis(histories,8,psiType=dot,phiType=Year,pType=dot) %Analysis(histories,8,psiType=dot,phiType=Year,pType=Year) %Analysis(histories,8,psiType=Year,phiType=dot,pType=dot,gconv=1E-08) %Analysis(histories,8,psiType=Year,phiType=dot,pType=Year) %Analysis(histories,8,psiType=Year,phiType=Year,pType=dot) %Analysis(histories,8,psiType=Year,phiType=Year,pType=Year) %Analysis(histories,8,psiType=dot,phiType=0,pType=dot) %Analysis(histories,8,psiType=dot,phiType=0,pType=Year) %Analysis(histories,8,psiType=Year,phiType=0,pType=dot) %Analysis(histories,8,psiType=Year,phiType=0,pType=Year) %Analysis(histories,8,psiType=dot,phiType=0,pType=TwoGroup) %Analysis(histories,8,psiType=dot,phiType=dot,pType=TwoGroup) %Analysis(histories,8,psiType=dot,phiType=Year,pType=TwoGroup) %Analysis(histories,8,psiType=Year,phiType=0,pType=TwoGroup) %Analysis(histories,8,psiType=Year,phiType=dot,pType=TwoGroup) %Analysis(histories,8,psiType=Year,phiType=Year,pType=TwoGroup) %Analysis(histories,8,psiType=dot,phiType=0,pType=YearTwoGroup) %Analysis(histories,8,psiType=dot,phiType=dot,pType=YearTwoGroup) %Analysis(histories,8,psiType=dot,phiType=Year,pType=YearTwoGroup) %Analysis(histories,8,psiType=Year,phiType=0,pType=YearTwoGroup) %Analysis(histories,8,psiType=Year,phiType=dot,pType=YearTwoGroup) %Analysis(histories,8,psiType=Year,phiType=Year,pType=YearTwoGroup) %Analysis(histories,8,psiType=logit,phiType=dot,pType=dot) %Analysis(histories,8,psiType=logit,phiType=dot,pType=Year) %Analysis(histories,8,psiType=logit,phiType=dot,pType=TwoGroup) %Analysis(histories,8,psiType=logit,phiType=dot,pType=YearTwoGroup) %Analysis(histories,8,psiType=logit,phiType=0,pType=dot) %Analysis(histories,8,psiType=logit,phiType=0,pType=Year) %Analysis(histories,8,psiType=logit,phiType=0,pType=TwoGroup) %Analysis(histories,8,psiType=logit,phiType=0,pType=YearTwoGroup) %Analysis(histories,8,psiType=logit,phiType=Year,pType=dot) %Analysis(histories,8,psiType=logit,phiType=Year,pType=Year) %Analysis(histories,8,psiType=logit,phiType=Year,pType=TwoGroup) %Analysis(histories,8,psiType=logit,phiType=Year,pType=YearTwoGroup) * Combine estimates of detection probabilities; data ae; set aedotdotdot aedotdotYear aedotYeardot aedotYearYear aeYeardotdot aeYeardotYear aeYearYeardot aeYearYearYear aedot0dot aedot0Year aeYear0dot aeYear0Year aedot0TwoGroup aedotdotTwoGroup aedotYearTwoGroup aeYear0TwoGroup aeYeardotTwoGroup aeYearYearTwoGroup aedot0YearTwoGroup aedotdotYearTwoGroup aedotYearYearTwoGroup aeYear0YearTwoGroup aeYeardotYearTwoGroup aeYearYearYearTwoGroup aelogitdotdot aelogitdotYear aelogitdotTwoGroup aelogitdotYearTwoGroup aelogit0dot aelogit0Year aelogit0TwoGroup aelogit0YearTwoGroup aelogitYeardot aelogitYearYear aelogitYearTwoGroup aelogitYearYearTwoGroup; run; * Combine AIC values; data AIC; set fsdotdotdot fsdotdotYear fsdotYeardot fsdotYearYear fsYeardotdot fsYeardotYear fsYearYeardot fsYearYearYear fsdot0dot fsdot0Year fsYear0dot fsYear0Year fsdot0TwoGroup fsdotdotTwoGroup fsdotYearTwoGroup fsYear0TwoGroup fsYeardotTwoGroup fsYearYearTwoGroup fsdot0YearTwoGroup fsdotdotYearTwoGroup fsdotYearYearTwoGroup fsYear0YearTwoGroup fsYeardotYearTwoGroup fsYearYearYearTwoGroup fslogitdotdot fslogitdotYear fslogitdotTwoGroup fslogitdotYearTwoGroup fslogit0dot fslogit0Year fslogit0TwoGroup fslogit0YearTwoGroup fslogitYeardot fslogitYearYear fslogitYearTwoGroup fslogitYearYearTwoGroup ; proc sort data=AIC out=AIC; by zone AIC; data AIC total; set AIC; by zone; retain minAIC total; if first.zone then do; minAIC = AIC; total = 0; end; deltaAIC = AIC - minAIC; AICWt = exp(-deltaAIC/2); total = total + AICWt; output AIC; if last.zone then output total; run; data total; set total; keep zone total; data AIC; set AIC; keep zone model AIC deltaAIC AICWt; data AIC; merge AIC total; drop total; by zone; AICWt = AICWt/total; run; * Parameter estimates; data pe; set pedotdotdot pedotdotYear pedotYeardot pedotYearYear peYeardotdot peYeardotYear peYearYeardot peYearYearYear pedot0dot pedot0Year peYear0dot peYear0Year pedot0TwoGroup pedotdotTwoGroup pedotYearTwoGroup peYear0TwoGroup peYeardotTwoGroup peYearYearTwoGroup pedot0YearTwoGroup pedotdotYearTwoGroup pedotYearYearTwoGroup peYear0YearTwoGroup peYeardotYearTwoGroup peYearYearYearTwoGroup pelogitdotdot pelogitdotYear pelogitdotTwoGroup pelogitdotYearTwoGroup pelogit0dot pelogit0Year pelogit0TwoGroup pelogit0YearTwoGroup pelogitYeardot pelogitYearYear pelogitYearTwoGroup pelogitYearYearTwoGroup ; * Save output summaries; PROC EXPORT DATA= WORK.AIC OUTFILE= "&dir.\fisher summary 2012-08-10.xlsx" DBMS=EXCEL2007 REPLACE; SHEET="AIC"; PROC EXPORT DATA= WORK.PE OUTFILE= "&dir.\fisher summary 2012-08-10.xlsx" DBMS=EXCEL2007 REPLACE; SHEET="ParameterEstimates"; PROC EXPORT DATA= WORK.AE OUTFILE= "&dir.\fisher summary 2012-08-10.xlsx" DBMS=EXCEL2007 REPLACE; SHEET="AdditionalEstimates"; PROC EXPORT DATA= WORK.Histories OUTFILE= "&dir.\fisher summary 2012-08-10.xlsx" DBMS=EXCEL2007 REPLACE; SHEET="Histories"; run;