Comments (2)
Hi all
First of all, thanks for an awesome package!
I have encountered a similar issue to barbosawf. For me, the problem is that there are less rows in the replacement compared to data when I add a 2D-spline to account for spatial effects in my model.
I can work around this by creating a custom Dtable (i.e. remove an "unused" row from model$Dtable) and specifying the Dtable argugment in predict.mmer.
Although this is a bit ugly, it seems to work in my case.
Yet, there seems to be a problem in the "if (is.null(Dtable) & is.character(D)) {...." part of predict.mmer and it would be good to have a proper solution.
Please find a reproducible example below.
Many thanks!
#==============================================
# Example
## sommer version: 4.3.2 (2023-09-01)
## R version 4.2.1 (2022-06-23 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 22621)
#==============================================
library(sommer)
# get data
data(DT_cpdata)
DT <- DT_cpdata
GT <- GT_cpdata
MP <- MP_cpdata
A <- A.mat(GT)
# fit basic model
m <- mmer(Yield~1,
random = ~vsr(id, Gu=A) +
vsr(Rowf) +
vsr(Colf),
rcov = ~vsr(units),
data=DT,
verbose = FALSE, dateWarning = FALSE)
# fit model using 2D p-spline for spatial correction
m_spl2Da <- mmer(Yield~1,
random = ~vsr(id, Gu=A) +
vsr(Rowf) +
vsr(Colf) +
spl2Da(Row,Col),
rcov=~vsr(units),
data=DT,
nIters = 3, verbose = FALSE, dateWarning = FALSE)
# predict
pr_m <- predict(m,D="id") # works
pr_m_spl2Da <- predict(m_spl2Da,D="id") # Error in `$<-.data.frame`(`*tmp*`, "start", value = c(1, 2, 365, 378, :
# replacement has 5 rows, data has 6
m$Dtable
pr_m$Dtable
m_spl2Da$Dtable
# remove 'unused' row from Dtable and specify terms to be included/averaged
Dt <- m_spl2Da$Dtable
Dt[Dt$term == "1","include"] = TRUE
Dt[Dt$term == "1","average"] = TRUE
Dt[Dt$term == "id","include"] = TRUE
Dt <- Dt[-6,]
# predict by specifying 'custom' Dtable
pr_m_spl2Da<- predict(m_spl2Da,D="id",Dtable = Dt)
pr_m_spl2Da$Dtable
# inspect
summary(m)
summary(m_spl2Da)
plot(pr_m$pvals$predicted.value,pr_m_spl2Da$pvals$predicted.value) # prediction seems OK
from sommer.
I apologize for the slow response. The predict function for mmer() is indeed a headache, I am trying to rewrite all formulae of mmer but is taking me more than I thought. You can try mmec() and the predict function from that one. That second function uses the ideal formulae and is easy to keep the predict function easy to build.
from sommer.
Related Issues (20)
- predict function when spl2D is used HOT 4
- predict() error in cross-validation HOT 6
- Facing error at the stage of A.mat HOT 3
- Can't get mmec to run HOT 4
- mmec using weights (W) HOT 5
- mmer fails when number of observations > 2^15 HOT 4
- Poisson and Negative Bionomial Distributed Traits HOT 2
- how to add permanent environmental effect in random regression model ? HOT 1
- Throw error for singular system HOT 6
- GWAS entries in CHANGELOG and documentation HOT 2
- Predict.mmec function issue HOT 1
- Different varcomp estimates between sommer and ASReml-R when it is bounded HOT 1
- multivariate model specification with different fixed effects per trait HOT 1
- Possible mix up between VanRaden and Endleman GRMs HOT 1
- Cooks distance HOT 2
- multivariate (multi-trait) for modeling GCA HOT 5
- Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD HOT 6
- thetaC constraint in isc, dsc, ... functions: lack of documentation HOT 1
- Factor analytic covariance structure updates during REML HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sommer.