Hi again,
after adding a column with the name using the command $Md to Anova models,
I tried to do the same, but for any reason is not working.
I create a series of model and make them compete:
lmeGPBYPGAlowNULL <- lme(StdzDiff ~ 1, data = DataBM_GP_StdzDiffGAlow,
random = ~ 1|factor(ExpID),method="ML")
lmeGPBYPGAlowOnlyT <- lme(StdzDiff ~ Trtmnt2, data =
DataBM_GP_StdzDiffGAlow, random = ~ 1|factor(ExpID),method="ML")
Model selection table
(Intrc) Trtm2 df logLik AICc delta weight
lmeGPBYPGAlowNULL 3.367 3 -73.434 154.4 0.00 0.83
lmeGPBYPGAlowOnlyT 3.367 + 4 -73.433 157.5 3.17 0.17
Models ranked by AICc(x)
Random terms (all models):
?1 | factor(ExpID)?
Then I get the results of the Model selection, and a column with the name.
BM_MuMIn_GP_ByP_GAlow<-(msAICc <-
model.sel(lmeGPBYPGAlowNULL,lmeGPBYPGAlowOnlyT))
BM_MuMIn_GP_ByP_GAlow$Md<-"BM GP MuMIn By periods GAlow"
It seems that there is no problem. And t confirm I run it
BM_MuMIn_GP_ByP_GAlow
Model selection table
(Intrc) Trtm2 df logLik AICc delta weight
Md
lmeGPBYPGAlowNULL 3.367 3 -73.434 154.4 0.00 0.83 BM GP MuMIn
By periods GAlow
lmeGPBYPGAlowOnlyT 3.367 + 4 -73.433 157.5 3.17 0.17 BM GP MuMIn
By periods GAlow
Models ranked by AICc(x)
Random terms (all models):
?1 | factor(ExpID)?
*BUT*, when I do the same with other objects with the same amount of
columns, etc and bind them, the column Md doesnt appear
Model selection table
(Int) Tr2 Prd Prd:Tr2 df logLik AICc delta weight
Md
lmeGPAllPpAllNULL 1.441 3 -262.736 531.8 0.00 0.742 BM
GP MuMIn All periods Interact peakAll
lmeGPAllPpAllOnlyT 1.441 + 4 -262.714 533.9 2.16 0.252 BM
GP MuMIn All periods Interact peakAll
lmeGPAllPpAll2wTP 1.484 + + + 10 -260.089 543.1 11.35 0.003 BM
GP MuMIn All periods Interact peakAll
lmeGPAllPpAll2wTP1 1.484 + + + 10 -260.089 543.1 11.35 0.003 BM
GP MuMIn All periods Interact peakAll
Models ranked by AICc(x)
Random terms (all models):
?1 | factor(ExpID)?
BM_MuMIn_GP_AllP_earlypeak
Model selection table
(Int) Tr2 Prd Prd:Tr2 df logLik AICc delta weight
Md
lmeGPAllPearlypNULL 1.547 3 -261.853 530.0 0.00 0.742
BM GP MuMIn All periods Interact earlypeak
lmeGPAllPearlypOnlyT 1.547 + 4 -261.824 532.1 2.14 0.254
BM GP MuMIn All periods Interact earlypeak
lmeGPAllPearlyp2wTP 1.587 + + + 10 -259.508 541.9 11.95 0.002
BM GP MuMIn All periods Interact earlypeak
lmeGPAllPearlyp2wTP1 1.587 + + + 10 -259.508 541.9 11.95 0.002
BM GP MuMIn All periods Interact earlypeak
Models ranked by AICc(x)
Random terms (all models):
?1 | factor(ExpID)?
BM_MuMIn_GP_AllP_latepeak
Model selection table
(Int) Tr2 Prd Prd:Tr2 df logLik AICc delta weight
Md
lmeGPAllPlatepNULL 1.229 3 -266.356 539.0 0.00 0.738 BM
GP MuMIn All periods Interact latepeak
lmeGPAllPlatepOnlyT 1.229 + 4 -266.346 541.2 2.18 0.248 BM
GP MuMIn All periods Interact latepeak
lmeGPAllPlatep2wTP 1.277 + + + 10 -262.725 548.4 9.38 0.007 BM
GP MuMIn All periods Interact latepeak
lmeGPAllPlatep2wTP1 1.277 + + + 10 -262.725 548.4 9.38 0.007 BM
GP MuMIn All periods Interact latepeak
Models ranked by AICc(x)
Random terms (all models):
?1 | factor(ExpID)?
El mar., 8 oct. 2019 a las 11:08, Rolf Turner (<r.turner at auckland.ac.nz>)
escribi?:
On 8/10/19 9:28 PM, Mario Garrido wrote:
Dear Emmanuel Curis,
your approach was working perfectly, but at some point w gives me the
error. when introduced the new column
I have no problem in running model, the errors appears when introducing
extra $Md column. I wonder whether the problem is the * of the
significance, but is not, also is not due to character strings since my
variables are recognized as factors. I have no missing data in my
matrix,... And, as I said, problem only arise when I introduced the new
column
Thanks in advanxe
Analysis of Variance Table
Response: StdzDiff
Df Sum Sq Mean Sq F value Pr(>F) Md
Trtmnt 2 0.991 0.4953 0.2382 0.78891
sp 2 13.781 6.8904 3.3134 0.04407
Trtmnt:sp 4 4.123 1.0306 0.4956 0.73898
Residuals 53 110.217 2.0796
Warning message:
In data.matrix(x) : NAs introducidos por coerci?n
This is a "generic" problem; it is not peculiar to your model nor to
models fitted using lme, or other mixed modelling software.
Consider the following example:
set.seed(42)
x <- 1:20
y <- rnorm(20)
fit <- lm(y ~ x)
m <- anova(fit)
m$newColumn <- "yeeeeks"
m
This produces:
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F) newColumn
x 1 4.113 4.1130 2.5865 0.12518
Residuals 18 28.624 1.5902
Warning message:
In data.matrix(x) : NAs introduced by coercion
The "reason" is that m is (in the first instance) of class "anova" and
there are (not unreasonably) certain restrictions as to how you can
treat an object of this class.
A work-around to get something like what you appear to want could be:
set.seed(42)
x <- 1:20
y <- rnorm(20)
fit <- lm(y ~ x)
m <- anova(fit)
m <- cbind(m,newColumn=c("yeeeks",rep("",nrow(m)-1)))
m
However m is now of class "data.frame" whence it is printed by the
method print.data.frame() rather than print.anova(). Consequently NAs
show up in the output of the print method:
Df Sum Sq Mean Sq F value Pr(>F) newColumn
x 1 0.04176282 0.04176282 0.03784897 0.8479256 yeeeks
Residuals 18 19.86132473 1.10340693 NA NA
You could just live with those NAs, or you could convert the "F value"
and "Pr(>F)" columns from numeric to character mode and replace the NAs
by null strings "".
HTH
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Mario Garrido Escudero, PhD
Dr. Hadas Hawlena Lab
Mitrani Department of Desert Ecology
Jacob Blaustein Institutes for Desert Research
Ben-Gurion University of the Negev
Midreshet Ben-Gurion 84990 ISRAEL
gaiarrido at gmail.com; gaadio at post.bgu.ac.il
phone: (+972) 08-659-6854
[[alternative HTML version deleted]]