

I am a Professor of Statistics at Indira Gandhi Krishi Vishwavidyalaya,
Raipur, India. While teaching in class about analysis of variance using R,
I was doing a oneway analysis for the two datasets given below in the
Rclass. I got a typical error in "emmeans" package, please help:
Dataset1:

Medley and Clements (1998) investigated the impact of zinc contamination
(and other heavy metals) on the diversity of diatom species in the USA
Rocky Mountains. The diversity of diatoms (number of species) and degree of
zinc contamination (categorized as either of high, medium, low or natural
background level) were recorded from between four and six sampling stations
within each of six streams known to be polluted, as given below:
stream=c("Eagle", "Eagle", "Eagle", "Eagle", "Blue", "Blue",
"Blue", "Blue", "Blue", "Blue", "Blue", "Snake", "Snake",
"Snake", "Snake", "Snake", "Arkan", "Arkan", "Arkan",
"Arkan", "Arkan", "Arkan", "Arkan", "Chalk", "Chalk",
"Chalk", "Chalk", "Chalk", "Splat", "Splat", "Splat",
"Splat", "Splat", "Splat")
zinc=c("BACK", "HIGH", "HIGH", "MED", "BACK", "HIGH", "BACK", "BACK",
"HIGH", "MED", "MED", "BACK", "MED", "HIGH", "HIGH", "HIGH",
"LOW", "LOW", "LOW", "LOW", "MED", "MED", "LOW", "LOW",
"HIGH", "HIGH", "MED", "LOW", "BACK", "BACK", "MED", "LOW",
"MED", "BACK")
diversity=c(2.27, 1.25, 1.15, 1.62, 1.7, 0.63, 2.05, 1.98, 1.04,
2.19, 2.1, 2.2, 2.06, 1.9, 1.88, 0.85, 1.4, 2.18, 1.83,
1.88, 2.02, 1.94, 2.1, 2.38, 1.43, 1.37, 1.75, 2.83,
1.53, 0.76, 0.8, 1.66, 0.98, 1.89)
medley.clementis=data.frame(stream,zinc,diversity)
I did the oneway anova:

medley.clementis.aov=with(medley.clementis, aov(diversity ~ zinc))
anova(medley.clementis)
Then, I tried to do post hoc analysis using "emmeans" package following
command:

emmeans::emmeans(medley.clementis.aov, "zinc")
This gives following error:

Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action, :
object 'possibly.random' not found
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
Dataset2:

Keough and Raimondi (1995) examined the effects of four biofilm types (SL:
sterile unfilmed substrate, NL: netted laboratory biofilms, UL: unnetted
laboratory biofilms and F: netted field biofilms) on the recruitment of
serpulid larvae. Substrates treated with one of the four biofilm types were
left in shallow marine waters for one week after which the number of newly
recruited serpulid worms were counted, as given below:
biofilm=c("SL", "SL", "SL", "SL", "SL", "SL", "SL", "UL", "UL", "UL",
"UL", "UL", "UL", "UL", "NL", "NL", "NL", "NL", "NL", "NL",
"NL", "F", "F", "F", "F", "F", "F", "F")
serpulid=c(61, 113, 123, 75, 75, 83, 95, 143, 81, 101, 155, 156, 193,
163, 203, 159, 139, 161, 179, 97, 157, 128.5, 204.5,
108.5, 116.5, 140.5, 160.5, 87.5)
keough.raimondi=data.frame(biofilm,serpulid)
Applied logtransformation:

keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid))
I did the oneway anova, with contrasts defined below:

contrasts(keough.raimondi.ln$biofilm) < cbind(c(0, 1, 0, 1),
c(2, 1, 0, 1), c(1, 1, 3, 1))
keough.raimondi.ln$biofilm
keough.contr.list < list(biofilm = list('NL vs UL' = 1,
'F vs (NL & UL)' = 2, 'SL vs (F & NL & UL)' = 3))
keough.contr.list
Oneway anova:

keough.raimondi.ln.aov=with(keough.raimondi.ln, aov(serpulid.ln ~ biofilm))
summary(keough.raimondi.ln.aov,split=keough.contr.list)
Then, I tried to do post hoc analysis using "emmeans" package following
command:

emmeans(keough.raimondi.ln.aov, ~ biofilm)
This gives following error:

Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action, :
object 'possibly.random' not found
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
Help Needed:

On many other data sets and data frame I successfully used "emmeans"
package using the help available in R.
But, for the above two datasets, I consistently got the same error as
described above.
I do not know what is amiss. Where I am missing or whatever is wrong, I
request the entire Rteam to help me to solve above problem. Thanking in
advance.
Dr. A.K. Singh
Professor and Head
Department of Agricultural Statistics
Indira Gandhi Krishi Vishwavidyalaya
Raipur492012, Chhattisgarh, India
Mob: +918770625795
Email: [hidden email]
WhatsApp: +919039202968
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On 07/01/18 02:19, Akhilesh Singh wrote:
> I am a Professor of Statistics at Indira Gandhi Krishi Vishwavidyalaya,
> Raipur, India. While teaching in class about analysis of variance using R,
> I was doing a oneway analysis for the two datasets given below in the
> Rclass. I got a typical error in "emmeans" package, please help:
>
> Dataset1:
> 
> Medley and Clements (1998) investigated the impact of zinc contamination
> (and other heavy metals) on the diversity of diatom species in the USA
> Rocky Mountains. The diversity of diatoms (number of species) and degree of
> zinc contamination (categorized as either of high, medium, low or natural
> background level) were recorded from between four and six sampling stations
> within each of six streams known to be polluted, as given below:
>
> stream=c("Eagle", "Eagle", "Eagle", "Eagle", "Blue", "Blue",
> "Blue", "Blue", "Blue", "Blue", "Blue", "Snake", "Snake",
> "Snake", "Snake", "Snake", "Arkan", "Arkan", "Arkan",
> "Arkan", "Arkan", "Arkan", "Arkan", "Chalk", "Chalk",
> "Chalk", "Chalk", "Chalk", "Splat", "Splat", "Splat",
> "Splat", "Splat", "Splat")
>
> zinc=c("BACK", "HIGH", "HIGH", "MED", "BACK", "HIGH", "BACK", "BACK",
> "HIGH", "MED", "MED", "BACK", "MED", "HIGH", "HIGH", "HIGH",
> "LOW", "LOW", "LOW", "LOW", "MED", "MED", "LOW", "LOW",
> "HIGH", "HIGH", "MED", "LOW", "BACK", "BACK", "MED", "LOW",
> "MED", "BACK")
>
> diversity=c(2.27, 1.25, 1.15, 1.62, 1.7, 0.63, 2.05, 1.98, 1.04,
> 2.19, 2.1, 2.2, 2.06, 1.9, 1.88, 0.85, 1.4, 2.18, 1.83,
> 1.88, 2.02, 1.94, 2.1, 2.38, 1.43, 1.37, 1.75, 2.83,
> 1.53, 0.76, 0.8, 1.66, 0.98, 1.89)
>
> medley.clementis=data.frame(stream,zinc,diversity)
>
> I did the oneway anova:
> 
>
> medley.clementis.aov=with(medley.clementis, aov(diversity ~ zinc))
>
> anova(medley.clementis)
>
> Then, I tried to do post hoc analysis using "emmeans" package following
> command:
> 
>
> emmeans::emmeans(medley.clementis.aov, "zinc")
>
>
> This gives following error:
> 
> Error in recover_data.call(fcall, delete.response(terms(object)),
> object$na.action, :
> object 'possibly.random' not found
> Error in ref_grid(object, ...) :
> Perhaps a 'data' or 'params' argument is needed
>
>
>
> Dataset2:
> 
> Keough and Raimondi (1995) examined the effects of four biofilm types (SL:
> sterile unfilmed substrate, NL: netted laboratory biofilms, UL: unnetted
> laboratory biofilms and F: netted field biofilms) on the recruitment of
> serpulid larvae. Substrates treated with one of the four biofilm types were
> left in shallow marine waters for one week after which the number of newly
> recruited serpulid worms were counted, as given below:
>
> biofilm=c("SL", "SL", "SL", "SL", "SL", "SL", "SL", "UL", "UL", "UL",
> "UL", "UL", "UL", "UL", "NL", "NL", "NL", "NL", "NL", "NL",
> "NL", "F", "F", "F", "F", "F", "F", "F")
>
> serpulid=c(61, 113, 123, 75, 75, 83, 95, 143, 81, 101, 155, 156, 193,
> 163, 203, 159, 139, 161, 179, 97, 157, 128.5, 204.5,
> 108.5, 116.5, 140.5, 160.5, 87.5)
>
> keough.raimondi=data.frame(biofilm,serpulid)
>
> Applied logtransformation:
> 
> keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid))
>
> I did the oneway anova, with contrasts defined below:
> 
> contrasts(keough.raimondi.ln$biofilm) < cbind(c(0, 1, 0, 1),
> c(2, 1, 0, 1), c(1, 1, 3, 1))
> keough.raimondi.ln$biofilm
>
> keough.contr.list < list(biofilm = list('NL vs UL' = 1,
> 'F vs (NL & UL)' = 2, 'SL vs (F & NL & UL)' = 3))
> keough.contr.list
>
> Oneway anova:
> 
> keough.raimondi.ln.aov=with(keough.raimondi.ln, aov(serpulid.ln ~ biofilm))
>
> summary(keough.raimondi.ln.aov,split=keough.contr.list)
>
>
> Then, I tried to do post hoc analysis using "emmeans" package following
> command:
> 
>
> emmeans(keough.raimondi.ln.aov, ~ biofilm)
>
>
> This gives following error:
> 
> Error in recover_data.call(fcall, delete.response(terms(object)),
> object$na.action, :
> object 'possibly.random' not found
> Error in ref_grid(object, ...) :
> Perhaps a 'data' or 'params' argument is needed
>
>
> Help Needed:
> 
> On many other data sets and data frame I successfully used "emmeans"
> package using the help available in R.
>
> But, for the above two datasets, I consistently got the same error as
> described above.
>
> I do not know what is amiss. Where I am missing or whatever is wrong, I
> request the entire Rteam to help me to solve above problem.
Well, you don't need the *entire* Rteam!!! It probably (in some sense)
includes millions of people. :)
> Thanking in advance.
Thanks for your thorough and well set out description of the problem.
Your reproducible examples were flawless.
I am not *completely* certain, but this looks to me like a bug in emmeans.
I have therefore taken the liberty of ccing this reply to Russell Lenth
(the maintainer of emmeans) to get his take on the issue.
cheers,
Rolf Turner

Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +6493737599 ext. 88276
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


One way to avoid this error is to create the aov without using the with
function, but instead use the data= option in the aov function.
That is,
medley2 = aov(diversity ~ zinc, data=medley.clementis)
emmeans::emmeans(medley2, "zinc")
You can see the difference in the calls:
medley2$call
medley.clementis.aov$call
This works for the other data set as well, e.g.
keough2 = aov(serpulid.ln ~ biofilm, data=keough.raimondi.ln)
~ Sal Mangiafico
On 1/8/2018 4:44 PM, Rolf Turner wrote:
>
> On 07/01/18 02:19, Akhilesh Singh wrote:
>
>> I am a Professor of Statistics at Indira Gandhi Krishi Vishwavidyalaya,
>> Raipur, India. While teaching in class about analysis of variance
>> using R,
>> I was doing a oneway analysis for the two datasets given below in the
>> Rclass. I got a typical error in "emmeans" package, please help:
>>
>> Dataset1:
>> 
>> Medley and Clements (1998) investigated the impact of zinc contamination
>> (and other heavy metals) on the diversity of diatom species in the USA
>> Rocky Mountains. The diversity of diatoms (number of species) and
>> degree of
>> zinc contamination (categorized as either of high, medium, low or
>> natural
>> background level) were recorded from between four and six sampling
>> stations
>> within each of six streams known to be polluted, as given below:
>>
>> stream=c("Eagle", "Eagle", "Eagle", "Eagle", "Blue", "Blue",
>> "Blue", "Blue", "Blue", "Blue", "Blue", "Snake", "Snake",
>> "Snake", "Snake", "Snake", "Arkan", "Arkan", "Arkan",
>> "Arkan", "Arkan", "Arkan", "Arkan", "Chalk", "Chalk",
>> "Chalk", "Chalk", "Chalk", "Splat", "Splat", "Splat",
>> "Splat", "Splat", "Splat")
>>
>> zinc=c("BACK", "HIGH", "HIGH", "MED", "BACK", "HIGH", "BACK", "BACK",
>> "HIGH", "MED", "MED", "BACK", "MED", "HIGH", "HIGH", "HIGH",
>> "LOW", "LOW", "LOW", "LOW", "MED", "MED", "LOW", "LOW",
>> "HIGH", "HIGH", "MED", "LOW", "BACK", "BACK", "MED", "LOW",
>> "MED", "BACK")
>>
>> diversity=c(2.27, 1.25, 1.15, 1.62, 1.7, 0.63, 2.05, 1.98, 1.04,
>> 2.19, 2.1, 2.2, 2.06, 1.9, 1.88, 0.85, 1.4, 2.18, 1.83,
>> 1.88, 2.02, 1.94, 2.1, 2.38, 1.43, 1.37, 1.75, 2.83,
>> 1.53, 0.76, 0.8, 1.66, 0.98, 1.89)
>>
>> medley.clementis=data.frame(stream,zinc,diversity)
>>
>> I did the oneway anova:
>> 
>>
>> medley.clementis.aov=with(medley.clementis, aov(diversity ~ zinc))
>>
>> anova(medley.clementis)
>>
>> Then, I tried to do post hoc analysis using "emmeans" package following
>> command:
>> 
>>
>>
>> emmeans::emmeans(medley.clementis.aov, "zinc")
>>
>>
>> This gives following error:
>> 
>> Error in recover_data.call(fcall, delete.response(terms(object)),
>> object$na.action, :
>> object 'possibly.random' not found
>> Error in ref_grid(object, ...) :
>> Perhaps a 'data' or 'params' argument is needed
>>
>>
>>
>> Dataset2:
>> 
>> Keough and Raimondi (1995) examined the effects of four biofilm types
>> (SL:
>> sterile unfilmed substrate, NL: netted laboratory biofilms, UL: unnetted
>> laboratory biofilms and F: netted field biofilms) on the recruitment of
>> serpulid larvae. Substrates treated with one of the four biofilm
>> types were
>> left in shallow marine waters for one week after which the number of
>> newly
>> recruited serpulid worms were counted, as given below:
>>
>> biofilm=c("SL", "SL", "SL", "SL", "SL", "SL", "SL", "UL", "UL", "UL",
>> "UL", "UL", "UL", "UL", "NL", "NL", "NL", "NL", "NL", "NL",
>> "NL", "F", "F", "F", "F", "F", "F", "F")
>>
>> serpulid=c(61, 113, 123, 75, 75, 83, 95, 143, 81, 101, 155, 156, 193,
>> 163, 203, 159, 139, 161, 179, 97, 157, 128.5, 204.5,
>> 108.5, 116.5, 140.5, 160.5, 87.5)
>>
>> keough.raimondi=data.frame(biofilm,serpulid)
>>
>> Applied logtransformation:
>> 
>> keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid))
>>
>> I did the oneway anova, with contrasts defined below:
>> 
>> contrasts(keough.raimondi.ln$biofilm) < cbind(c(0, 1, 0, 1),
>> c(2, 1, 0, 1), c(1, 1, 3, 1))
>> keough.raimondi.ln$biofilm
>>
>> keough.contr.list < list(biofilm = list('NL vs UL' = 1,
>> 'F vs (NL & UL)' = 2, 'SL vs (F & NL & UL)' = 3))
>> keough.contr.list
>>
>> Oneway anova:
>> 
>> keough.raimondi.ln.aov=with(keough.raimondi.ln, aov(serpulid.ln ~
>> biofilm))
>>
>> summary(keough.raimondi.ln.aov,split=keough.contr.list)
>>
>>
>> Then, I tried to do post hoc analysis using "emmeans" package following
>> command:
>> 
>>
>>
>> emmeans(keough.raimondi.ln.aov, ~ biofilm)
>>
>>
>> This gives following error:
>> 
>> Error in recover_data.call(fcall, delete.response(terms(object)),
>> object$na.action, :
>> object 'possibly.random' not found
>> Error in ref_grid(object, ...) :
>> Perhaps a 'data' or 'params' argument is needed
>>
>>
>> Help Needed:
>> 
>> On many other data sets and data frame I successfully used "emmeans"
>> package using the help available in R.
>>
>> But, for the above two datasets, I consistently got the same error as
>> described above.
>>
>> I do not know what is amiss. Where I am missing or whatever is wrong, I
>> request the entire Rteam to help me to solve above problem.
>
> Well, you don't need the *entire* Rteam!!! It probably (in some
> sense) includes millions of people. :)
>
>> Thanking in advance.
>
> Thanks for your thorough and well set out description of the problem.
> Your reproducible examples were flawless.
>
> I am not *completely* certain, but this looks to me like a bug in
> emmeans.
>
> I have therefore taken the liberty of ccing this reply to Russell
> Lenth (the maintainer of emmeans) to get his take on the issue.
>
> cheers,
>
> Rolf Turner
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks for your kind reply. Problem is solved. However, it's "confidence
interval / treatment comparison plot" is not taking main title. And the
fonts of axes labels can not be changed using 'cex' parameter. I will
appreciate if you could help in this matter too.
Dr. A. K. Singh
On 09Jan2018 8:18 PM, "Sal Mangiafico" < [hidden email]>
wrote:
One way to avoid this error is to create the aov without using the with
function, but instead use the data= option in the aov function.
That is,
medley2 = aov(diversity ~ zinc, data=medley.clementis)
emmeans::emmeans(medley2, "zinc")
You can see the difference in the calls:
medley2$call
medley.clementis.aov$call
This works for the other data set as well, e.g.
keough2 = aov(serpulid.ln ~ biofilm, data=keough.raimondi.ln)
~ Sal Mangiafico
On 1/8/2018 4:44 PM, Rolf Turner wrote:
On 07/01/18 02:19, Akhilesh Singh wrote:
I am a Professor of Statistics at Indira Gandhi Krishi Vishwavidyalaya,
Raipur, India. While teaching in class about analysis of variance using R,
I was doing a oneway analysis for the two datasets given below in the
Rclass. I got a typical error in "emmeans" package, please help:
Dataset1:

Medley and Clements (1998) investigated the impact of zinc contamination
(and other heavy metals) on the diversity of diatom species in the USA
Rocky Mountains. The diversity of diatoms (number of species) and degree of
zinc contamination (categorized as either of high, medium, low or natural
background level) were recorded from between four and six sampling stations
within each of six streams known to be polluted, as given below:
stream=c("Eagle", "Eagle", "Eagle", "Eagle", "Blue", "Blue",
"Blue", "Blue", "Blue", "Blue", "Blue", "Snake", "Snake",
"Snake", "Snake", "Snake", "Arkan", "Arkan", "Arkan",
"Arkan", "Arkan", "Arkan", "Arkan", "Chalk", "Chalk",
"Chalk", "Chalk", "Chalk", "Splat", "Splat", "Splat",
"Splat", "Splat", "Splat")
zinc=c("BACK", "HIGH", "HIGH", "MED", "BACK", "HIGH", "BACK", "BACK",
"HIGH", "MED", "MED", "BACK", "MED", "HIGH", "HIGH", "HIGH",
"LOW", "LOW", "LOW", "LOW", "MED", "MED", "LOW", "LOW",
"HIGH", "HIGH", "MED", "LOW", "BACK", "BACK", "MED", "LOW",
"MED", "BACK")
diversity=c(2.27, 1.25, 1.15, 1.62, 1.7, 0.63, 2.05, 1.98, 1.04,
2.19, 2.1, 2.2, 2.06, 1.9, 1.88, 0.85, 1.4, 2.18, 1.83,
1.88, 2.02, 1.94, 2.1, 2.38, 1.43, 1.37, 1.75, 2.83,
1.53, 0.76, 0.8, 1.66, 0.98, 1.89)
medley.clementis=data.frame(stream,zinc,diversity)
I did the oneway anova:

medley.clementis.aov=with(medley.clementis, aov(diversity ~ zinc))
anova(medley.clementis)
Then, I tried to do post hoc analysis using "emmeans" package following
command:


emmeans::emmeans(medley.clementis.aov, "zinc")
This gives following error:

Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action, :
object 'possibly.random' not found
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
Dataset2:

Keough and Raimondi (1995) examined the effects of four biofilm types (SL:
sterile unfilmed substrate, NL: netted laboratory biofilms, UL: unnetted
laboratory biofilms and F: netted field biofilms) on the recruitment of
serpulid larvae. Substrates treated with one of the four biofilm types were
left in shallow marine waters for one week after which the number of newly
recruited serpulid worms were counted, as given below:
biofilm=c("SL", "SL", "SL", "SL", "SL", "SL", "SL", "UL", "UL", "UL",
"UL", "UL", "UL", "UL", "NL", "NL", "NL", "NL", "NL", "NL",
"NL", "F", "F", "F", "F", "F", "F", "F")
serpulid=c(61, 113, 123, 75, 75, 83, 95, 143, 81, 101, 155, 156, 193,
163, 203, 159, 139, 161, 179, 97, 157, 128.5, 204.5,
108.5, 116.5, 140.5, 160.5, 87.5)
keough.raimondi=data.frame(biofilm,serpulid)
Applied logtransformation:

keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid))
I did the oneway anova, with contrasts defined below:

contrasts(keough.raimondi.ln$biofilm) < cbind(c(0, 1, 0, 1),
c(2, 1, 0, 1), c(1, 1, 3, 1))
keough.raimondi.ln$biofilm
keough.contr.list < list(biofilm = list('NL vs UL' = 1,
'F vs (NL & UL)' = 2, 'SL vs (F & NL & UL)' = 3))
keough.contr.list
Oneway anova:

keough.raimondi.ln.aov=with(keough.raimondi.ln, aov(serpulid.ln ~ biofilm))
summary(keough.raimondi.ln.aov,split=keough.contr.list)
Then, I tried to do post hoc analysis using "emmeans" package following
command:


emmeans(keough.raimondi.ln.aov, ~ biofilm)
This gives following error:

Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action, :
object 'possibly.random' not found
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
Help Needed:

On many other data sets and data frame I successfully used "emmeans"
package using the help available in R.
But, for the above two datasets, I consistently got the same error as
described above.
I do not know what is amiss. Where I am missing or whatever is wrong, I
request the entire Rteam to help me to solve above problem.
Well, you don't need the *entire* Rteam!!! It probably (in some sense)
includes millions of people. :)
Thanking in advance.
Thanks for your thorough and well set out description of the problem.
Your reproducible examples were flawless.
I am not *completely* certain, but this looks to me like a bug in emmeans.
I have therefore taken the liberty of ccing this reply to Russell Lenth
(the maintainer of emmeans) to get his take on the issue.
cheers,
Rolf Turner
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


This seems to be an entirely new question.
The ‘plot.emmGrid()’ function returns a graphic object of class “ggplot” (by default) or “lattice” (if called with ‘engine = “lattice”’). You should use the provisions in those respective packages (ggplot2 or lattice) to control the details of the plot. In the case of lattice, additional arguments are passed via ‘...’ in the call. In the case of ggplot, one may “add” other ggplot:: functions to modify the plot.
Russ
Russell V. Lenth  Professor Emeritus
Department of Statistics and Actuarial Science
The University of Iowa  Iowa City, IA 52242 USA
Voice (319)3350712 (Dept. office)  FAX (319)3353017
From: Akhilesh Singh [mailto: [hidden email]]
Sent: Wednesday, January 10, 2018 12:45 AM
To: Sal Mangiafico < [hidden email]>
Cc: Rolf Turner < [hidden email]>; rhelp mailing list < [hidden email]>; Lenth, Russell V < [hidden email]>
Subject: Re: [R] [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.
Thanks for your kind reply. Problem is solved. However, it's "confidence interval / treatment comparison plot" is not taking main title. And the fonts of axes labels can not be changed using 'cex' parameter. I will appreciate if you could help in this matter too.
Dr. A. K. Singh
On 09Jan2018 8:18 PM, "Sal Mangiafico" <mailto: [hidden email]> wrote:
One way to avoid this error is to create the aov without using the with function, but instead use the data= option in the aov function.
That is,
medley2 = aov(diversity ~ zinc, data=medley.clementis)
emmeans::emmeans(medley2, "zinc")
You can see the difference in the calls:
medley2$call
medley.clementis.aov$call
This works for the other data set as well, e.g.
keough2 = aov(serpulid.ln ~ biofilm, data=keough.raimondi.ln)
~ Sal Mangiafico
On 1/8/2018 4:44 PM, Rolf Turner wrote:
On 07/01/18 02:19, Akhilesh Singh wrote:
I am a Professor of Statistics at Indira Gandhi Krishi Vishwavidyalaya,
Raipur, India. While teaching in class about analysis of variance using R,
I was doing a oneway analysis for the two datasets given below in the
Rclass. I got a typical error in "emmeans" package, please help:
Dataset1:

Medley and Clements (1998) investigated the impact of zinc contamination
(and other heavy metals) on the diversity of diatom species in the USA
Rocky Mountains. The diversity of diatoms (number of species) and degree of
zinc contamination (categorized as either of high, medium, low or natural
background level) were recorded from between four and six sampling stations
within each of six streams known to be polluted, as given below:
stream=c("Eagle", "Eagle", "Eagle", "Eagle", "Blue", "Blue",
"Blue", "Blue", "Blue", "Blue", "Blue", "Snake", "Snake",
"Snake", "Snake", "Snake", "Arkan", "Arkan", "Arkan",
"Arkan", "Arkan", "Arkan", "Arkan", "Chalk", "Chalk",
"Chalk", "Chalk", "Chalk", "Splat", "Splat", "Splat",
"Splat", "Splat", "Splat")
zinc=c("BACK", "HIGH", "HIGH", "MED", "BACK", "HIGH", "BACK", "BACK",
"HIGH", "MED", "MED", "BACK", "MED", "HIGH", "HIGH", "HIGH",
"LOW", "LOW", "LOW", "LOW", "MED", "MED", "LOW", "LOW",
"HIGH", "HIGH", "MED", "LOW", "BACK", "BACK", "MED", "LOW",
"MED", "BACK")
diversity=c(2.27, 1.25, 1.15, 1.62, 1.7, 0.63, 2.05, 1.98, 1.04,
2.19, 2.1, 2.2, 2.06, 1.9, 1.88, 0.85, 1.4, 2.18, 1.83,
1.88, 2.02, 1.94, 2.1, 2.38, 1.43, 1.37, 1.75, 2.83,
1.53, 0.76, 0.8, 1.66, 0.98, 1.89)
medley.clementis=data.frame(stream,zinc,diversity)
I did the oneway anova:

medley.clementis.aov=with(medley.clementis, aov(diversity ~ zinc))
anova(medley.clementis)
Then, I tried to do post hoc analysis using "emmeans" package following
command:

emmeans::emmeans(medley.clementis.aov, "zinc")
This gives following error:

Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action, :
object 'possibly.random' not found
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
Dataset2:

Keough and Raimondi (1995) examined the effects of four biofilm types (SL:
sterile unfilmed substrate, NL: netted laboratory biofilms, UL: unnetted
laboratory biofilms and F: netted field biofilms) on the recruitment of
serpulid larvae. Substrates treated with one of the four biofilm types were
left in shallow marine waters for one week after which the number of newly
recruited serpulid worms were counted, as given below:
biofilm=c("SL", "SL", "SL", "SL", "SL", "SL", "SL", "UL", "UL", "UL",
"UL", "UL", "UL", "UL", "NL", "NL", "NL", "NL", "NL", "NL",
"NL", "F", "F", "F", "F", "F", "F", "F")
serpulid=c(61, 113, 123, 75, 75, 83, 95, 143, 81, 101, 155, 156, 193,
163, 203, 159, 139, 161, 179, 97, 157, 128.5, 204.5,
108.5, 116.5, 140.5, 160.5, 87.5)
keough.raimondi=data.frame(biofilm,serpulid)
Applied logtransformation:

keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid))
I did the oneway anova, with contrasts defined below:

contrasts(keough.raimondi.ln$biofilm) < cbind(c(0, 1, 0, 1),
c(2, 1, 0, 1), c(1, 1, 3, 1))
keough.raimondi.ln$biofilm
keough.contr.list < list(biofilm = list('NL vs UL' = 1,
'F vs (NL & UL)' = 2, 'SL vs (F & NL & UL)' = 3))
keough.contr.list
Oneway anova:

keough.raimondi.ln.aov=with(keough.raimondi.ln, aov(serpulid.ln ~ biofilm))
summary(keough.raimondi.ln.aov,split=keough.contr.list)
Then, I tried to do post hoc analysis using "emmeans" package following
command:

emmeans(keough.raimondi.ln.aov, ~ biofilm)
This gives following error:

Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action, :
object 'possibly.random' not found
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
Help Needed:

On many other data sets and data frame I successfully used "emmeans"
package using the help available in R.
But, for the above two datasets, I consistently got the same error as
described above.
I do not know what is amiss. Where I am missing or whatever is wrong, I
request the entire Rteam to help me to solve above problem.
Well, you don't need the *entire* Rteam!!! It probably (in some sense) includes millions of people. :)
Thanking in advance.
Thanks for your thorough and well set out description of the problem.
Your reproducible examples were flawless.
I am not *completely* certain, but this looks to me like a bug in emmeans.
I have therefore taken the liberty of ccing this reply to Russell Lenth (the maintainer of emmeans) to get his take on the issue.
cheers,
Rolf Turner
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

