# Specific results from mixed models fit with lme

I feel like this is a simple and stupid question but I cannot seem to find an answer that works.

How do I calculate specific statistical results in a mixed model analysis with 'lme()'?

Data:

year Plot SeedingDate Rep Treat CalDays
2017 11 Sep 1 Controlled 161
2017 12 Sep 1 Deep Fraze 35
2017 13 Sep 1 Verticut 161
2017 14 Sep 1 Less Fraze 84
2017 15 Sep 1 Scalped 63
2017 21 Sep 2 Less Fraze 63
2017 22 Sep 2 Deep Fraze 49
2017 23 Sep 2 Verticut 84
2017 24 Sep 2 Scalped 84
2017 25 Sep 2 Controlled 84
2017 31 Sep 3 Scalped 35

Code:
setwd("/Users/mc1499/Documents/Thesis Measurements/2017 & 2018 Fall/GDD Rye")
block<-as.factor(dat\$Rep)
trt<-as.factor(dat\$Treat)
seeddate<-as.factor(dat\$SeedingDate)
yr<-as.factor(dat\$year)
str(dat)

DIA0WAS<-lme(CalDays ~ Treat*SeedingDate,random = ~1|year/Rep,data=dat)
anova(DIA0WAS)
predictmeans(DIA0WAS,"Treat:SeedingDate",pairwise=TRUE)

I am trying to graph my data and the programs needs either % critical value or standard deviation, what code can I use to get that from my data?

Could you please turn this into a minimal REPRoducible EXample (reprex) for your issue?

This is what I get if I try to run your code as a reprex

``````dat <- data.frame(stringsAsFactors=FALSE,
year = c(2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017,
2017),
Plot = c(11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31),
SeedingDate = c("Sep", "Sep", "Sep", "Sep", "Sep", "Sep", "Sep", "Sep",
"Sep", "Sep", "Sep"),
Rep = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3),
Treat = c("Controlled", "Deep Fraze", "Verticut", "Less Fraze",
"Scalped", "Less Fraze", "Deep Fraze", "Verticut",
"Scalped", "Controlled", "Scalped"),
CalDays = c(161, 35, 161, 84, 63, 63, 49, 84, 84, 84, 35)
)

library(nlme)

block<-as.factor(dat\$Rep)
trt<-as.factor(dat\$Treat)
seeddate<-as.factor(dat\$SeedingDate)
yr<-as.factor(dat\$year)
str(dat)
#> 'data.frame':    11 obs. of  6 variables:
#>  \$ year       : num  2017 2017 2017 2017 2017 ...
#>  \$ Plot       : num  11 12 13 14 15 21 22 23 24 25 ...
#>  \$ SeedingDate: chr  "Sep" "Sep" "Sep" "Sep" ...
#>  \$ Rep        : num  1 1 1 1 1 2 2 2 2 2 ...
#>  \$ Treat      : chr  "Controlled" "Deep Fraze" "Verticut" "Less Fraze" ...
#>  \$ CalDays    : num  161 35 161 84 63 63 49 84 84 84 ...

DIA0WAS<-lme(CalDays ~ Treat*SeedingDate, random = ~1|year/Rep, data=dat)
#> Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]): contrasts can be applied only to factors with 2 or more levels
anova(DIA0WAS)
#> Error in anova(DIA0WAS): objeto 'DIA0WAS' no encontrado
predictmeans(DIA0WAS,"Treat:SeedingDate",pairwise=TRUE)
#> Error in predictmeans(DIA0WAS, "Treat:SeedingDate", pairwise = TRUE): no se pudo encontrar la función "predictmeans"
``````

Created on 2019-06-21 by the reprex package (v0.3.0)

Okay, I am not sure if this it correct because it keeps giving me an error for my "lme" and anova but that is not the case. Those are running fine I am just trying to find a code to get %CV or standard deviation.

setwd("/Users/mc1499/Documents/Thesis Measurements/2017 & 2018 Fall/GDD Rye")
block<-as.factor(dat\$Rep)
trt<-as.factor(dat\$Treat)
seeddate<-as.factor(dat\$SeedingDate)
yr<-as.factor(dat\$year)

DIA0WAS<-lme(CalDays ~ Treat*SeedingDate,random = ~1|year/Rep,data=dat)
#> Error in lme(CalDays ~ Treat * SeedingDate, random = ~1 | year/Rep, data = dat): could not find function "lme"
anova(DIA0WAS)
#> Error in anova(DIA0WAS): object 'DIA0WAS' not found

You are getting those erros because you are not including library calls and sample data in your example, if you want to make a proper reprex, please read the content of the link I gave you before and try to follow along.

I am sorry. I did, I just didn't catch that.

library(nlme)
setwd("/Users/mc1499/Documents/Thesis Measurements/2017 & 2018 Fall/GDD Rye")
block<-as.factor(dat\$Rep)
trt<-as.factor(dat\$Treat)
seeddate<-as.factor(dat\$SeedingDate)
yr<-as.factor(dat\$year)

DIA0WAS<-lme(CalDays ~ Treat*SeedingDate,random = ~1|year/Rep,data=dat)
anova(DIA0WAS)
#> numDF denDF F-value p-value
#> (Intercept) 1 98 203.00155 <.0001
#> Treat 4 98 36.74186 <.0001
#> SeedingDate 2 98 24.95223 <.0001
#> Treat:SeedingDate 8 98 5.09245 <.0001

I feel like this is a simple and stupid question but I cannot seem to find an answer that works.

How do I calculate specific statistical results in a mixed model analysis with 'lme()'?

Data:

year Plot SeedingDate Rep Treat CalDays
2017 11 Sep 1 Controlled 161
2017 12 Sep 1 Deep Fraze 35
2017 13 Sep 1 Verticut 161
2017 14 Sep 1 Less Fraze 84
2017 15 Sep 1 Scalped 63
2017 21 Sep 2 Less Fraze 63
2017 22 Sep 2 Deep Fraze 49
2017 23 Sep 2 Verticut 84
2017 24 Sep 2 Scalped 84
2017 25 Sep 2 Controlled 84
2017 31 Sep 3 Scalped 35

Code:
library(nlme)
setwd("/Users/mc1499/Documents/Thesis Measurements/2017 & 2018 Fall/GDD Rye")
block<-as.factor(dat\$Rep)
trt<-as.factor(dat\$Treat)
seeddate<-as.factor(dat\$SeedingDate)
yr<-as.factor(dat\$year)

DIA0WAS<-lme(CalDays ~ Treat*SeedingDate,random = ~1|year/Rep,data=dat)
anova(DIA0WAS)

I am trying to graph my data and the program needs either % critical value or standard deviation, but anova does not give me those.
What code can I use to get that from my data?

What am I not doing right?

Obviously, being that you deleted/merged my post with the same post from 3 days ago that no one has responded to, I am again messing up something.

You are not supposed to duplicate open topics even if the previous one doesn't have an answer, if you want to attract attention towards your topic try to make a proper reproducible example to make it easier for responders to help you, take a look to this FAQ about how to make good R related questions.

Version:1.0 StartHTML:0000000107 EndHTML:0000003814 StartFragment:0000000127 EndFragment:0000003796

``````head(dat, 5)[, c('Treat', 'CalDays', 'SeedingDate')]
library(nlme)
df <- data.frame(Treat = c('Controlled', 'Deep Fraze', 'Verticut', 'Less Fraze', 'Scalped'), SeedingDate = c('Sep', 'Sep', 'Sep', 'Sep', 'Sep'), CalDays = c(161, 35, 161, 84, 63))
DIA0WAS<-lme(data = df, CalDays ~ Treat*SeedingDate)
#> Error in getGroups.data.frame(dataMix, groups): invalid formula for groups
anova(DIA0WAS)
#> Error in anova(DIA0WAS): object 'DIA0WAS' not found
``````

Okay, this has all kinds of errors and I understand that. I have worked on it all morning and can not get it to not give me an error when putting it in this format. The errors are not the problem I can run the code fine with the code I am using. All I need is an additional code for a way to get % critical value or standard deviation.

I feel like it is something as simply as "summary(dat)" that is why I feel that the errors are not a big deal. Does anyone have a simple code to get either of these value for your data?

Thank you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.