Skip to content
Snippets Groups Projects
Commit 219df790 authored by dj44vuri's avatar dj44vuri
Browse files

added exported functions subcoef and remGOF

parent d3ae44c2
Branches
No related tags found
1 merge request!1functions generally improved and made packagelike, quicktexregapollo added...
...@@ -3,4 +3,6 @@ ...@@ -3,4 +3,6 @@
export("%>%") export("%>%")
export(createSets) export(createSets)
export(quicktexregapollo) export(quicktexregapollo)
export(remGOF)
export(subcoef)
importFrom(magrittr,"%>%") importFrom(magrittr,"%>%")
...@@ -26,7 +26,7 @@ quicktexregapollo <- function(model = model, wtpest = NULL, se="rob") { ...@@ -26,7 +26,7 @@ quicktexregapollo <- function(model = model, wtpest = NULL, se="rob") {
stop(" It seems you did not do bootstrapping. Thus, I cannot report bootstrapped se. The 'model' object must contain an element named 'bootse' when 'se' is 'bs'.") stop(" It seems you did not do bootstrapping. Thus, I cannot report bootstrapped se. The 'model' object must contain an element named 'bootse' when 'se' is 'bs'.")
} }
browser()
modelOutput_settings = list(printPVal=T) modelOutput_settings = list(printPVal=T)
if (is.null(wtpest)) { if (is.null(wtpest)) {
......
#' Remove unnecessary statistics from Table for TexReg
#'
#' @param models the models you want to delete the GOF statistics
#'
#' @return a list with the same models as in models but without GOF statistics
#' @export
#'
#' @examples {
#' est_model <- readRDS(system.file("extdata", "mixlogitInt_bootstrap.RDS", package = "choiceTools"))
#' ## make full model in one column using texreg
#' full_model <- quicktexregapollo(est_model, se="normal")
#' texreg::screenreg(full_model)
#' ## split the model to different columns, e.g. for mean, sd, sample_interactions
#' splitmodels <- purrr::map(c("mean_","sd_" , paste0("_s",c(2:6)) ) ,subcoef,full_model)
#' texreg::screenreg(splitmodels)
#' ## the same, but make sure gof statistics are shown only once
#' texreg::screenreg(c(splitmodels[[1]],remGOF(splitmodels[2:7] ) ) )
#' }
remGOF<- function(models){ remGOF<- function(models){
gof<- function(m){ gof<- function(m){
......
# function to split model into different columns for texreg
#' Title function to split model into different columns for texreg
#'
#' @param condition The stub that is common for all parameters you want to split. For example 'mean'
#' @param mname The name of the model you want to split
#'
#' @return a new texreg object with only the selected column (for example the model output with only the mean parameters)
#' @export
#'
#' @examples {
#' est_model <- readRDS(system.file("extdata", "mixlogitInt_bootstrap.RDS", package = "choiceTools"))
#' ## make full model in one column using texreg
#' full_model <- quicktexregapollo(est_model, se="normal")
#' texreg::screenreg(full_model)
#' ## split the model to different columns, e.g. for mean, sd, sample_interactions
#' splitmodels <- purrr::map(c("mean_","sd_" , paste0("_s",c(2:6)) ) ,subcoef,full_model)
#' texreg::screenreg(splitmodels)
#' ## the same, but make sure gof statistics are shown only once
#' texreg::screenreg(c(splitmodels[[1]],remGOF(splitmodels[2:7] ) ) )
#'
#' }
subcoef <- function(condition, mname){ subcoef <- function(condition, mname){
sub <- grep(condition,methods::slot(mname,"coef.names")) sub <- grep(condition,methods::slot(mname,"coef.names"))
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/remGOF.R
\name{remGOF}
\alias{remGOF}
\title{Remove unnecessary statistics from Table for TexReg}
\usage{
remGOF(models)
}
\arguments{
\item{models}{the models you want to delete the GOF statistics}
}
\value{
a list with the same models as in models but without GOF statistics
}
\description{
Remove unnecessary statistics from Table for TexReg
}
\examples{
{
est_model <- readRDS(system.file("extdata", "mixlogitInt_bootstrap.RDS", package = "choiceTools"))
## make full model in one column using texreg
full_model <- quicktexregapollo(est_model, se="normal")
texreg::screenreg(full_model)
## split the model to different columns, e.g. for mean, sd, sample_interactions
splitmodels <- purrr::map(c("mean_","sd_" , paste0("_s",c(2:6)) ) ,subcoef,full_model)
texreg::screenreg(splitmodels)
## the same, but make sure gof statistics are shown only once
texreg::screenreg(c(splitmodels[[1]],remGOF(splitmodels[2:7] ) ) )
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/subcoef.R
\name{subcoef}
\alias{subcoef}
\title{Title function to split model into different columns for texreg}
\usage{
subcoef(condition, mname)
}
\arguments{
\item{condition}{The stub that is common for all parameters you want to split. For example 'mean'}
\item{mname}{The name of the model you want to split}
}
\value{
a new texreg object with only the selected column (for example the model output with only the mean parameters)
}
\description{
Title function to split model into different columns for texreg
}
\examples{
{
est_model <- readRDS(system.file("extdata", "mixlogitInt_bootstrap.RDS", package = "choiceTools"))
## make full model in one column using texreg
full_model <- quicktexregapollo(est_model, se="normal")
texreg::screenreg(full_model)
## split the model to different columns, e.g. for mean, sd, sample_interactions
splitmodels <- purrr::map(c("mean_","sd_" , paste0("_s",c(2:6)) ) ,subcoef,full_model)
texreg::screenreg(splitmodels)
## the same, but make sure gof statistics are shown only once
texreg::screenreg(c(splitmodels[[1]],remGOF(splitmodels[2:7] ) ) )
}
}
rm(list = ls())
devtools::load_all()
est_model <- readRDS(system.file("extdata", "mixlogitInt_bootstrap.RDS", package = "choiceTools"))
## make full model in one column using texreg
full_model <- quicktexregapollo(est_model, se="normal")
texreg::screenreg(full_model)
## split the model to different columns, e.g. for mean, sd, sample_interactions
splitmodels <- purrr::map(c("mean_","sd_" , paste0("_s",c(2:6)) ) ,subcoef,full_model)
texreg::screenreg(splitmodels)
## the same, but make sure gof statistics are shown only once
texreg::screenreg(c(splitmodels[[1]],remGOF(splitmodels[2:7] ) ) )
janitor::clean_names(apollo::apollo_modelOutput(est_model))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment