[R-sig-ME] Formula and Start-values for simplest "non-linear" mixed model - nlmer (nlme??, lmer ?)

Robert Chatfield chatfield at alumni.rice.edu
Sun Jan 12 23:30:33 CET 2014


I'm trying to solve simple mixed-effects problem that seems to require nlmer() from lme4
or nlme() from nlme ...  
(Apologies if this is a duplicate post:  I've checked as best I can...RC)

The problem is simply one with a random x-intercept
when we have have a set of dependent-concentrations that all depend on a single
tracer-concentration,
... but each dependent-concentration (chemical species.type) has a random slope dependence on the tracer-concentration
  (for all measurement instances)
... and each measurement instance has its own random baseline-concentration (at which the tracer-concentrations
also become  0 ... with some small error) 

So the problem is to find the random baseline-concentration for instances (id)  "j"
and the random slopes for each dependent-concentration (species.type)   "i" 
i.e. ... using plotmath expression notation ...
expression(y[ ij ] == a[ i ] *(  x[j] + {x^o}[ j ]  )

Since the a[ i ] must apply to both the x and to x^o , I guess that one must use 
nlmer (or nlme:  I am still confused by the syntax of nlme() )

first.nlmer = nlmer( y ~ a*(x+ x.nought) ~ a|species.type + x.nought | id,
  start=start.vals.1,  data=good.est.merge.long.dat  )

In this case, the y are repeated many times in a "long" list as specified for lmer or nlmer, one time each
for each species.type, so we formally have a long vector as a regression
function of a long vector (n of species.types   times   number of instances


(NOTE: It does not seem to work to look for the usual  y intercepts by running the problem "backwards"
as a multiple regression of a single tracer-variable versus many species.type concentrations
(y[ ij ] == a[ i ] *( + {x^o}[ j ]  
x[j]  = alpha(i) * y[ij] + x^o[j]  
since there is an "exact" but trivial solution x^0[j] = x[j]  ... 

Two questions ... 
======================================================================================
Mostly: (1)
I could not convince nlmer that the the starting values were vectors ... perhaps this is
elementary R
start.vals.1 = c(a=aij, x.nought=x.nought.lin)    (SEE VALUES BELOW)
#   start.vals.1 = cbind(a=aij, x.nought=x.nought.lin)  # tried this -- does not work

where this calculation for aij
len.lon.dat = dim(good.est.merge.long.dat)[1]   #  repeats once for each species.type
len.lon.dat = dim(good.est.merge.long.dat)[1]   #  repeats once for each species.type 

aij = vector(mode="numeric",length= len.lon.dat)
#  The name aij is given since
for ( i in 1:len.lon.dat ) {
spec.type.nm = as.character(species.type[i])
aij[i] = (ranef(try.spec.2.lmer,drop=T)[["species.type"]])[[spec.type.nm]]
}

I am wondering if the names are not being passed along correctly ...
> names(start.vals.1)[1]
[1] "a1"
> start.vals.1[1]
       a1 
0.002266363 
> start.vals.1[1802]
    a1802 
-0.02694557 
> start.vals.1[1803]
x.nought1 
-0.3141149 
> start.vals.1[3604]
x.nought1802 
-0.1204595 
Could this naming be confusing to nlmer?  The start values must be named.

Now I have made a similar lmer() formula work ... unfortunately it gives only y-intercepts
and there are somewhat unsatisfactory approximations to make this give me x-intercepts
======================================================================================
ALSO (2) 
Is this the correct last portion of the three-part formula (there are no examples)
~ a|species.type + x.nought | id


*** (I am happy to use nlme() if someone could help me with the syntax, or tell me how
to formulate this as a linear model with imposed conditions.

Computer details:  Two Macintoshes running OS X 10.5.8 
"R version 2.15.3 (2013-03-01)"
R 2.15.3 GUI   and most recent nlmer from lme4 0.999999-0

THANKS TO ALL ..

Robert Chatfield
Earth Science Division
NASA Ames Research Center  650-604-5490
======================================================================================
POSTSCRIPT ... to convince you that the basic approach works with lmer for linear formulas
(PS: the somewhat unsatisfactory approximation that depends on normalizing all the 
y and doing a bit of geometery
ttry.spec.2.lmer = lmer( y ~ x  + (x- 1 | species.type) + ( 1 | id) + 1 , data=good.est.merge.long.dat )

This solves just fine 
here
id  is the sample or "instance" id , goes  for j = 1:106
species.type is a factor construct that describes each species
  (in detail species.type describes each species for each burning-type ... for example, Flaming or Smoldering or ..
   but this detail is not important ... just treat this as if we had 68 species.type categories  .... i= 1::68

This gives some y intercepts (not really wanted) from which I obtain some
very approximate x intercepts  ... this is not fully described ...
x_approx = x_first_guess + 
       ( fixef(try.spec.2.lmer)[["(Intercept)"]]   + ranef(try.spec.2.lmer,drop=T)$id ) / ( fixef(try.spec.2.lmer)[["x"]]  )
======================================================================================



More information about the R-sig-mixed-models mailing list