Skip to content

mixed models

4 messages · Jeff Newmiller, James Henson, David Winsemius

#
Please keep the mailing list in the loop by using reply-all.

I don't think there is a requirement that the number of levels is equal, but there may be problems if you don't have the minimum number of records corresponding to each combination of levels specified in your model. 

You can change the csv extension to txt and attach for the mailing list. Or, better yet, you can use the dput function to embed the data directly in your sample code. 

Also,  please learn to post plain text email to avoid corruption of R code by the HTML formatting.
1 day later
#
Greetings Jeff,
You are correct that the unequal number of levels is not the problem.
I revised the data frame so that the number of levels was equal and
the same error message occurred.  The code is below, and the
Eboni2.txt file is attached. This problem baffles me.  I appreciate
any help.
Best regards,
James
 Eboni2 <- read.csv("Eboni2.csv", header = TRUE)

library("nlme")

str(Eboni2)

head(Eboni2)

model1 <- lme(preDawn ~ Irrigation, random=~season_order|treeNo, data=Eboni2)

On Wed, May 25, 2016 at 6:23 PM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us> wrote:
#
I downloaded the attached file to your first posting that was called a "csv" file but it was tab-separated (as could be clearly seen with the str output, so would only load properly with read.delim rather than read.csv. Running then with the lme call, it produced this message
Error in na.fail.default(list(season_order = c(5L, 5L, 5L, 5L, 5L, 5L,  : 
  missing values in object

And looking at the str result made it clear that there were many NA's in the file.
number Location   Season season_order Month  treeID treeNo preDawn midday
1      1      UCC November            5   Nov UCCLO 1     60     1.4    1.3
2      2      UCC November            5   Nov UCCLO 2     72     1.2    1.3
3      3      UCC November            5   Nov UCCLO 3     78     1.1    1.2
4      4      UCC November            5   Nov UCCLO 4     79     1.1    2.1
5      5      UCC November            5   Nov UCCLO 5     80     1.4    1.3
6      6      UCC November            5   Nov UCCLO 6     81     0.6    1.8
  Irrigation Pnet        Gs        E      WUE d15N   d13C Nper  Cper include2
1          N    9 0.2907004 3.766207 2.389672   NA     NA   NA    NA       no
2          N   11 0.3262582 3.120574 3.524993   NA     NA   NA    NA       no
3          N    8 0.2870957 1.693821 4.723050 3.00 -27.44 2.12 52.12      yes
4          N   10 0.2475180 1.839343 5.436724 3.61 -29.50 1.42 51.97      yes
5          N   13 0.3009228 3.082278 4.217660   NA     NA   NA    NA       no
6          N   17 0.3487337 2.534550 6.707304 2.79 -30.50 1.49 49.94      yes

And even more importantly, there was one NA in your outcome variable:
[1] 0
[1] 1

So after restricting to complete.cases, I then formed the hypothesis that you reversed the order of the variables in the formula for the random parameter:
1  2  3  4  5 
83 83 83 83 83
[1] 415

So it seemed unreasonable to have a "grouping" on variable with only one item per group.
Linear mixed-effects model fit by REML
  Data: Eboni2[complete.cases(Eboni2[, c("preDawn", "Irrigation", "season_order",      "treeNo")]), ] 
  Log-restricted-likelihood: -183.4708
  Fixed: preDawn ~ Irrigation 
(Intercept) IrrigationY 
 1.04520145 -0.06037706 

Random effects:
 Formula: ~treeNo | season_order
 Structure: General positive-definite, Log-Cholesky parametrization
            StdDev      Corr  
(Intercept) 0.140239324 (Intr)
treeNo      0.003766019 -0.725
Residual    0.365678898       

Number of Observations: 414
Number of Groups: 5 

(Warning, I'm not a frequent user of this package or any of the mixed effects packages.)



Just to correct some misinformation that appeared earlier: You can attach "csv" or "tsv" files as long as you name them with an .txt extension so the mail clients and servers consider them to be MIME-text.
#
Greetings David,
I am new to R and neglected to check vigorously for missing values.
Apologize for posting without checking and finding the one NA.

I appreciate your help.
Thanks.
James F. Henson
On Fri, May 27, 2016 at 1:49 PM, David Winsemius <dwinsemius at comcast.net> wrote: