Title: | Hierarchical Spatial Finlay-Wilkinson Model |
---|---|
Description: | Estimation and Prediction Functions Using Bayesian Hierarchical Spatial Finlay-Wilkinson Model for Analysis of Multi-Environment Field Trials. |
Authors: | Xingche Guo <[email protected]> |
Maintainer: | Xingche Guo <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-25 06:51:11 UTC |
Source: | CRAN |
This function ignores spatial effects.
HFWM_est(Y, VAR, ENV, kin_info = FALSE, A = NULL, env_info = FALSE, Z = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, save_chain = FALSE, seed = NULL)
HFWM_est(Y, VAR, ENV, kin_info = FALSE, A = NULL, env_info = FALSE, Z = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, save_chain = FALSE, seed = NULL)
Y |
A length-N numerical response vector |
VAR |
A length-N factor/character vector indicating the genotype information of Y |
ENV |
A length-N factor/character vector indicating the field information of Y |
kin_info |
A logical parameter controling if to use kinship matrix |
A |
kinship matrix, give value only if kin_info = TRUE |
env_info |
A logical parameter controling whether to use environmental covariates |
Z |
environmental covariates matrix with rownames = field names, give value only if env_info = TRUE |
inits |
initial values, default is given |
hyper_para |
hyper-parameter values, default is given |
M_iter |
Total iteration number |
burn_in |
Burn in number |
thin |
Thinning value |
save_chain |
A logical parameter controling whether to save MCMC chain: 'Chains.rds' in current working directory |
seed |
Random seed value |
Mean estimates and RMSE value
library(spFW) # load data data(spFW_example_data) Y <- spFW_example_data$yield VAR <- spFW_example_data$geno ENV <- spFW_example_data$loc COOR <- spFW_example_data[,c(4,5)] # run model fit0 <- HFWM_est(Y, VAR, ENV, M_iter = 1000, burn_in = 500, thin = 5) # plot estimated Y plot(Y, fit0$yhat)
library(spFW) # load data data(spFW_example_data) Y <- spFW_example_data$yield VAR <- spFW_example_data$geno ENV <- spFW_example_data$loc COOR <- spFW_example_data[,c(4,5)] # run model fit0 <- HFWM_est(Y, VAR, ENV, M_iter = 1000, burn_in = 500, thin = 5) # plot estimated Y plot(Y, fit0$yhat)
This function ignores spatial effects.
HFWM_pred(Y, VAR, ENV, VAR2, ENV2, save_int = FALSE, kin_info = FALSE, A = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, seed = NULL)
HFWM_pred(Y, VAR, ENV, VAR2, ENV2, save_int = FALSE, kin_info = FALSE, A = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, seed = NULL)
Y |
A length-N1 numerical response vector from training set |
VAR |
A length-N1 factor/character vector indicating the genotype information of Y |
ENV |
A length-N1 factor/character vector indicating the field information of Y |
VAR2 |
A length-N2 factor/character vector indicating the genotype information of testing set |
ENV2 |
A length-N2 factor/character vector indicating the field information of of testing set |
save_int |
A logical parameter controling whether to save prediction credible intervals |
kin_info |
A logical parameter controling if to use kinship matrix |
A |
kinship matrix, give value only if kin_info = TRUE |
inits |
initial values, default is given |
hyper_para |
hyper-parameter values, default is given |
M_iter |
Total iteration number |
burn_in |
Burn in number |
thin |
Thinning value |
seed |
Random seed value |
Mean prediction values and/or prediction intervals
library(spFW) # load and split data data(spFW_example_data) idx_pred <- sample(125, 25) Y0 <- spFW_example_data$yield VAR0 <- spFW_example_data$geno ENV0 <- spFW_example_data$loc Y1 <- Y0[-idx_pred] Y2 <- Y0[idx_pred] VAR1 <- VAR0[-idx_pred] VAR2 <- VAR0[idx_pred] ENV1 <- ENV0[-idx_pred] ENV2 <- ENV0[idx_pred] order_y <- order(Y2) # run model pred0 <- HFWM_pred(Y1, VAR1, ENV1, VAR2, ENV2, save_int = TRUE, M_iter = 1000, burn_in = 500, thin = 5) # visualize prediction results plot(1:25, pred0$PY[order_y], ylim = c(50, 250), pch = 15, col = "red", xlab = "Plant ID for Prediction", ylab = "Yield", main = "95% Prediction Intervals with Predicted Mean (Red) Versus True Yield (Blue)") points(1:25, Y2[order_y], col = "blue") for (i in 1:25){ lines(x = c(i,i), y = c(pred0$PY_CI[,order_y][1,i], pred0$PY_CI[,order_y][4,i])) }
library(spFW) # load and split data data(spFW_example_data) idx_pred <- sample(125, 25) Y0 <- spFW_example_data$yield VAR0 <- spFW_example_data$geno ENV0 <- spFW_example_data$loc Y1 <- Y0[-idx_pred] Y2 <- Y0[idx_pred] VAR1 <- VAR0[-idx_pred] VAR2 <- VAR0[idx_pred] ENV1 <- ENV0[-idx_pred] ENV2 <- ENV0[idx_pred] order_y <- order(Y2) # run model pred0 <- HFWM_pred(Y1, VAR1, ENV1, VAR2, ENV2, save_int = TRUE, M_iter = 1000, burn_in = 500, thin = 5) # visualize prediction results plot(1:25, pred0$PY[order_y], ylim = c(50, 250), pch = 15, col = "red", xlab = "Plant ID for Prediction", ylab = "Yield", main = "95% Prediction Intervals with Predicted Mean (Red) Versus True Yield (Blue)") points(1:25, Y2[order_y], col = "blue") for (i in 1:25){ lines(x = c(i,i), y = c(pred0$PY_CI[,order_y][1,i], pred0$PY_CI[,order_y][4,i])) }
This function considers spatial adjustments.
HSFWM_est(Y, VAR, ENV, COOR, kin_info = FALSE, A = NULL, env_info = FALSE, Z = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, save_chain = FALSE, seed = NULL)
HSFWM_est(Y, VAR, ENV, COOR, kin_info = FALSE, A = NULL, env_info = FALSE, Z = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, save_chain = FALSE, seed = NULL)
Y |
A length-N numerical response vector |
VAR |
A length-N factor/character vector indicating the genotype information of Y |
ENV |
A length-N factor/character vector indicating the field information of Y |
COOR |
A N by 2 numerical matrix indicating the spatial locations of Y |
kin_info |
A logical parameter controling if to use kinship matrix |
A |
kinship matrix, give value only if kin_info = TRUE |
env_info |
A logical parameter controling whether to use environmental covariates |
Z |
environmental covariates matrix with rownames = field names, give value only if env_info = TRUE |
inits |
initial values, default is given |
hyper_para |
hyper-parameter values, default is given |
M_iter |
Total iteration number |
burn_in |
Burn in number |
thin |
Thinning value |
save_chain |
A logical parameter controling whether to save MCMC chain: 'Chains.rds' in current working directory |
seed |
Random seed value |
Mean estimates and RMSE value
library(spFW) # load data data(spFW_example_data) Y <- spFW_example_data$yield VAR <- spFW_example_data$geno ENV <- spFW_example_data$loc COOR <- spFW_example_data[,c(4,5)] # run model fit1 <- HSFWM_est(Y, VAR, ENV, COOR, M_iter = 1000, burn_in = 500, thin = 5) # plot estimated Y plot(Y, fit1$yhat)
library(spFW) # load data data(spFW_example_data) Y <- spFW_example_data$yield VAR <- spFW_example_data$geno ENV <- spFW_example_data$loc COOR <- spFW_example_data[,c(4,5)] # run model fit1 <- HSFWM_est(Y, VAR, ENV, COOR, M_iter = 1000, burn_in = 500, thin = 5) # plot estimated Y plot(Y, fit1$yhat)
This function considers spatial adjustments.
HSFWM_pred(Y, VAR, ENV, COOR, VAR2, ENV2, COOR2, save_int = FALSE, kin_info = FALSE, A = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, seed = NULL)
HSFWM_pred(Y, VAR, ENV, COOR, VAR2, ENV2, COOR2, save_int = FALSE, kin_info = FALSE, A = NULL, inits = NULL, hyper_para = NULL, M_iter = 5000, burn_in = 3000, thin = 5, seed = NULL)
Y |
A length-N1 numerical response vector from training set |
VAR |
A length-N1 factor/character vector indicating the genotype information of Y |
ENV |
A length-N1 factor/character vector indicating the field information of Y |
COOR |
A N1 by 2 numerical matrix indicating the spatial locations of Y |
VAR2 |
A length-N2 factor/character vector indicating the genotype information of testing set |
ENV2 |
A length-N2 factor/character vector indicating the field information of of testing set |
COOR2 |
A N2 by 2 numerical matrix indicating the spatial locations of testing set |
save_int |
A logical parameter controling whether to save prediction credible intervals |
kin_info |
A logical parameter controling if to use kinship matrix |
A |
kinship matrix, give value only if kin_info = TRUE |
inits |
initial values, default is given |
hyper_para |
hyper-parameter values, default is given |
M_iter |
Total iteration number |
burn_in |
Burn in number |
thin |
Thinning value |
seed |
Random seed value |
Mean prediction values and/or prediction intervals
library(spFW) # load and split data data(spFW_example_data) idx_pred <- sample(125, 25) Y0 <- spFW_example_data$yield VAR0 <- spFW_example_data$geno ENV0 <- spFW_example_data$loc COOR0 <- spFW_example_data[,c(4,5)] Y1 <- Y0[-idx_pred] Y2 <- Y0[idx_pred] VAR1 <- VAR0[-idx_pred] VAR2 <- VAR0[idx_pred] ENV1 <- ENV0[-idx_pred] ENV2 <- ENV0[idx_pred] COOR1 <- COOR0[-idx_pred,] COOR2 <- COOR0[idx_pred,] order_y <- order(Y2) # run model pred1 <- HSFWM_pred(Y1, VAR1, ENV1, COOR1, VAR2, ENV2, COOR2, save_int = TRUE, M_iter = 1000, burn_in = 500, thin = 5) # visualize prediction results plot(1:25, pred1$PY[order_y], ylim = c(50, 250), pch = 15, col = "red", xlab = "Plant ID for Prediction", ylab = "Yield", main = "95% Prediction Intervals with Predicted Mean (Red) Versus True Yield (Blue)") points(1:25, Y2[order_y], col = "blue") for (i in 1:25){ lines(x = c(i,i), y = c(pred1$PY_CI[,order_y][1,i], pred1$PY_CI[,order_y][4,i])) }
library(spFW) # load and split data data(spFW_example_data) idx_pred <- sample(125, 25) Y0 <- spFW_example_data$yield VAR0 <- spFW_example_data$geno ENV0 <- spFW_example_data$loc COOR0 <- spFW_example_data[,c(4,5)] Y1 <- Y0[-idx_pred] Y2 <- Y0[idx_pred] VAR1 <- VAR0[-idx_pred] VAR2 <- VAR0[idx_pred] ENV1 <- ENV0[-idx_pred] ENV2 <- ENV0[idx_pred] COOR1 <- COOR0[-idx_pred,] COOR2 <- COOR0[idx_pred,] order_y <- order(Y2) # run model pred1 <- HSFWM_pred(Y1, VAR1, ENV1, COOR1, VAR2, ENV2, COOR2, save_int = TRUE, M_iter = 1000, burn_in = 500, thin = 5) # visualize prediction results plot(1:25, pred1$PY[order_y], ylim = c(50, 250), pch = 15, col = "red", xlab = "Plant ID for Prediction", ylab = "Yield", main = "95% Prediction Intervals with Predicted Mean (Red) Versus True Yield (Blue)") points(1:25, Y2[order_y], col = "blue") for (i in 1:25){ lines(x = c(i,i), y = c(pred1$PY_CI[,order_y][1,i], pred1$PY_CI[,order_y][4,i])) }
A data frame containing the plant yield, genotypes, environments, and within-field positions.
spFW_example_data
spFW_example_data
A data frame with 5 elements, which are:
Plant yield
Plant genotype ID
Plant environment ID
Plant x-coordinate at a given environment
Plant y-coordinate at a given environment