Dear Vinay,
If you provided a reproducible example, I would be able to see exactly what happens. But I don't have access to your "phenx" object, so I cannot be sure of what is going on.
Nevertheless, if it is a data frame, you seem to be "pasting" the values of the variables together in the formula, rather than the variable names. I don't know why it worked on the 2-column case. I would need to examine the object to understand. But the fact that it did not fail does not mean it worked correctly.
Find below a reproducible example using the globulus data included with breedR. I hope it helps.
Best wishes,
ƒacu.-
library(breedR)
#> Loading required package: sp
## Reference model
res0 <- remlf90(
fixed = phe_X ~ gg + bl,
data = globulus
)
#> Using default initial variances given by default_initial_variance()
#> See ?breedR.getOption.
## This is analogous to what you have used in your example
res <- remlf90(
fixed = as.formula(paste("phe_X ~", paste(globulus[ ,5:6], collapse = "+"))),
data = globulus
)
#> Using default initial variances given by default_initial_variance()
#> See ?breedR.getOption.
#> Error in `[.data.frame`(mf, , names(which(attr(mt, "term.types") == "fixed")), : undefined columns selected
## This is not what you want
paste(globulus[ ,5:6], collapse = "+")
#> [1] "c(14, 4, 14, 14, 8, 14, 14, 14, 14, 11, 2, 4, 4, 6, 9, 14, 14, 14, 4, 9, 5, 14, 8, 9, 14, 14, 14, 14, 14, 14, 14, 9, 12, 6, 14, 14, 3, 14, 4, 8, 5, 10, 3, 5, 4, 9, 9, 14, 5, 9, 11, 14, 2, 14, 9, 2, 14, 5, 11, 5, 8, 5, 4, 9, 1, 8, 9, 8, 5, 3, 5, 9, 14, 1, 11, 8, 3, 14, 11, 14, 12, 14, 14, 14, 14, 14, 14, 1, 5, 5, 11, 14, 9, 14, 5, 2, 14, 1, 13, 2, 8, 4, 3, 3, 8, 13, 2, 12, 10, 5, 14, 14, 5, 14, 14, 14, 14, 3, 11, 4, 8, 13, 3, 11, 14, 3, 3, 7, 3, 1, 8, 7, 8, 14, 9, 1, 3, 14, 9, 14, 14, 2, 1, 11, 5, \n11, 8, 9, 5, 9, 12, 10, 1, 3, 3, 3, 14, 14, 14, 14, 5, 1, 14, 5, 14, 11, 14, 14, 6, 9, 4, 8, 1, 8, 3, 14, 3, 8, 6, 11, 8, 8, 1, 14, 12, 14, 9, 1, 14, 3, 8, 11, 14, 14, 14, 14, 1, 14, 14, 14, 13, 11, 12, 8, 7, 3, 1, 3, 7, 8, 9, 11, 1, 14, 8, 3, 1, 8, 4, 5, 11, 8, 11, 8, 12, 8, 3, 14, 9, 14, 3, 8, 14, 3, 4, 8, 8, 3, 14, 3, 5, 14, 1, 9, 3, 8, 14, 14, 5, 3, 11, 8, 5, 8, 11, 3, 8, 1, 5, 14, 14, 14, 14, 3, 9, 8, 5, 1, 8, 9, 12, 4, 4, 2, 14, 14, 14, 8, 8, 14, 14, 14, 11, 3, 1, 14, 14, 14, 11, 5, 8, 4, 5, \n13, 11, 3, 14, 14, 14, 14, 14, 11, 8, 14, 12, 2, 5, 1, 14, 9, 14, 4, 11, 14, 1, 2, 14, 9, 14, 14, 3, 5, 14, 12, 2, 9, 5, 11, 11, 3, 11, 14, 5, 14, 5, 9, 14, 5, 10, 8, 14, 14, 1, 14, 3, 9, 10, 4, 7, 8, 11, 8, 14, 1, 9, 14, 8, 14, 10, 3, 3, 14, 1, 14, 14, 14, 14, 5, 14, 14, 8, 5, 11, 13, 5, 4, 1, 5, 3, 3, 3, 14, 9, 14, 8, 4, 14, 8, 8, 14, 11, 3, 9, 8, 8, 14, 3, 8, 1, 3, 8, 3, 5, 3, 12, 3, 2, 8, 14, 11, 11, 2, 8, 3, 5, 1, 3, 4, 2, 14, 1, 5, 12, 14, 14, 7, 11, 4, 5, 9, 14, 9, 14, 1, 9, 14, 1, 14, 4, \n14, 14, 9, 9, 8, 8, 1, 14, 14, 10, 5, 3, 9, 4, 5, 14, 1, 8, 7, 1, 11, 8, 14, 14, 14, 9, 14, 11, 7, 5, 8, 3, 14, 14, 9, 11, 14, 14, 14, 9, 4, 9, 9, 3, 14, 3, 13, 3, 4, 8, 8, 8, 8, 5, 14, 5, 14, 11, 14, 3, 3, 1, 5, 6, 11, 4, 8, 3, 1, 9, 3, 8, 14, 8, 2, 12, 8, 3, 9, 14, 9, 14, 8, 3, 3, 3, 14, 14, 14, 8, 1, 14, 12, 8, 13, 5, 4, 3, 14, 11, 14, 12, 1, 8, 3, 11, 8, 3, 14, 11, 9, 14, 5, 14, 11, 1, 11, 14, 14, 1, 14, 3, 5, 14, 9, 14, 5, 8, 3, 14, 14, 9, 14, 5, 14, 7, 9, 14, 4, 1, 12, 3, 1, 14, 4, 5, 9, 2, \n9, 5, 11, 14, 8, 9, 2, 2, 2, 3, 8, 3, 1, 5, 8, 1, 8, 1, 5, 3, 14, 1, 14, 9, 3, 1, 14, 14, 14, 1, 6, 9, 4, 1, 11, 14, 14, 14, 14, 9, 14, 1, 8, 11, 5, 14, 14, 14, 11, 1, 14, 14, 14, 14, 9, 14, 8, 3, 5, 3, 5, 8, 8, 5, 14, 9, 14, 8, 8, 4, 3, 14, 1, 14, 14, 14, 14, 14, 14, 5, 3, 8, 14, 14, 9, 14, 8, 11, 14, 14, 14, 9, 14, 1, 13, 4, 11, 8, 1, 14, 14, 11, 5, 5, 10, 8, 9, 8, 14, 3, 8, 11, 10, 3, 5, 14, 14, 2, 11, 8, 4, 3, 14, 14, 14, 8, 3, 14, 12, 14, 12, 9, 3, 3, 14, 4, 3, 5, 2, 13, 12, 14, 14, 3, 2, 3, \n13, 12, 5, 14, 11, 8, 4, 10, 5, 1, 3, 14, 3, 14, 9, 6, 9, 4, 1, 13, 11, 14, 5, 14, 11, 4, 5, 4, 8, 8, 4, 14, 8, 3, 10, 5, 11, 9, 14, 12, 14, 3, 14, 7, 14, 11, 14, 3, 11, 8, 8, 12, 8, 3, 14, 14, 11, 9, 8, 3, 8, 4, 3, 8, 7, 14, 1, 14, 14, 14, 5, 3, 8, 8, 14, 7, 4, 14, 5, 9, 14, 11, 14, 5, 14, 9, 1, 3, 5, 11, 5, 14, 11, 14, 14, 3, 9, 14, 2, 9, 14, 14, 8, 3, 1, 14, 1, 13, 5, 12, 14, 3, 5, 12, 14, 5, 14, 14, 2, 14, 14, 14, 1, 7, 12, 3, 4, 11, 11, 3, 14, 4, 9, 12, 8, 11, 14, 3, 12, 9, 14, 14, 13, 11, 14, \n14, 8, 8, 1, 3, 6, 3, 1, 10, 11, 3, 2, 14, 11, 1, 8, 4, 14, 8, 14, 9, 4, 1, 9, 14, 13, 1, 14, 5, 14, 14, 9, 14, 14, 8, 14, 14, 9, 5, 2, 3, 14, 1, 14, 14, 12, 5, 3, 8, 8, 9, 8, 7, 8, 3, 11, 6, 8, 11, 4, 5, 5, 3, 10, 4, 3, 3, 9, 14, 14, 14, 3, 9, 8, 5, 14, 8, 14, 14, 3, 14, 3, 14, 14, 14, 4, 1, 8, 8, 3, 14, 3, 11, 4, 5, 2, 14, 4, 4, 8, 2, 14, 5, 14, 11, 7, 6, 9, 14, 8, 8, 14, 14, 14, 11, 5, 11, 5, 8, 1, 14, 8, 4, 9, 14, 8, 1, 8, 8, 5, 9, 3, 1, 3, 14, 8, 9, 14, 10, 14, 14, 9, 5)+c(13, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, \n13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 14, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, \n14, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, \n6, 2, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 10, 10, 10, 10, 10, 10, 10, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, \n7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, \n11, 11, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 3, 12, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 12, 12, \n12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4)"
## You want to use the *names* of the variables in the formula, not the
## variables themselves
res <- remlf90(
fixed = as.formula(paste("phe_X ~", paste(names(globulus)[5:6], collapse = "+"))),
data = globulus
)
#> Using default initial variances given by default_initial_variance()
#> See ?breedR.getOption.
all.equal(res, res0)
#> [1] TRUE
Created on 2022-09-26 with reprex v2.0.2
--
Report issues at https://github.com/famuvie/breedR/issues
---
You received this message because you are subscribed to the Google Groups "breedR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to breedr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/breedr/5e2b4c62-2f7e-4da0-8060-72faab9b2aaan%40googlegroups.com.