R/survival_model_results_function_stricta.R

Defines functions survival_model_results_function_stricta

Documented in survival_model_results_function_stricta

#' Create table of survival model results
#' 
#' @param convergence.status
#' @param parameter.estimates
#' @param fit.statistics
#' @param replace_list
#' @param select_list
#' 
#' @export

survival_model_results_function_stricta <- function(
	convergence.status, 
	parameter.estimates, 
	fit.statistics
)
{
	# filter out models that didn't converge
	y = merge(convergence.status, parameter.estimates) %>%
		filter(Reason=="Algorithm converged.") %>%
		# change effects to columns
		dcast(modelVars~Parameter, value.var="Estimate", fun=sum)
		# fit statistics
	z = fit.statistics %>%
		filter(Criterion=="AIC (smaller is better)" | Criterion=="Scaled Deviance") %>%
		dcast(modelVars~Criterion, value.var="Value") %>%
		setnames("AIC (smaller is better)", "AIC") 
	y %<>% merge(z, by="modelVars") %>% 
	arrange(modelVars)
	y %<>%
	mutate(
		Intercept = paste(
			Intercept %>% round(2),
			" [",
			parameter.estimates[which(parameter.estimates$Parameter=="Intercept"), ]$LowerLRCL[1] %>% round(2),
			", ",
			parameter.estimates[which(parameter.estimates$Parameter=="Intercept"), ]$UpperLRCL[1] %>% round(2),
			"]",
			sep=""
		),
		`C_t` = paste(
			Ln_Size_t_1_st %>% round(2),
			" [",
			parameter.estimates[which(parameter.estimates$Parameter=="Ln_Size_t_1_st"), ]$LowerLRCL[1] %>% round(2),
			", ",
			parameter.estimates[which(parameter.estimates$Parameter=="Ln_Size_t_1_st"), ]$UpperLRCL[1] %>% round(2),
			"]",
			sep=""
		)
	) %>%
	dplyr::select(
		Intercept, 
		C_t,
		`Scaled Deviance`
	)
	return(y)
}
ksauby/modresproc documentation built on Sept. 22, 2017, 8:53 a.m.