Skip to content

Commit

Permalink
working missing data imputation; documentation tweaks and minor bug f…
Browse files Browse the repository at this point in the history
…ixes
  • Loading branch information
tonymugen committed Feb 13, 2020
1 parent 0376cfb commit c700f28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion R/interfaceFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#'
#' Fits a mixture model to the provided data, taking into account replication structure. Takes data on multiple traits and generates samples from posterior distributions of parameters, as well as probabilities that a line belongs to a given population. The fit is performed using a No-U-Turn Sampler (NUTS). The recommended burn-in, sampling, number of chains, and thinning are set as defaults.
#'
#' Missing phenotype data are allowed. It is recommended that rows with all trait data missing are eliminated before running the function. If such rows are present, they will be eliminated by the function and a warning is issued. If all data for a given line are missing, this line is also dropped from consideration. The function does its best to retain the user provided factor level ordering, however such behavior may not be desired by some users, hence the warning. The (potentially modified) line factor is returned by the function to aid in trouble shooting.
#'
#' @note Currently exactly one level of replication is supported.
#'
#' @param data data frame with the data
Expand All @@ -31,7 +33,7 @@
#' @param n.sampling number of sampling steps
#' @param n.thin thinning number (if, e.g., set to five then every fifth chain sample is saved)
#' @param n.chains number of chains
#' @return S3 object of class \code{mugamix} that contains matrix of parameter chains (named \code{parChains}, each chain a column), a matrix of population assignments (named \code{popChains}), a matrix of population numbers (named \code{nPopsChain}), and a matrix of imputed missing data (if any; named \code{imputed})
#' @return S3 object of class \code{mugamix} that contains matrix of parameter chains (named \code{parChains}, each chain a column), a matrix of population assignments (named \code{popChains}), a matrix of population numbers (named \code{nPopsChain}), a matrix of imputed missing data (if any; named \code{imputed}), and the line factor used in model fitting (possibly modified from the user's input if missing rows are eliminated; named \code{lineFactor})
#'
#' @export
fitModel <- function(data, trait.colums, factor.column, n.pop, n.burnin = 5000, n.sampling = 10000, n.thin = 5, n.chains = 5){
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
This is an R package to assign individuals to populations based on phenotypic data from multiple traits. It uses Bayesian inference and Hamiltonian Monte Carlo to fit the model. Goodness of fit is assessed using Bayes factors which allow to choose the most likely number of populations.

The package is still in development. Basic model fitting with one level of replication, no missing phenotype data, and no covariates, is functional. The following functionality is in development:
The package is still in development. Basic model fitting with one level of replication and no covariates is functional. The following functionality is in development:

- Bayes factors to assess goodness of fit and reasonable population number
- Functions to summarize results and provide convergence diagnostics
- Disambiguation of population labels
- Support for missing phenotype data
- Support for covariates
- Arbitrary replication levels (including no replication)

Expand Down
4 changes: 2 additions & 2 deletions src/mumimo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ void WrapMMM::runSampler(const uint32_t &Nadapt, const uint32_t &Nsample, const
sortPops_();
updatePi_();
updatePz_();
if ( (Nsample%Nthin) == 0) {
if ( (b%Nthin) == 0) {
for (auto &t : vTheta_) {
thetaChain.push_back(t);
}
Expand Down Expand Up @@ -1201,7 +1201,7 @@ void WrapMMM::runSampler(const uint32_t &Nadapt, const uint32_t &Nsample, const
updatePi_();
updatePz_();
imputeMissing_();
if ( (Nsample%Nthin) == 0) {
if ( (b%Nthin) == 0) {
for (auto &t : vTheta_) {
thetaChain.push_back(t);
}
Expand Down

0 comments on commit c700f28

Please sign in to comment.