PARAMETER ESTIMATION SCRIPT (*Written by Kenneth Leonard*} (* ::Package:: *) CLEAR [ InFileName ] ; InFileName = " "; FileNameSetter [ Dynamic [ InFileName ] ] Print [ "============================================================" ] ; Print [ "----- Population data file ",InFileName ] ; Clear [ DataMatrix ] ; DataMatrix = Import [ InFileName ,"Data" ] ; Print [ "----- Population data " ] ; DataMatrix Print [ "============================================================" ] ; Flow=1/4.69; SS = 1000 ; Clear [ RK,C1C,C1N,CC,CN ] ; FitOutput = NonlinearModelFit [ DataMatrix, { ((1-1/(1+E^(SS (C1C/C1N-CC/CN )/(C1C/C1N)))) * (( RK CC)/(CC+C1C )-Flow) + (1-1/( 1+ E^( SS (C1N/C1C-CN/CC)/(C1N/C1C)))) * (( RK CN)/(CN+C1N)-Flow)), RK>0, C1C >0, C1N>0 }, { RK, C1C , C1N } , { CC , CN } ] Print [ "----- BestFitParameters" ] ; sRK = RK /. FitOutput [ "BestFitParameters" ] [ [ 1 ] ] ; sC1C = C1C /. FitOutput [ "BestFitParameters" ] [ [ 2 ] ] ; sC1N = C1N /. FitOutput [ "BestFitParameters" ] [ [ 3 ] ] ; CNRatio = sC1C / sC1N ; Print [ "---------- Maximum Capable Intrinsic Growth Rate" ] sRK Print [ "---------- Carbon Half-Max Concentration" ] sC1C Print [ "---------- Nitrogen Half-Max Concentration" ] sC1N Print [ "---------- Dual-Limiting C:N Ratio" ] CNRatio Print [ "----- RSquared" ] ; FitOutput [ "RSquared" ] Print [ "----- AdjustedRSquared" ] ; FitOutput [ "AdjustedRSquared" ] Print [ "----- AIC" ] ; FitOutput [ "AIC" ] Print [ "----- ANOVATable" ] ; FitOutput [ "ANOVATable" ] Print [ "----- ParameterConfidenceIntervalTable" ] ; FitOutput [ "ParameterConfidenceIntervalTable" ] Print [ "----- ParameterTable" ] ; FitOutput [ "ParameterTable" ] Print [ "============================================================" ] ; GRAPHING SCRIPT (*Written by Kenneth Leonard*} PopNameY = PopName1 ; RKY = ; C1CY = ; C1NY = ; PopNameZ = PopName2 ; RKZ = ; C1CZ = ; C1NZ = ; Plots (* Dual Surface Plot *) plot1=Show [ Plot3D [ { RKY Min [ C1C/(C1C+C1CY) , C1N/(C1N+C1NY) ] , RKZ Min [ C1C/(C1C+C1CZ) , C1N/(C1N+C1NZ) ] } , { C1C , 0 , CChi } , { C1N , 0 , CNhi } , Exclusions -> None , LabelStyle -> { 30 , FontFamily -> "Helvetica" } , AxesEdge -> { { -1 , -1 } , { -1 , -1 } , { -1 , 1 } } , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , ViewPoint -> { -1.0` , -0.5 , 0.5` } , PlotStyle -> { RGBColor [ 1 , 1 , 0 ] , RGBColor [ 0 , 0 , 1 ] } ] , ParametricPlot3D [ { C1C , C1NY / C1CY C1C , RKY C1C/(C1C+C1CY) } , { C1C , 0 , CChi } , Exclusions -> None , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , PlotStyle -> { Black , Thick } ] , ParametricPlot3D [ { C1C , C1NZ / C1CZ C1C , RKZ C1C/(C1C+C1CZ) } , { C1C , 0 , CChi } , Exclusions -> None , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , PlotStyle -> { Black , Thick, Dashing[Large]} ] ] (* Differential Surface *) Clear [ ColorScale ] ; ColorScale = Max [ Abs [ MaxValue [ { RKY Min [ C1C/(C1C +C1CY),C1N/(C1N+C1NY) ] - RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , 0 <= C1C <= CChi , 0 <= C1N <= CNhi } , { C1C , C1N } ] ] , Abs [ MinValue [ { RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] - RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , 0 <= C1C <= CChi , 0 <= C1N <= CNhi } , { C1C , C1N }]]]; plot2=Plot3D [ { RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] } , { C1C,0,CChi } , { C1N,0,CNhi } , Exclusions -> None , LabelStyle -> { 30 , FontFamily -> "Helvetica" } , AxesEdge-> { { -1,-1 } , { -1,-1 } , { -1,1 } } , PlotPoints->Ppoints, ImageSize-> { Pwidth,Pwidth } , ViewPoint-> { -1.0`,-0.4,.7` } , ColorFunction-> Function [ { x, y, z } , RGBColor [ Max [ 0, (z/ColorScale) ] , 1 - Max [ 0, -(z/ColorScale) ] , Max [ 0, -z/ColorScale ] ] ] , ColorFunctionScaling->False ] (* Differential Density *) Clear [ ColorScale ] ; ColorScale = Max [ Abs [ MaxValue [ { RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] - RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , 0 <= C1C <= CChi , 0 <= C1N <= CNhi } , { C1C , C1N } ] ] , Abs [ MinValue [ { RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] - RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , 0 <= C1C <= CChi , 0 <= C1N <= CNhi } , { C1C , C1N }]]]; plot3=Show [ DensityPlot [ RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , { C1C,0,CChi } , { C1N,0,CNhi } , Exclusions -> None , LabelStyle -> { 30 , FontFamily -> "Helvetica" } , PlotPoints->Ppoints, ImageSize-> { Pwidth,Pwidth } , ColorFunction-> Function [ { z } , RGBColor [ Max [ 0, (z/ColorScale) ] , 1 - Max [ 0, -(z/ColorScale) ] , Max [ 0, -z/ColorScale ] ] ] , ColorFunctionScaling->False ] , Plot [ { C1NY / C1CY C1C } , { C1C , 0 , CChi } , Exclusions -> None , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , PlotStyle -> {Black , Thick} ] , Plot [ { C1NZ / C1CZ C1C } , { C1C , 0 , CChi } , Exclusions -> None , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , PlotStyle -> { Black , Thick, Dashing[Large]} ] ] (* Differential Contour *) Clear [ ColorScale ] ; ColorScale = Max [ Abs [ MaxValue [ { RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] - RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , 0 <= C1C <= CChi , 0 <= C1N <= CNhi } , { C1C , C1N } ] ] , Abs [ MinValue [ { RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] - RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , 0 <= C1C <= CChi , 0 <= C1N <= CNhi } , { C1C , C1N }]]]; plot4=Show [ ContourPlot [ RKY Min [ C1C/(C1C+C1CY),C1N/(C1N+C1NY) ] RKZ Min [ C1C/(C1C+C1CZ),C1N/(C1N+C1NZ) ] , { C1C,0,CChi } , { C1N,0,CNhi } , Exclusions -> None , Contours -> { -0.1 , -0.05 , -0.04 ,-0.03 , -0.02 , -0.01 , 0 , 0.01 , 0.02 , 0.03 , 0.04 , 0.05 , 0.1 } , ContourLabels -> (Text[Style[#3, 30], {#1, #2}] &), LabelStyle -> { 30 , FontFamily -> "Helvetica" } , Frame -> False , Axes -> True , PlotPoints->Ppoints, ImageSize-> { Pwidth,Pwidth } , Contours-> 30, ColorFunction-> Function [ { z } , RGBColor [ Max [ 0, (z/ColorScale) ] , 1 - Max [ 0, -(z/ColorScale) ] , Max [ 0, -z/ColorScale ] ] ] , ColorFunctionScaling->False ] , Plot [ { C1NY / C1CY C1C } , { C1C , 0 , CChi } , Exclusions -> None , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , PlotStyle -> { Black , Thick } ] , Plot [ { C1NZ / C1CZ C1C } , { C1C , 0 , CChi } , Exclusions -> None , PlotPoints -> Ppoints , ImageSize -> { Pwidth , Pwidth } , PlotStyle -> { Black , Dashing[Large]} ] ]