LMER: Error in model.frame.default… variable lengths differ (Without NA's)
<p>I've looked through a couple of other questions similar to mine, and the <a href="https://stackoverflow.com/questions/34032796/error-in-model-frame-default-variable-lengths-differ-without-nas">one most relevant</a> wasn't answered, while the others all came down to missing data and data lengths. </p>

<p>I am trying to model compositional dissmiliarity after a disturbance through time. I sampled at discrete timepoints: 0, 3, 6, and 9 months. I am interested in the fixed effect of time on recovery, but at each point, season and other environmental variables changed and led to differing variability between 0, 3, 6, and 9 months, as reflected in the residuals in a normal linear model.</p>

<p>To incorporate the random variance differences, while still including the fixed effect, I ran this model using nlme:</p>

<pre><code>mod1 &lt;- lme(Resp ~ Temp + Time, random = (~1 | Dummy), 
           weights = varIdent(form = ~1 | Time.f), data = recovery)
</code></pre>

<p>where Resp is my dissimilarity; Temp is a disturbance intensity (temperature), Time is 0, 3, 6, or 9 months; Dummy is a dummy random intercept (here just a vector filled with "D"); and Time.f is Time converted to a factor. I have 60 data points, 15 in each of the sampling times.</p>

<p>This ran fine. I want to extract conditional-R2 values, however, so tried it in lme4 using the lmer function:</p>

<pre><code>mod2 &lt;- lmer(Resp ~ Temp + Time + (1 | Dummy), weights = varIdent(form = ~1 | Time.f), data = recovery)
</code></pre>

<p>To run lmer, the dummy variables needs at least two categories, so I changed the first value to a "C" for the sake of trying to run it (see data below). I get the error:</p>

<blockquote>
  <p>Error in model.frame.default(data = recovery, weights = varIdent(form
  = ~1 |  :    variable lengths differ (found for '(weights)')</p>
</blockquote>

<p>I'm new to variance structures and I'm not sure if it's a problem in the fundamental structure of this model. In <a href="https://stats.stackexchange.com/questions/163445/problems-when-adding-a-variance-structure-into-a-glmm">this</a> question, Alain Zuur implied that it is incorrect to use varIdent with binomial models, but I'm running this as a Gaussian (though I've also considered a Gamma).</p>

<p>Here is my data:</p>

<pre><code>recovery &lt;- data.frame(Resp = c(0.451342292, 0.518351745, 0.469268304,
 0.472750101, 0.498935251, 0.508081111, 0.490904624, 0.446764424, 0.536142651, 
0.707955998, 0.403299657, 0.495046237, 0.630677117, 0.630420366, 0.511555117, 
0.460977339, 0.313873121, 0.442930551, 0.504933216, 0.266894217, 0.461051448, 
0.406211728, 0.500511806, 0.561122944, 0.490329006, 0.565621645, 0.612263178, 
0.380895252, 0.358544132, 0.40361619, 0.296853964, 0.364686954, 0.299307408, 
0.349446067, 0.288854758, 0.292265106, 0.37207794, 0.300760264, 0.387906769, 
0.376203541, 0.433080559, 0.371204216, 0.341724067, 0.357920013, 0.396109361, 
0.372228087, 0.282725524, 0.317789872, 0.244435419, 0.277035603, 0.272620508, 
0.378162153, 0.267645891, 0.306363131, 0.353826191, 0.230613947, 0.445865256, 
0.321665269, 0.324131469, 0.266275828), Temp = c(25.4, 22.9, 22.5, 20.5, 29, 
25.2, 40.5, 23.9, 28.1, 33.2, 43, 34.5, 38.5, 42.4, 31.3, 27, 28.6, 22.4, 24.2, 
21.4, 22.6, 36.6, 28.8, 24.9, 28.6, 41.2, 21.5, 33, 39.8, 30.8, 22.2, 29.5, 
25.9, 26.6, 22.8, 27.7, 24.9, 22.9, 27.6, 29, 26.7, 29.4, 43.5, 28.8, 23.1, 
26.1, 25.7, 23.4, 29.4, 29.6, 23.7, 26.6, 31.7, 28.3, 28.5, 20.5, 23, 35.3, 
42.5, 26.8), Time = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9), Dummy = c("C", "D", "D", "D", 
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", 
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", 
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", 
"D", "D", "D", "D", "D", "D", "D", "D"), Time.f = c("a", "a", "a", "a", "a", 
"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b",
 "b", "b", "b", "b", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "c", 
"c", "c", "c", "c", "c", "c", "c", "c", "c", "d", "d", "d", "d", "d", "d", "d", 
"d", "d", "d", "d", "d", "d", "d", "d"))
</code></pre>

<p>Like I said, I'm new to this and to posting. Any advice or suggestions would be wonderful!</p>