-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from SticsRPacks/AgMIP_phaseIV
Improvements for AgMIP calibration phase IV
- Loading branch information
Showing
58 changed files
with
347 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#' @title Compute equality constraints on model wrapper input parameters | ||
#' | ||
#' @inheritParams estim_param | ||
#' @param param_values Named vector or tibble, value(s) of the estimated parameters | ||
#' as provided by the parameter estimation algorithm (and possibly transformed in | ||
#' main_crit function) | ||
#' | ||
#' @return Named vector or tibble (same shape as param_values) containing the values | ||
#' for the model parameters to force. | ||
#' | ||
#' @keywords internal | ||
#' | ||
compute_eq_const <- function(forced_param_values, param_values) { | ||
|
||
comp_forced_values <- NULL | ||
if (!is.null(forced_param_values)) { | ||
|
||
param_values <- tibble::tibble(!!!param_values) | ||
param_values$situation <- NULL | ||
nrows <- max(1,seq_len(nrow(param_values))) | ||
comp_forced_values <- matrix(ncol = length(forced_param_values), | ||
nrow = nrows) | ||
colnames(comp_forced_values) <- names(forced_param_values) | ||
|
||
for (irow in nrows) { | ||
|
||
expr_ls <- | ||
lapply(names(forced_param_values), function(x) paste(x,"<-",forced_param_values[[x]])) | ||
names(expr_ls) <- names(forced_param_values) | ||
|
||
for (par in names(param_values)) { | ||
eval(parse(text = paste(par,"<-",param_values[[irow, par]]))) | ||
} | ||
for (par in names(forced_param_values)) { | ||
eval(parse(text = expr_ls[[par]])) | ||
eval(parse(text = paste0("comp_forced_values[irow,\"",par,"\"] <- ",par))) | ||
} | ||
|
||
} | ||
|
||
if (nrows==1) { | ||
comp_forced_values <- comp_forced_values[1,] | ||
} else { | ||
comp_forced_values <- tibble::as_tibble(comp_forced_values) | ||
} | ||
|
||
} | ||
|
||
return(comp_forced_values) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.