stan_nlmer.Rd
Bayesian inference for NLMMs with groupspecific coefficients that have unknown covariance matrices with flexible priors.
stan_nlmer(formula, data = NULL, subset, weights, na.action, offset, contrasts = NULL, ..., prior = normal(), prior_aux = exponential(), prior_covariance = decov(), prior_PD = FALSE, algorithm = c("sampling", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE, sparse = FALSE)
formula, data  Same as for 


subset, weights, offset  Same as 

na.action, contrasts  Same as 

...  Further arguments passed to the function in the rstan
package ( 

prior  The prior distribution for the regression coefficients.
See the priors help page for details on the families and
how to specify the arguments for all of the functions in the table above.
To omit a prior i.e., to use a flat (improper) uniform prior
Note: Unless 

prior_aux  The prior distribution for the "auxiliary" parameter (if
applicable). The "auxiliary" parameter refers to a different parameter
depending on the


prior_covariance  Cannot be 

prior_PD  A logical scalar (defaulting to 

algorithm  A string (possibly abbreviated) indicating the
estimation approach to use. Can be 

adapt_delta  Only relevant if 

QR  A logical scalar defaulting to 

sparse  A logical scalar (defaulting to 
A stanreg object is returned
for stan_nlmer
.
The stan_nlmer
function is similar in syntax to
nlmer
but rather than performing (approximate) maximum
marginal likelihood estimation, Bayesian estimation is by default performed
via MCMC. The Bayesian model adds independent priors on the "coefficients"
 which are really intercepts  in the same way as
stan_nlmer
and priors on the terms of a decomposition of the
covariance matrices of the groupspecific parameters. See
priors
for more information about the priors.
The supported transformation functions are limited to the named
"selfstarting" functions in the stats library:
SSasymp
, SSasympOff
,
SSasympOrig
, SSbiexp
,
SSfol
, SSfpl
,
SSgompertz
, SSlogis
,
SSmicmen
, and SSweibull
.
stanregmethods
and
nlmer
.
The vignette for stan_glmer
, which also discusses
stan_nlmer
models. http://mcstan.org/rstanarm/articles/
# \donttest{ data("Orange", package = "datasets") Orange$circumference < Orange$circumference / 100 Orange$age < Orange$age / 100 fit < stan_nlmer( circumference ~ SSlogis(age, Asym, xmid, scal) ~ AsymTree, data = Orange, # for speed only chains = 1, iter = 1000 )#> #> SAMPLING FOR MODEL 'continuous' NOW (CHAIN 1). #> Chain 1: #> Chain 1: Gradient evaluation took 0.00011 seconds #> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 1.1 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: #> Chain 1: Iteration: 1 / 1000 [ 0%] (Warmup) #> Chain 1: Iteration: 100 / 1000 [ 10%] (Warmup) #> Chain 1: Iteration: 200 / 1000 [ 20%] (Warmup) #> Chain 1: Iteration: 300 / 1000 [ 30%] (Warmup) #> Chain 1: Iteration: 400 / 1000 [ 40%] (Warmup) #> Chain 1: Iteration: 500 / 1000 [ 50%] (Warmup) #> Chain 1: Iteration: 501 / 1000 [ 50%] (Sampling) #> Chain 1: Iteration: 600 / 1000 [ 60%] (Sampling) #> Chain 1: Iteration: 700 / 1000 [ 70%] (Sampling) #> Chain 1: Iteration: 800 / 1000 [ 80%] (Sampling) #> Chain 1: Iteration: 900 / 1000 [ 90%] (Sampling) #> Chain 1: Iteration: 1000 / 1000 [100%] (Sampling) #> Chain 1: #> Chain 1: Elapsed Time: 0.846004 seconds (Warmup) #> Chain 1: 0.481843 seconds (Sampling) #> Chain 1: 1.32785 seconds (Total) #> Chain 1:print(fit)#> stan_nlmer #> family: gaussian [inv_SSlogis] #> formula: circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym  Tree #> observations: 35 #>  #> Median MAD_SD #> Asym 1.8 0.1 #> xmid 6.8 0.3 #> scal 3.2 0.2 #> #> Auxiliary parameter(s): #> Median MAD_SD #> sigma 0.1 0.0 #> #> Error terms: #> Groups Name Std.Dev. #> Tree Asym 0.315 #> Residual 0.092 #> Num. levels: Tree 5 #> #>  #> * For help interpreting the printed output see ?print.stanreg #> * For info on the priors used see ?prior_summary.stanregposterior_interval(fit)#> 5% 95% #> Asym 1.59269650 2.08285981 #> xmid 6.21023369 7.34193463 #> scal 2.79907165 3.66679594 #> b[Asym Tree:3] 0.57820072 0.07150115 #> b[Asym Tree:1] 0.49676087 0.01001252 #> b[Asym Tree:5] 0.27085517 0.20674935 #> b[Asym Tree:2] 0.08149556 0.56722637 #> b[Asym Tree:4] 0.16846725 0.63049656 #> sigma 0.07370698 0.11723286 #> Sigma[Tree:Asym,Asym] 0.03310061 0.22896389# }