Nonlinear mixed-effects models using Stata

Similar documents
Estimation and Model Selection in Mixed Effects Models Part I. Adeline Samson 1

4. MA(2) +drift: y t = µ + ɛ t + θ 1 ɛ t 1 + θ 2 ɛ t 2. Mean: where θ(l) = 1 + θ 1 L + θ 2 L 2. Therefore,

Recent Developments in Multilevel Modeling

Confidence intervals for the variance component of random-effects linear models

Case of single exogenous (iv) variable (with single or multiple mediators) iv à med à dv. = β 0. iv i. med i + α 1

Plot of Laser Operating Current as a Function of Time Laser Test Data

Measures of Fit from AR(p)

Group Comparisons: Differences in Composition Versus Differences in Models and Effects

Outline. Linear OLS Models vs: Linear Marginal Models Linear Conditional Models. Random Intercepts Random Intercepts & Slopes

Lecture 2: Poisson and logistic regression

Ordinal Independent Variables Richard Williams, University of Notre Dame, Last revised April 9, 2017

Lecture 5: Poisson and logistic regression

Empirical Asset Pricing

A Journey to Latent Class Analysis (LCA)

The estimation methods in Nonlinear Mixed-Effects Models (NLMM) still largely rely on numerical approximation of the likelihood function

ON THE CONSEQUENCES OF MISSPECIFING ASSUMPTIONS CONCERNING RESIDUALS DISTRIBUTION IN A REPEATED MEASURES AND NONLINEAR MIXED MODELLING CONTEXT

Fitting PK Models with SAS NLMIXED Procedure Halimu Haridona, PPD Inc., Beijing

Analysing repeated measurements whilst accounting for derivative tracking, varying within-subject variance and autocorrelation: the xtiou command

Econometrics. 9) Heteroscedasticity and autocorrelation

point estimates, standard errors, testing, and inference for nonlinear combinations

One-stage dose-response meta-analysis

nonlinear mixed effect model fitting with nlme

Lecture 3 Linear random intercept models

Estimating terminal half life by non-compartmental methods with some data below the limit of quantification

Exercices for Applied Econometrics A

Postestimation commands predict estat Remarks and examples Stored results Methods and formulas

Estimating Markov-switching regression models in Stata

Example 7b: Generalized Models for Ordinal Longitudinal Data using SAS GLIMMIX, STATA MEOLOGIT, and MPLUS (last proportional odds model only)

xtdpdqml: Quasi-maximum likelihood estimation of linear dynamic short-t panel data models

Outline. Mixed models in R using the lme4 package Part 3: Longitudinal data. Sleep deprivation data. Simple longitudinal data

Multilevel Modeling Day 2 Intermediate and Advanced Issues: Multilevel Models as Mixed Models. Jian Wang September 18, 2012

The general concept of pharmacokinetics

Lecture 4: Generalized Linear Mixed Models

Practical Econometrics. for. Finance and Economics. (Econometrics 2)

Soc 63993, Homework #7 Answer Key: Nonlinear effects/ Intro to path analysis

Title. Description. Special-interest postestimation commands. xtmelogit postestimation Postestimation tools for xtmelogit

Generalized linear models

Lecture#12. Instrumental variables regression Causal parameters III

Lab 3: Two levels Poisson models (taken from Multilevel and Longitudinal Modeling Using Stata, p )

CRE METHODS FOR UNBALANCED PANELS Correlated Random Effects Panel Data Models IZA Summer School in Labor Economics May 13-19, 2013 Jeffrey M.

Class Notes: Week 8. Probit versus Logit Link Functions and Count Data

Monday 7 th Febraury 2005

Hierarchical Generalized Linear Models. ERSH 8990 REMS Seminar on HLM Last Lecture!

5. Let W follow a normal distribution with mean of μ and the variance of 1. Then, the pdf of W is

SOCY5601 Handout 8, Fall DETECTING CURVILINEARITY (continued) CONDITIONAL EFFECTS PLOTS

Lecture 3.1 Basic Logistic LDA

Warwick Economics Summer School Topics in Microeconometrics Instrumental Variables Estimation

Non-linear mixed-effects pharmacokinetic/pharmacodynamic modelling in NLME using differential equations

multilevel modeling: concepts, applications and interpretations

Testing methodology. It often the case that we try to determine the form of the model on the basis of data

1 The basics of panel data

MA/ST 810 Mathematical-Statistical Modeling and Analysis of Complex Systems

Mixed effects models

General Linear Model (Chapter 4)

Description Syntax for predict Menu for predict Options for predict Remarks and examples Methods and formulas References Also see

options description set confidence level; default is level(95) maximum number of iterations post estimation results

2.1. Consider the following production function, known in the literature as the transcendental production function (TPF).

2: Multiple Linear Regression 2.1

Introduction A research example from ASR mltcooksd mlt2stage Outlook. Multi Level Tools. Influential cases in multi level modeling

Description Quick start Menu Syntax Options Remarks and examples Stored results Methods and formulas Acknowledgments References Also see

ECON2228 Notes 2. Christopher F Baum. Boston College Economics. cfb (BC Econ) ECON2228 Notes / 47

Using generalized structural equation models to fit customized models without programming, and taking advantage of new features of -margins-

GMM Estimation in Stata

Comparison of Stochastic Soybean Yield Response Functions to Phosphorus Fertilizer

36-309/749 Experimental Design for Behavioral and Social Sciences. Dec 1, 2015 Lecture 11: Mixed Models (HLMs)

Introduction to Within-Person Analysis and RM ANOVA

Treatment interactions with nonexperimental data in Stata

Introduction and Background to Multilevel Analysis

Marginal Effects in Multiply Imputed Datasets

Additional Notes: Investigating a Random Slope. When we have fixed level-1 predictors at level 2 we show them like this:

ECON Introductory Econometrics. Lecture 5: OLS with One Regressor: Hypothesis Tests

Subject-specific observed profiles of log(fev1) vs age First 50 subjects in Six Cities Study

1 A Review of Correlation and Regression

Description Syntax for predict Menu for predict Options for predict Remarks and examples Methods and formulas References Also see

Graduate Econometrics Lecture 4: Heteroskedasticity

ESTIMATING AVERAGE TREATMENT EFFECTS: REGRESSION DISCONTINUITY DESIGNS Jeff Wooldridge Michigan State University BGSE/IZA Course in Microeconometrics

Working with Stata Inference on the mean

MLMED. User Guide. Nicholas J. Rockwood The Ohio State University Beta Version May, 2017

Essential of Simple regression

****Lab 4, Feb 4: EDA and OLS and WLS

Understanding the multinomial-poisson transformation

Dealing With and Understanding Endogeneity

Jeffrey M. Wooldridge Michigan State University

Correlation and Simple Linear Regression

Longitudinal Data Analysis

Outline. Statistical inference for linear mixed models. One-way ANOVA in matrix-vector form

Lecture notes to Stock and Watson chapter 8

Problem Set 10: Panel Data

A brief introduction to mixed models

Introduction to Markov-switching regression models using the mswitch command

BIOSTATS 640 Spring 2018 Unit 2. Regression and Correlation (Part 1 of 2) STATA Users

Linear Modelling in Stata Session 6: Further Topics in Linear Modelling

PSC 8185: Multilevel Modeling Fitting Random Coefficient Binary Response Models in Stata

Empirical Application of Simple Regression (Chapter 2)

Section Least Squares Regression

8. Nonstandard standard error issues 8.1. The bias of robust standard errors

Appendix A. Numeric example of Dimick Staiger Estimator and comparison between Dimick-Staiger Estimator and Hierarchical Poisson Estimator

Model and Working Correlation Structure Selection in GEE Analyses of Longitudinal Data

Instantaneous geometric rates via generalized linear models

ECON3150/4150 Spring 2016

Transcription:

Nonlinear mixed-effects models using Stata Yulia Marchenko Executive Director of Statistics StataCorp LP 2017 German Stata Users Group meeting Yulia Marchenko (StataCorp) 1 / 48

Outline What is NLMEM? Simple NLMEM Residual covariance structures Heteroskedasticity Linear combinations and random coefficients Three-level model: CES production function Pharmacokinetic model Summary References Yulia Marchenko (StataCorp) 2 / 48

What is NLMEM? Jargon Nonlinear mixed-effects models (NLMEMs) mixed effects = fixed effects + random effects Nonlinear multilevel models Nonlinear hierarchical models Yulia Marchenko (StataCorp) 3 / 48

What is NLMEM? Applications NLMEMs are popular in studies of biological and agricultural growth processes, population pharmacokinetics, bioassays, and more. For example, NLMEMs have been used to model drug absorption in the body, intensity of earthquakes, and growth of plants. Yulia Marchenko (StataCorp) 4 / 48

What is NLMEM? Two ways of thinking: Nonlinear regression + REs Nonlinear regression: where ǫ N(0,σ 2 ). y = 1 β 1 +β 2 x +β 3 x 2 +ǫ Let, e.g., β 1 vary randomly across G groups: where u j N(0,σ 2 u ). β 1 = β 1j = b 1 +u j, j = 1,2,...,G Variance components: error variance σ 2 and between-group variance σ 2 u. Coefficients β 2 and β 3 can also be group-specific. Yulia Marchenko (StataCorp) 5 / 48

What is NLMEM? Two ways of thinking: Linear mixed-effects regression + nonlinearity Alternatively, consider a linear mixed-effects model: y ij = β 1 +β 2 x ij +β 3 x 2 ij +u j +ǫ ij where ǫ ij N(0,σ 2 ) and u j N(0,σ 2 u). In the nonlinear mixed-effects model y ij = 1 β 1 +β 2 x ij +β 3 x 2 ij +u j +ǫ ij all coefficients and random intercept u j enter nonlinearly. Yulia Marchenko (StataCorp) 6 / 48

Simple NLMEM Growth of orange trees. webuse orange (Growth of orange trees (Draper and Smith, 1998)). twoway connected circumf age, connect(l) title(growth of orange trees) Growth of orange trees Trunk circumference (mm) 0 200 0 500 1000 1500 Time since Dec 31, 1968 (days) Yulia Marchenko (StataCorp) 7 / 48

Simple NLMEM Nonlinear growth model Consider the following nonlinear growth model: circumf ij = where ǫ ij N(0,σ 2 ). β 1 1+exp { ( age ij β 2 ) /β3 } +ǫ ij β 1 is the average asymptotic trunk circumference of trees as age. β 2 estimates the age at which a tree attains half of β 1. β 3 represents the number of days it takes for a tree to grow from 50% to about 73% of its average asymptotic trunk circumference β 1. Yulia Marchenko (StataCorp) 8 / 48

Simple NLMEM Graphical representation of parameters Growth of orange trees Trunk circumference (mm) 0 87.5 131.25 175 200 0 118 484 700 1000 1372 1582 Time since Dec 31, 1968 (days) β 1 175 mm, β 2 700 days, and β 3 1,000 700 = 300 days. Notice that the variability between trees increases with age. Yulia Marchenko (StataCorp) 9 / 48

Simple NLMEM Two-level nonlinear growth model Let s incorporate the between-tree variability into the model. Consider the following two-level nonlinear growth model (Pinheiro and Bates 2000): circumf ij = β 1 +u 1j 1+exp { ( age ij β 2 ) /β3 } +ǫ ij where u 1j N(0,σ 2 u 1 ) and ǫ ij N(0,σ 2 ). Yulia Marchenko (StataCorp) 10 / 48

Simple NLMEM Two-level nonlinear growth model We use menl to fit the model.. menl circumf = ({b1}+{u1[tree]})/(1+exp(-(age-{b2})/{b3})) Mixed-effects ML nonlinear regression Number of obs = 35 Group variable: tree Number of groups = 5 Obs per group: min = 7 avg = 7.0 max = 7 Linearization log likelihood = -131.58458 circumf Coef. Std. Err. z P> z [95% Conf. Interval] /b1 191.049 16.15403 11.83 0.000 159.3877 222.7103 /b2 722.556 35.15082 20.56 0.000 653.6616 791.4503 /b3 344.1624 27.14739 12.68 0.000 290.9545 397.3703 Random-effects Parameters Estimate Std. Err. [95% Conf. Interval] tree: Identity var(u1) 991.1514 639.4636 279.8776 3510.038 var(residual) 61.56371 15.89568 37.11466 102.1184 Yulia Marchenko (StataCorp) 11 / 48

Simple NLMEM Two-level nonlinear growth model: All coefficients vary Similarly, we can let β 2 and β 3 vary across trees. We use a more convenient multistage formulation: where circumf ij = β 1j 1+exp { ( age ij β 2j ) /β3j } +ǫ ij β 1j = b 1 +u 1j β 2j = b 2 +u 2j β 3j = b 3 +u 3j and where u 1j N(0,σ 2 u 1 ), u 2j N(0,σ 2 u 2 ) and u 3j N(0,σ 2 u 3 ). Yulia Marchenko (StataCorp) 12 / 48

. menl circumf = ({beta1:})/(1+exp(-(age-{beta2:})/{beta3:})), > define(beta1:{b1}+{u1[tree]}) > define(beta2:{b2}+{u2[tree]}) > define(beta3:{b3}+{u3[tree]}) Mixed-effects ML nonlinear regression Number of obs = 35 Group variable: tree Number of groups = 5 Obs per group: min = 7 avg = 7.0 max = 7 Linearization log likelihood = -131.55076 beta1: {b1}+{u1[tree]} beta2: {b2}+{u2[tree]} beta3: {b3}+{u3[tree]} circumf Coef. Std. Err. z P> z [95% Conf. Interval] /b1 191.1332 15.96228 11.97 0.000 159.8477 222.4187 /b2 722.7144 34.94627 20.68 0.000 654.2209 791.2078 /b3 345.2863 27.70935 12.46 0.000 290.977 399.5956 Random-effects Parameters Estimate Std. Err. [95% Conf. Interval] tree: Independent var(u1) 970.67 665.4967 253.2113 3721.004 var(u2) 140.9707 2669.433 1.07e-14 1.85e+18 var(u3) 248.5962 1397.996.0040617 1.52e+07 var(residual) 59.43549 18.44102 32.35519 109.1812

Simple NLMEM Random-effects covariance structures With only five trees, the previous model is already too rich for these data. Otherwise, we could have considered a more complicated covariance structure for the random effects: σ 11 σ 12 σ 13 (u 1j,u 2j,u 3j ) MVN(0,Σ), Σ = σ 12 σ 22 σ 23 σ 13 σ 23 σ 33 Or assuming dependence only between some random effects such as u 1j and u 2j : And variations of the above. σ 11 σ 12 0 Σ = σ 12 σ 22 0 0 0 σ 33 Yulia Marchenko (StataCorp) 14 / 48

Simple NLMEM Random-effects covariance structures For example,. menl circumf = ({beta1:})/(1+exp(-(age-{beta2:})/{beta3:})), > define(beta1:{b1}+{u1[tree]}) > define(beta2:{b2}+{u2[tree]}) > define(beta3:{b3}+{u3[tree]}) > covariance(u1 U2 U3, unstructured) The above is also equivalent to:. menl...,... covariance(u*, unstructured) Or, assuming correlation between only U1 and U2. menl...,... covariance(u1 U2, unstructured) Yulia Marchenko (StataCorp) 15 / 48

Residual covariance structures menl provides flexible modeling of within-group error structures (or residual covariance structures). Use option resvariance() to model error heteroskedasticity as a linear, power, or exponential function of other covariates or of predicted values. Use option rescorrelation() to model the dependence of the within-group errors as, e.g., AR or MA processes. Combine resvariance() and rescorrelation() to build flexible residual covariance structures. Yulia Marchenko (StataCorp) 16 / 48

Heteroskedasticity Growth of soybean plants Continuing with growth processes, consider the growth of soybean plants. Variable weight records an average leaf weight per plant in grams. Variable time records the number of days after planting at which plants were weighed. The data are obtained from 48 plots.. webuse soybean (Growth of soybean plants (Davidian and Giltinan, 1995)) Yulia Marchenko (StataCorp) 17 / 48

Heteroskedasticity Two-level growth model Consider the following growth model: where weight ij = φ 1j 1+exp{ (time ij φ 2j )/φ 3j } +ǫ ij φ 1j = b 1 +u 1j φ 2j = b 2 +u 2j φ 3j = b 3 +u 3j and where (u 1j,u 2j,u 3j ) MVN(0,Σ) with σ 11 σ 12 σ 13 Σ = σ 12 σ 22 σ 23 σ 13 σ 23 σ 33 and ǫ ij N(0,σ 2 ). Yulia Marchenko (StataCorp) 18 / 48

Heteroskedasticity menl specification We use the following specification of menl:. menl weight = {phi1:}/(1+exp(-(time-{phi2:})/{phi3:})), > define(phi1: U1[plot], xb) > define(phi2: U2[plot], xb) > define(phi3: U3[plot], xb) > covariance(u1 U2 U3, unstructured) Option define(phi1: U1[plot], xb) is essentially a shortcut for define(phi1: {b1}+{u1[plot]}) The above shortcut is useful to specify linear combinations. Yulia Marchenko (StataCorp) 19 / 48

Heteroskedasticity menl: Regression coefficients Estimates of regression coefficients: Mixed-effects ML nonlinear regression Number of obs = 412 Group variable: plot Number of groups = 48 Obs per group: min = 8 avg = 8.6 max = 10 Linearization log likelihood = -739.83445 phi1: U1[plot], xb phi2: U2[plot], xb phi3: U3[plot], xb weight Coef. Std. Err. z P> z [95% Conf. Interval] phi1 phi2 phi3 _cons 19.25314.8031811 23.97 0.000 17.67893 20.82734 _cons 55.01999.7272491 75.65 0.000 53.59461 56.44537 _cons 8.403468.3152551 26.66 0.000 7.78558 9.021357 Yulia Marchenko (StataCorp) 20 / 48

Heteroskedasticity menl: Variance components Estimates of variance components: Random-effects Parameters Estimate Std. Err. [95% Conf. Interval] plot: Unstructured var(u1) 27.05081 6.776516 16.55561 44.19929 var(u2) 17.61605 5.317899 9.748766 31.83227 var(u3) 1.972036.9849825.7409021 5.248904 cov(u1,u2) 15.73304 5.413365 5.123042 26.34304 cov(u1,u3) 5.193819 2.165586.9493488 9.438289 cov(u2,u3) 5.649306 2.049458 1.632442 9.66617 var(residual) 1.262237.1111686 1.062119 1.50006 Store estimation results for later comparison. estimates store nohet Yulia Marchenko (StataCorp) 21 / 48

Heteroskedasticity Residuals-versus-fitted plot Residuals-versus-fitted plot. predict fitweight, yhat. predict res, residuals. scatter res fitweight Residuals 10 5 0 5 0 5 10 15 20 25 Mean prediction Yulia Marchenko (StataCorp) 22 / 48

Heteroskedasticity Error variability as a power function of the mean Davidian and Giltinan (1995) proposed to model heteroskedasticity (the error variance) in this example as a power function of the mean: Var(ǫ ij ) = σ 2 ( weight ij ) 2δ where weight ij denotes predicted mean weight values. The corresponding menl specification is. menl weight = {phi1:}/(1+exp(-(time-{phi2:})/{phi3:})), > define(phi1: U1[plot], xb) > define(phi2: U2[plot], xb) > define(phi3: U3[plot], xb) > covariance(u1 U2 U3, unstructured) > resvariance(power yhat, noconstant) Yulia Marchenko (StataCorp) 23 / 48

Heteroskedasticity menl, resvar(power): Regression coefficients Estimates of regression coefficients: Mixed-effects ML nonlinear regression Number of obs = 412 Group variable: plot Number of groups = 48 Obs per group: min = 8 avg = 8.6 max = 10 Linearization log likelihood = -357.55571 phi1: U1[plot], xb phi2: U2[plot], xb phi3: U3[plot], xb weight Coef. Std. Err. z P> z [95% Conf. Interval] phi1 phi2 phi3 _cons 16.9422.6060387 27.96 0.000 15.75439 18.13002 _cons 51.77667.462577 111.93 0.000 50.87004 52.68331 _cons 7.540957.0963157 78.29 0.000 7.352182 7.729732 Yulia Marchenko (StataCorp) 24 / 48

Heteroskedasticity menl, resvar(power): Variance components Estimates of variance components: plot: Unstructured var(u1) 11.47264 2.747485 7.174911 18.34469 var(u2) 3.014802 1.278198 1.313322 6.920641 var(u3).1017371.0442522.0433746.2386292 cov(u1,u2).5324789.131718.2743164.7906415 cov(u1,u3).9081537.2459849.4260321 1.390275 cov(u2,u3).340901.1091677.1269363.5548658 Residual variance: Power _yhat sigma2.0496757.0043236.0418849.0589156 delta.9376681.0253201.8880416.9872945 Store estimation results for comparison. estimates store het Yulia Marchenko (StataCorp) 25 / 48

Heteroskedasticity Model comparison Likelihood-ratio test:. lrtest het nohet Likelihood-ratio test LR chi2(1) = 764.56 (Assumption: nohet nested in het) Prob > chi2 = 0.0000 Information criteria:. estimates stats het nohet Akaike s information criterion and Bayesian information criterion Model Obs ll(null) ll(model) df AIC BIC het 412. -357.5557 11 737.1114 781.3427 nohet 412. -739.8344 10 1499.669 1539.879 Note: N=Obs used in calculating BIC; see [R] BIC note. A heteroskedastic model fits data better. Yulia Marchenko (StataCorp) 26 / 48

Linear combinations and random coefficients The actual objective of the soybean study was to compare the growth patterns of two genotypes of soybean plants in three types of growing seasons. Genotypes, variety: commercial variety F and experimental variety P Growing seasons, year: dry (1988), wet (1989), and normal (1990). Average leaf weight per plant (g) 0 10 20 30 F (Commercial) P (Experimental) 20 40 60 80 20 40 60 80 Time the sample was taken (days after planting) Growth pattern in wet growing season 1989 Yulia Marchenko (StataCorp) 27 / 48

Linear combinations and random coefficients We can include the main effects of genotypes and of years, and their interaction in the equation for the asymptotic rate: φ 1j = b 1 +β G G+β Y Y+ +u 1j menl specification:. menl weight = {phi1:}/(1+exp(-(time-{phi2:})/{phi3:})), > define(phi1: i.variety##i.year U1[plot]) > define(phi2: U2[plot], xb) > define(phi3: U3[plot], xb) > covariance(u1 U2 U3, unstructured) > resvariance(power yhat, noconstant) Yulia Marchenko (StataCorp) 28 / 48

Linear combinations and random coefficients We can also let the coefficients for, e.g., genotypes vary across plots: φ 1j = b 1 +β G G+β Y Y+ +u 1j +F f 1j +P p 1j where F and P are genotype indicators and f 1j N(0,σ 2 F ) and p 1j N(0,σ 2 P ). menl specification:. menl weight = {phi1:}/(1+exp(-(time-{phi2:})/{phi3:})), > define(phi1: i.variety##i.year U1[plot] 1.variety#F1[plot] 2.variety#P1[plot]) > define(phi2: U2[plot], xb) > define(phi3: U3[plot], xb) > covariance(u1 U2 U3, unstructured) > resvariance(power yhat, noconstant) The i. operator is not allowed with factor variables when specifying random coefficients because a distinct name is required for each random coefficient. Yulia Marchenko (StataCorp) 29 / 48

Three-level model: CES production function Constant elasticity of substitution (CES) production function is used in macroeconomic modeling to model the production process as a function of inputs such as capital and labor. It introduces and estimates the CES parameter, which makes it a flexible modeling tool. Elasticity of substitution (ES) measures how easy it is to substitute one input such as capital for another such as labor. And constant ES does not depend on input values. Other common production functions such as Cobb-Douglas and Leontief can be viewed as special cases of the CES production function. For example, Cobb-Douglas function assumes that ES is 1. Yulia Marchenko (StataCorp) 30 / 48

Three-level model: CES production function Consider fictional data on log(production) from the 50 U.S. states plus D.C. divided into 9 regions over the period of 1990 to 2017. We wish to fit the CES production function lnp ijt = β 0 1 ρ ln{δk ρ ijt +(1 δ)l ρ ijt }+ǫ ijt where ǫ ijt N(0,σ 2 ). lnp ijt, K ijt, and L ijt are log(production), capital, and labor of state j within region i in year t. Parameters: log-factor productivity β 0, share δ, and ρ is related to the elasticity of substitution σ = 1/(1+ρ). Yulia Marchenko (StataCorp) 31 / 48

Three-level model: CES production function We suspect that δ may be affected by regions and states-within-regions: δ = δ ij = δ 0 +u 1i +u 2ij where u 1i N(0,σ 2 u 1 ) and u 2ij N(0,σ 2 u 2 ). u 2 s are nested within u 1 s. Yulia Marchenko (StataCorp) 32 / 48

Three-level model: CES production function menl: Regression coefficients. menl lnprod = {b0}-1/{rho}*ln({delta:}*capital^(-{rho})+(1-{delta:})*labor^(-{rho})), > define(delta: {delta0} + {U1[region]} + {U2[region>state]}) Mixed-effects ML nonlinear regression Number of obs = 1,377 No. of Observations per Group Path Groups Minimum Average Maximum region 9 108 153.0 216 region>state 51 27 27.0 27 Linearization log likelihood = 1094.2223 delta: {delta0}+{u1[region]}+{u2[region>state]} lnprod Coef. Std. Err. z P> z [95% Conf. Interval] /b0 3.49166.0040189 868.82 0.000 3.483783 3.499537 /delta0.3439896.0490629 7.01 0.000.2478281.4401511 /rho 1.109318.0272072 40.77 0.000 1.055993 1.162644 Yulia Marchenko (StataCorp) 33 / 48

Three-level model: CES production function menl: Variance components Random-effects Parameters Estimate Std. Err. [95% Conf. Interval] region: Identity var(u1).0199948.0102071.0073517.0543809 region>state: Identity var(u2).0073329.001642.004728.0113729 var(residual).0102169.0003967.0094681.0110248 There is some variability between regions and states-within-regions in the estimates of the share parameter. Yulia Marchenko (StataCorp) 34 / 48

Three-level model: CES production function Predict region-specific share parameters We can predict the share parameter for each region:. predict (delta = {delta:}), relevel(region). list region delta if region[_n]!=region[_n-1], sep(0) region delta 1. New England.2699136 163. Mid Atlantic.1453616 271. E North Central.6366224 406. W North Central.3761043 595. South Atlantic.3879336 811. E South Central.344411 919. W South Central.17091 1027. Mountain.4102365 1243. Pacific.3544133 Yulia Marchenko (StataCorp) 35 / 48

Three-level model: CES production function Estimate ES We can use nlcom to estimate the ES:. nlcom (sigma: 1/(1+_b[/rho])) sigma: 1/(1+_b[/rho]) lnprod Coef. Std. Err. z P> z [95% Conf. Interval] sigma.4740868.006115 77.53 0.000.4621015.4860721 The estimated ES is 0.47, which is less than one meaning that the capital and labor are not very good substitutes in this example. If the labor price increases, substituting capital for labor will not offset the increase in the total expenditure on labor. Yulia Marchenko (StataCorp) 36 / 48

Pharmacokinetic model Pharmacokinetics (PKs) studies the distribution of drugs within the body and is often referred to as the study of what the body does with a drug. It models drug output based on drug input by summarizing concentration-time measurements, while accounting for patient-specific characteristics. Yulia Marchenko (StataCorp) 37 / 48

Pharmacokinetic model PK study of theophylline Consider data on the antiasthmatic agent theophylline (Boeckmann, Sheiner, and Beal [1994] 2011). The drug was administered orally to 12 subjects with the dosage (mg/kg) given on a per weight basis. Serum concentrations (in mg/l) were obtained at 11 time points per subject over 25 hours following administration. Yulia Marchenko (StataCorp) 38 / 48

Pharmacokinetic model PK study of theophylline Concentration-time profiles of 12 subjects:. webuse theoph (Theophylline kinetics (Boeckmann et al., [1994] 2011)). twoway connected conc time, connect(l) Theophylline concentration (mg/l) 0 5 10 15 0 5 10 15 20 25 Time since drug administration (hr) Yulia Marchenko (StataCorp) 39 / 48

Pharmacokinetic model One-compartment model The concentration rises rapidly initially and then decays exponentially. In PKs, such pattern is often described by a so-called one-compartment open model with first-order absorption and elimination. (Body is viewed as one blood compartment.) This model is used for drugs that distribute relatively rapidly throughout the body, which is a reasonable assumption for the kinetics of theophylline after oral administration. Yulia Marchenko (StataCorp) 40 / 48

Pharmacokinetic model One-compartment model One-compartment open model for theophylline kinetics: conc ij = dose jk e k aj Cl j ( kaj k e ) { exp( k e time ij ) exp ( k aj time ij )} +ǫij for i = 1,...,11 and j = 1,...,12. Parameters: elimination rate constant k e, and, for each subject j, absorption rate constant k aj and clearance Cl j. Yulia Marchenko (StataCorp) 41 / 48

Pharmacokinetic model One-compartment model Elimination rate constant describes the rate at which a drug is removed from the body. It is defined as the fraction of drug in the body eliminated per unit time. Absorption rate constant describes the rate at which a drug is absorbed by the body. Clearance measures the rate at which a drug is cleared from the plasma. It is defined as the volume of plasma cleared of drug per unit time. Yulia Marchenko (StataCorp) 42 / 48

Pharmacokinetic model One-compartment model All parameters must be positive, and clearance and absorption rate constant are allowed to vary among subjects: Cl j = exp(β 0 +u 0j ) k aj = exp(β 1 +u 1j ) k e = exp(β 2 ) where u 0j N(0,σ 2 u 0 ) and u 1j N(0,σ 2 u 1 ). Heteroskedasticity, often present in PK data, is modeled using the power function plus a constant. Var(ǫ ij ) = σ 2 {(ĉonc ij ) δ +c} 2 Adding a constant avoids the variance of zero at time = 0, because the concentration is zero at that time. Yulia Marchenko (StataCorp) 43 / 48

Pharmacokinetic model menl: Coefficients. menl conc =(dose*{ke:}*{ka:}/({cl:}*({ka:}-{ke:})))*(exp(-{ke:}*time)-exp(-{ka:}*time)), > define(cl: exp({b0}+{u0[subject]})) > define(ka: exp({b1}+{u1[subject]})) > define(ke: exp({b2})) > resvariance(power _yhat) reml Mixed-effects REML nonlinear regression Number of obs = 132 Group variable: subject Number of groups = 12 Obs per group: min = 11 avg = 11.0 max = 11 Linear. log restricted-likelihood = -172.44384 cl: exp({b0}+{u0[subject]}) ka: exp({b1}+{u1[subject]}) ke: exp({b2}) conc Coef. Std. Err. z P> z [95% Conf. Interval] /b0-3.227295.0619113-52.13 0.000-3.348639-3.105951 /b1.4354519.2072387 2.10 0.036.0292716.8416322 /b2-2.453743.0517991-47.37 0.000-2.555267-2.352218 Yulia Marchenko (StataCorp) 44 / 48

Pharmacokinetic model menl: Variance components Random-effects Parameters Estimate Std. Err. [95% Conf. Interval] subject: Independent var(u0).0316416.014531.0128634.0778326 var(u1).4500585.2228206.1705476 1.187661 Residual variance: Power _yhat sigma2.1015759.086535.0191263.5394491 delta.3106636.2466547 -.1727707.7940979 _cons.7150935.3745256.2561837 1.996063 Yulia Marchenko (StataCorp) 45 / 48

Pharmacokinetic model menl specification In the previous menl model, we used restricted maximum likelihood estimation (REML) via option reml instead of the default maximum likelihood (ML) estimation to account for a moderate number of subjects. We specified nonlinear functions of model parameters in the define() options. Yulia Marchenko (StataCorp) 46 / 48

Summary menl fits NLMEMs; see [ME] menl. menl implements the Lindstrom Bates method, which is based on the linearization of the nonlinear mean function with respect to fixed and random effects. menl supports ML and REML estimation and provides flexible random-effects and residual covariance structures. menl supports single-stage and multistage specifications. You can predict random effects and their standard errors, group-specific nonlinear parameters, and more after estimation; see [ME] menl postestimation. NLMEMs are known to be sensitive to initial values. menl provides default, but for some models you may need to specify your own. Use option initial(). NLMEMs are known to have difficulty converging or converging to a local maximum. Trying different initial values may help. Yulia Marchenko (StataCorp) 47 / 48

References Boeckmann, A. J., L. B. Sheiner, and S. L. Beal. [1994] 2011. NONMEM Users Guide, Part V: Introductory Guide. San Francisco: Regents of the University of California. https://nonmem.iconplc.com/nonmem720/guides/v.pdf. Davidian, M., and D. M. Giltinan. 1995. Nonlinear Models for Repeated Measurement Data. Boca Raton, FL: Chapman & Hall/CRC. Pinheiro, J. C., and D. M. Bates. 2000. Mixed-Effects Models in S and S-PLUS. New York: Springer. Yulia Marchenko (StataCorp) 48 / 48