Skip to content
Prev 11367 / 20628 Next

Simple: don't understand lmer formula and slopes

Here's a very simple mis-understanding of formula specification in lme4 - lmer
(Thanks to Ben and this group for help with a more fundamental question),

How does one specify slopes in lmer?
(This illustrates the essentials of a more complex problem.  I know that
I could simply using  a rescaling  of the y variables with estimated 
standard deviations) 

(Again) I have a single control tracer variable, and a whole set
of dependent variables with varying slopes.  The way I am specifying
the problem, I get no random effect for a, the slope, as it should
depend on species.

The lmer formal

 test.1.lmer = lmer( ylong ~ xlong + (xlong - 1 | species) + 1 , data=trial.dat)  

I provide an example below suggesting that I have built the 
data frame correctly, I think.  

# How this was run ? 
# Macintosh 10.8.5
#  R 2.15.2 GUI 1.53 Leopard build 64-bit (6335)
# lme4  version 0.999999-0


Bob Chatfield
Robert.B.Chatfield at nasa.gov
Earth Science Division, NASA (Ames), Mountain View, CA 94035 USA


 #  Test an lmer with a variable slope ... specification of random effect
+   for ( j in 1:10) y[i,j] = a[j] * xd[i]
+ }
Linear mixed model fit by REML 
Formula: ylong ~ xlong + (xlong - 1 | species) + 1 
   Data: trial.dat 
  AIC  BIC logLik deviance REMLdev
 3896 3916  -1944     3877    3888
Random effects:
 Groups   Name  Variance Std.Dev.
 species  xlong 0.000    0.0000  
 Residual       2.833    1.6832  
Number of obs: 1000, groups: species, 10

Fixed effects:
            Estimate Std. Error t value
(Intercept) -0.96101    0.32930  -2.918
xlong        0.09945    0.01279   7.775

Correlation of Fixed Effects:
      (Intr)
xlong -0.987
standard deviation of original idealized data and of random effects
[1] 0.0821322
[1] 0
#  Example of the dataset
xlong     ylong  species
1 23.60230 0.7164348 species1
2 27.70397 0.9228682 species2
3 22.25050 0.5650994 species3
      xlong     ylong   species
9  29.75010 0.8829359  species9
10 24.02824 0.6977277 species10
xlong     ylong  species
11 27.56634 0.6923857 species1
12 21.81768 0.5428702 species2
13 33.02031 0.9520825 species3
xlong     ylong  species
101 23.60230 0.3621467 species1
102 27.70397 0.4328762 species2
103 22.25050 0.3848661 species3
xlong     ylong  species
111 27.56634 0.5934288 species1
112 21.81768 0.3077124 species2
113 33.02031 0.8165563 species3
Message-ID: <D36BA9EB-7BAF-4B7E-ADDE-39A31BFD86FF@alumni.rice.edu>
In-Reply-To: <mailman.1863.1391206366.4563.r-sig-mixed-models@r-project.org>