Akhilesh Singh
2018-Jan-06 13:19 UTC
[R] Error occurring in "emmeans" package for the two data sets I used. Please help.
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 one-way analysis for the two data-sets given below in the R-class. I got a typical error in "emmeans" package, please help: Data-set-1: -------------- 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 one-way 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 Data-set-2: --------------- 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 log-transformation: ------------------------------------------- keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid)) I did the one-way 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 One-way 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 data-sets, 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 R-team 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 Raipur-492012, Chhattisgarh, India Mob: +918770625795 Email: akhileshsingh.igkv at gmail.com WhatsApp: +919039202968 [[alternative HTML version deleted]]
Rolf Turner
2018-Jan-08 21:44 UTC
[R] [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.
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 one-way analysis for the two data-sets given below in the > R-class. I got a typical error in "emmeans" package, please help: > > Data-set-1: > -------------- > 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 one-way 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 > > > > Data-set-2: > --------------- > 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 log-transformation: > ------------------------------------------- > keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid)) > > I did the one-way 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 > > One-way 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 data-sets, 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 R-team to help me to solve above problem.Well, you don't need the *entire* R-team!!! 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 cc-ing 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: +64-9-373-7599 ext. 88276
Sal Mangiafico
2018-Jan-09 14:48 UTC
[R] [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.
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 one-way analysis for the two data-sets given below in the >> R-class. I got a typical error in "emmeans" package, please help: >> >> Data-set-1: >> -------------- >> 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 one-way 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 >> >> >> >> Data-set-2: >> --------------- >> 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 log-transformation: >> ------------------------------------------- >> keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid)) >> >> I did the one-way 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 >> >> One-way 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 data-sets, 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 R-team to help me to solve above problem. > > Well, you don't need the *entire* R-team!!! 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 cc-ing this reply to Russell > Lenth (the maintainer of emmeans) to get his take on the issue. > > cheers, > > Rolf Turner >[[alternative HTML version deleted]]
Akhilesh Singh
2018-Jan-10 06:45 UTC
[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 09-Jan-2018 8:18 PM, "Sal Mangiafico" <salvatore.s.mangiafico at gmail.com> 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 one-way analysis for the two data-sets given below in the R-class. I got a typical error in "emmeans" package, please help: Data-set-1: -------------- 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 one-way 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 Data-set-2: --------------- 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 log-transformation: ------------------------------------------- keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid)) I did the one-way 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 One-way 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 data-sets, 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 R-team to help me to solve above problem. Well, you don't need the *entire* R-team!!! 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 cc-ing this reply to Russell Lenth (the maintainer of emmeans) to get his take on the issue. cheers, Rolf Turner [[alternative HTML version deleted]]
Lenth, Russell V
2018-Jan-10 17:01 UTC
[R] [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.
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)335-0712 (Dept. office)? -? FAX (319)335-3017 From: Akhilesh Singh [mailto:akhileshsingh.igkv at gmail.com] Sent: Wednesday, January 10, 2018 12:45 AM To: Sal Mangiafico <salvatore.s.mangiafico at gmail.com> Cc: Rolf Turner <r.turner at auckland.ac.nz>; r-help mailing list <r-help at r-project.org>; Lenth, Russell V <russell-lenth at uiowa.edu> 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 09-Jan-2018 8:18 PM, "Sal Mangiafico" <mailto:salvatore.s.mangiafico at gmail.com> 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 one-way analysis for the two data-sets given below in the R-class. I got a typical error in "emmeans" package, please help: Data-set-1: -------------- 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 one-way 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 Data-set-2: --------------- 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 log-transformation: ------------------------------------------- keough.raimondi.ln=transform(keough.raimondi, serpulid.ln=log(serpulid)) I did the one-way 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 One-way 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 data-sets, 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 R-team to help me to solve above problem. Well, you don't need the *entire* R-team!!! 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 cc-ing this reply to Russell Lenth (the maintainer of emmeans) to get his take on the issue. cheers, Rolf Turner
Seemingly Similar Threads
- [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.
- [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.
- R helps win competitions
- R helps win competitions
- mixed model nested ANOVA (part two)