SlideShare a Scribd company logo
1 of 8
Download to read offline
Introduction to AD Model Builder
Anders Nielsen
an@aqua.dtu.dk
What is AD Model Builder
ˆ Tool for development and optimization of nonlinear models
ˆ Structured template for C++ programming
ˆ Support library containing:
– A quasi-Newton minimizer aided by automatic differentiation
– Data objects (number, vector, matrix, 3darray,
ragged arrays, strings, ...)
– Model parameters (unbounded, bounded, fixed, summing to zero,
vectors of, matrix of, ...)
– A simple way to set up optimization in phases
– Standard ways to quantify uncertainty (Hessian based delta method, profile like-
lihood, MCMC sampling)
– Tools for random effects (AD aided Laplace approximation, sparse ma-
trix, importance sampling, ...)
– Lots of helper functions (gammaln, choleski decomp, inv, det, eigenvalues, RNG,
... )
What is it used for?
ˆ Not enough
ˆ Our web-site lists (at my last count):
— 110 peer reviewed publications based on AD Model Builder applications
— 18 Theses and Dissertations
— Countless reports and fish stock assessments
ˆ Those are only the users who remembered to report back
ˆ Models in fisheries science are typically:
— Non-standard
— Non-linear
— High dimensional
ˆ Often they also contain random effects
ˆ They should preferably run in minutes
Dave Fournier receiving the AFS Ricker award
Quick example
ˆ Assume that these 15 numbers follow a negative binomial distribution:
# Number of observations
15
# Observations
13 5 28 28 15 4 13 4 10 17 11 13 12 17 3
ˆ Estimate the two unknown parameters.
ˆ Entire AD Model Builder Program:
DATA_SECTION
init_int N
init_vector X(1,N);
PARAMETER_SECTION
init_number logsize;
init_bounded_number p(0,1);
sdreport_number size;
objective_function_value nll;
PROCEDURE_SECTION
size=exp(logsize);
nll=-sum(gammln(X+size))+N*gammln(size)+
sum(gammln(X+1.0))-N*size*log(p)-sum(X)*log(1.0-p);
ˆ Compile: <filename>.tpl
makeadm
−→ <filename>.cpp
g++
−→ binary
index name value std dev
1 logsize 1.3017e+00 4.7101e-01
2 p 2.2218e-01 8.5571e-02
3 size 3.6754e+00 1.7312e+00
A fisheries catch-at-age model
ˆ Data is the yearly catch in 7 age classes and 45 years Cay, and a yearly index of fishing
effort ey
ˆ The model has 107 model parameters to be estimated (small for an assessment model)
ˆ The model is non-linear
ˆ In AD Model Builder that takes 0.3 seconds to optimize and compute and write all
output
Random effects — no problem
DATA_SECTION
init_int N
init_vector Y(1,N)
PARAMETER_SECTION
init_number logr0
init_number logtheta
init_bounded_number logK(4.6,7.6)
init_number logQ
init_number logR
random_effects_vector X(1,N);
sdreport_number r0
sdreport_number theta
sdreport_number K
sdreport_number Q
sdreport_number R
objective_function_value jnll
PROCEDURE_SECTION
for(int i=2; i<=N; ++i){
step(X(i-1),X(i),logr0,logK,logtheta,logQ);
}
for(int i=1; i<=N; ++i){
obs(X(i),logR,i);
}
r0=exp(logr0); theta=exp(logtheta); K=exp(logK); Q=exp(logQ); R=exp(logR);
SEPARABLE_FUNCTION void step(const dvariable& x1, const dvariable& x2, const dvariable& logr0, const dv
dvariable var=exp(logQ);
dvariable m=x1 + exp(logr0) * (1.0 - pow(exp(x1)/exp(logK),exp(logtheta)));
jnll+=0.5*(log(2.0*M_PI*var)+square(x2-m)/var);
SEPARABLE_FUNCTION void obs(const dvariable& x, const dvariable& logR, int i)
dvariable var=exp(logR);
jnll+=0.5*(log(2.0*M_PI*var)+square(x-Y(i))/var);
A theta logistic population model is defined
for the log-transformed population size as a
nonlinear function of its previous size in the
following way:
Xt = Xt−1 + r0 1 −
exp(Xt−1)
K
θ
+ et,
Yt = Xt + ut,
where et ∼ N(0, Q) and ut ∼ N(0, R).
Anders Nielsen AD Model-Builder
Anders Nielsen AD Model-Builder

More Related Content

What's hot

Sajid Ali reg # 016
Sajid Ali reg # 016Sajid Ali reg # 016
Sajid Ali reg # 016
Sajid Ali
 

What's hot (20)

Machine Learning Basics for Web Application Developers
Machine Learning Basics for Web Application DevelopersMachine Learning Basics for Web Application Developers
Machine Learning Basics for Web Application Developers
 
Concept of c
Concept of cConcept of c
Concept of c
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
 
Overview of Apache SystemML by Berthold Reinwald and Nakul Jindal
Overview of Apache SystemML by Berthold Reinwald and Nakul JindalOverview of Apache SystemML by Berthold Reinwald and Nakul Jindal
Overview of Apache SystemML by Berthold Reinwald and Nakul Jindal
 
Oral-2
Oral-2Oral-2
Oral-2
 
Sajid Ali reg # 016
Sajid Ali reg # 016Sajid Ali reg # 016
Sajid Ali reg # 016
 
Minimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part IMinimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part I
 
Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.ppt
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Complexity Analysis
Complexity Analysis Complexity Analysis
Complexity Analysis
 
Software Metrics
Software MetricsSoftware Metrics
Software Metrics
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
14 dimentionality reduction
14 dimentionality reduction14 dimentionality reduction
14 dimentionality reduction
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
2 optimization
2 optimization2 optimization
2 optimization
 
Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
 
Exp 3
Exp 3Exp 3
Exp 3
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Analysis of algo
Analysis of algoAnalysis of algo
Analysis of algo
 

Similar to Anders Nielsen AD Model-Builder

Similar to Anders Nielsen AD Model-Builder (20)

Feature Engineering - Getting most out of data for predictive models - TDC 2017
Feature Engineering - Getting most out of data for predictive models - TDC 2017Feature Engineering - Getting most out of data for predictive models - TDC 2017
Feature Engineering - Getting most out of data for predictive models - TDC 2017
 
R programmingmilano
R programmingmilanoR programmingmilano
R programmingmilano
 
Feature Engineering - Getting most out of data for predictive models
Feature Engineering - Getting most out of data for predictive modelsFeature Engineering - Getting most out of data for predictive models
Feature Engineering - Getting most out of data for predictive models
 
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
 
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
DN 2017 | Multi-Paradigm Data Science - On the many dimensions of Knowledge D...
 
[DSC Europe 22] Smart approach in development and deployment process for vari...
[DSC Europe 22] Smart approach in development and deployment process for vari...[DSC Europe 22] Smart approach in development and deployment process for vari...
[DSC Europe 22] Smart approach in development and deployment process for vari...
 
Chapter 1 Basic Concepts
Chapter 1 Basic ConceptsChapter 1 Basic Concepts
Chapter 1 Basic Concepts
 
Towards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoTowards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei Diao
 
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineering
 
L5 array
L5 arrayL5 array
L5 array
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSEL
 
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
Mini-lab 1: Stochastic Gradient Descent classifier, Optimizing Logistic Regre...
 
Real-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingReal-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to Streaming
 
Analytics with Spark
Analytics with SparkAnalytics with Spark
Analytics with Spark
 
Aggregation Functions in OCL
Aggregation Functions in OCL Aggregation Functions in OCL
Aggregation Functions in OCL
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdf
 
Xgboost
XgboostXgboost
Xgboost
 
Timeseries - data visualization in Grafana
Timeseries - data visualization in GrafanaTimeseries - data visualization in Grafana
Timeseries - data visualization in Grafana
 
big-data-anallytics.pptx
big-data-anallytics.pptxbig-data-anallytics.pptx
big-data-anallytics.pptx
 

More from David LeBauer

Software and data as scaffolds for integrative science
Software and data as scaffolds for integrative scienceSoftware and data as scaffolds for integrative science
Software and data as scaffolds for integrative science
David LeBauer
 
Reusable Software and Open Data To Optimize Agriculture
Reusable Software and Open Data To Optimize AgricultureReusable Software and Open Data To Optimize Agriculture
Reusable Software and Open Data To Optimize Agriculture
David LeBauer
 
Matt Jones software-interoperability
Matt Jones software-interoperabilityMatt Jones software-interoperability
Matt Jones software-interoperability
David LeBauer
 
Aaron Ellison: Analytic Web
Aaron Ellison: Analytic WebAaron Ellison: Analytic Web
Aaron Ellison: Analytic Web
David LeBauer
 
Ilkay Altintas: Kepler
Ilkay Altintas: KeplerIlkay Altintas: Kepler
Ilkay Altintas: Kepler
David LeBauer
 
Jeroen Steenbeek Ecopath with Ecosim
Jeroen Steenbeek Ecopath with EcosimJeroen Steenbeek Ecopath with Ecosim
Jeroen Steenbeek Ecopath with Ecosim
David LeBauer
 
Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%
David LeBauer
 
Andrew Thomas OpenBUGS
Andrew Thomas OpenBUGSAndrew Thomas OpenBUGS
Andrew Thomas OpenBUGS
David LeBauer
 
Janine Illian R-INLA
Janine Illian R-INLAJanine Illian R-INLA
Janine Illian R-INLA
David LeBauer
 
Advancing Software for Ecological Forecasting: Public Sessions
Advancing Software for Ecological Forecasting: Public SessionsAdvancing Software for Ecological Forecasting: Public Sessions
Advancing Software for Ecological Forecasting: Public Sessions
David LeBauer
 
Advancing software for ecological forecasting
Advancing software for ecological forecastingAdvancing software for ecological forecasting
Advancing software for ecological forecasting
David LeBauer
 

More from David LeBauer (20)

Software and data as scaffolds for integrative science
Software and data as scaffolds for integrative scienceSoftware and data as scaffolds for integrative science
Software and data as scaffolds for integrative science
 
Reusable Software and Open Data To Optimize Agriculture
Reusable Software and Open Data To Optimize AgricultureReusable Software and Open Data To Optimize Agriculture
Reusable Software and Open Data To Optimize Agriculture
 
Yiqi Luo EcoPAD
Yiqi Luo EcoPADYiqi Luo EcoPAD
Yiqi Luo EcoPAD
 
David LeBauer PEcAn
David LeBauer PEcAnDavid LeBauer PEcAn
David LeBauer PEcAn
 
David Kelly SWIFT
David Kelly SWIFTDavid Kelly SWIFT
David Kelly SWIFT
 
Matt Jones software-interoperability
Matt Jones software-interoperabilityMatt Jones software-interoperability
Matt Jones software-interoperability
 
Aaron Ellison: Analytic Web
Aaron Ellison: Analytic WebAaron Ellison: Analytic Web
Aaron Ellison: Analytic Web
 
Ilkay Altintas: Kepler
Ilkay Altintas: KeplerIlkay Altintas: Kepler
Ilkay Altintas: Kepler
 
Jeroen Steenbeek Ecopath with Ecosim
Jeroen Steenbeek Ecopath with EcosimJeroen Steenbeek Ecopath with Ecosim
Jeroen Steenbeek Ecopath with Ecosim
 
Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%Aaron Ellison Keynote: Reaching the 99%
Aaron Ellison Keynote: Reaching the 99%
 
Andrew Thomas OpenBUGS
Andrew Thomas OpenBUGSAndrew Thomas OpenBUGS
Andrew Thomas OpenBUGS
 
Martyn Plummer JAGS
Martyn Plummer JAGSMartyn Plummer JAGS
Martyn Plummer JAGS
 
Daniel Lee STAN
Daniel Lee STANDaniel Lee STAN
Daniel Lee STAN
 
Ed Ionides POMP
Ed Ionides POMPEd Ionides POMP
Ed Ionides POMP
 
Janine Illian R-INLA
Janine Illian R-INLAJanine Illian R-INLA
Janine Illian R-INLA
 
Andy Fox DART
Andy Fox DARTAndy Fox DART
Andy Fox DART
 
Mike Dietze PEcAn
Mike Dietze PEcAnMike Dietze PEcAn
Mike Dietze PEcAn
 
de Valpine NIMBLE
de Valpine NIMBLEde Valpine NIMBLE
de Valpine NIMBLE
 
Advancing Software for Ecological Forecasting: Public Sessions
Advancing Software for Ecological Forecasting: Public SessionsAdvancing Software for Ecological Forecasting: Public Sessions
Advancing Software for Ecological Forecasting: Public Sessions
 
Advancing software for ecological forecasting
Advancing software for ecological forecastingAdvancing software for ecological forecasting
Advancing software for ecological forecasting
 

Recently uploaded

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Anders Nielsen AD Model-Builder

  • 1. Introduction to AD Model Builder Anders Nielsen an@aqua.dtu.dk
  • 2. What is AD Model Builder ˆ Tool for development and optimization of nonlinear models ˆ Structured template for C++ programming ˆ Support library containing: – A quasi-Newton minimizer aided by automatic differentiation – Data objects (number, vector, matrix, 3darray, ragged arrays, strings, ...) – Model parameters (unbounded, bounded, fixed, summing to zero, vectors of, matrix of, ...) – A simple way to set up optimization in phases – Standard ways to quantify uncertainty (Hessian based delta method, profile like- lihood, MCMC sampling) – Tools for random effects (AD aided Laplace approximation, sparse ma- trix, importance sampling, ...) – Lots of helper functions (gammaln, choleski decomp, inv, det, eigenvalues, RNG, ... )
  • 3. What is it used for? ˆ Not enough ˆ Our web-site lists (at my last count): — 110 peer reviewed publications based on AD Model Builder applications — 18 Theses and Dissertations — Countless reports and fish stock assessments ˆ Those are only the users who remembered to report back ˆ Models in fisheries science are typically: — Non-standard — Non-linear — High dimensional ˆ Often they also contain random effects ˆ They should preferably run in minutes Dave Fournier receiving the AFS Ricker award
  • 4. Quick example ˆ Assume that these 15 numbers follow a negative binomial distribution: # Number of observations 15 # Observations 13 5 28 28 15 4 13 4 10 17 11 13 12 17 3 ˆ Estimate the two unknown parameters. ˆ Entire AD Model Builder Program: DATA_SECTION init_int N init_vector X(1,N); PARAMETER_SECTION init_number logsize; init_bounded_number p(0,1); sdreport_number size; objective_function_value nll; PROCEDURE_SECTION size=exp(logsize); nll=-sum(gammln(X+size))+N*gammln(size)+ sum(gammln(X+1.0))-N*size*log(p)-sum(X)*log(1.0-p); ˆ Compile: <filename>.tpl makeadm −→ <filename>.cpp g++ −→ binary index name value std dev 1 logsize 1.3017e+00 4.7101e-01 2 p 2.2218e-01 8.5571e-02 3 size 3.6754e+00 1.7312e+00
  • 5. A fisheries catch-at-age model ˆ Data is the yearly catch in 7 age classes and 45 years Cay, and a yearly index of fishing effort ey ˆ The model has 107 model parameters to be estimated (small for an assessment model) ˆ The model is non-linear ˆ In AD Model Builder that takes 0.3 seconds to optimize and compute and write all output
  • 6. Random effects — no problem DATA_SECTION init_int N init_vector Y(1,N) PARAMETER_SECTION init_number logr0 init_number logtheta init_bounded_number logK(4.6,7.6) init_number logQ init_number logR random_effects_vector X(1,N); sdreport_number r0 sdreport_number theta sdreport_number K sdreport_number Q sdreport_number R objective_function_value jnll PROCEDURE_SECTION for(int i=2; i<=N; ++i){ step(X(i-1),X(i),logr0,logK,logtheta,logQ); } for(int i=1; i<=N; ++i){ obs(X(i),logR,i); } r0=exp(logr0); theta=exp(logtheta); K=exp(logK); Q=exp(logQ); R=exp(logR); SEPARABLE_FUNCTION void step(const dvariable& x1, const dvariable& x2, const dvariable& logr0, const dv dvariable var=exp(logQ); dvariable m=x1 + exp(logr0) * (1.0 - pow(exp(x1)/exp(logK),exp(logtheta))); jnll+=0.5*(log(2.0*M_PI*var)+square(x2-m)/var); SEPARABLE_FUNCTION void obs(const dvariable& x, const dvariable& logR, int i) dvariable var=exp(logR); jnll+=0.5*(log(2.0*M_PI*var)+square(x-Y(i))/var); A theta logistic population model is defined for the log-transformed population size as a nonlinear function of its previous size in the following way: Xt = Xt−1 + r0 1 − exp(Xt−1) K θ + et, Yt = Xt + ut, where et ∼ N(0, Q) and ut ∼ N(0, R).