Thank you for the many requests to provide some extra info on how best to get finalfit results out of RStudio, and particularly into Microsoft Word. Here is how. Make sure you are on the most up-to-date version of finalfit. devtools::install_github(“ewenharrison/finalfit”) What follows is for demonstration purposes and is not meant to illustrate model building. Does a tumour characteristic (differentiation) predict 5-year survival? Demographics table First explore variable of interest (exposure) by making it the dependent. library(finalfit) library(dplyr) dependent = “differ.factor” # Specify explanatory variables of interest explanatory = c(“age”, “sex.factor”, “extent.factor”, “obstruct.factor”, “nodes”) Note this useful alternative way of specifying explanatory variable lists: colon_s %>% select(age, sex.factor, extent.factor, obstruct.factor, nodes) %>% names() -> explanatory Look at associations between our exposure and other explanatory variables. Include missing data. colon_s %>% summary_factorlist(dependent, explanatory, p=TRUE, na_include=TRUE) label levels Well Moderate Poor p…

Original Post: Finalfit, knitr and R Markdown for quick results

# Posts by Ewen Harrison

## Elegant regression results tables and plots in R: the finalfit package

The finafit package brings together the day-to-day functions we use to generate final results tables and plots when modelling. I spent many years repeatedly manually copying results from R analyses and built these functions to automate our standard healthcare data workflow. It is particularly useful when undertaking a large study involving multiple different regression analyses. When combined with RMarkdown, the reporting becomes entirely automated. Its design follows Hadley Wickham’s tidy tool manifesto. Installation and Documentation It lives on GitHub. You can install finalfit from github with: # install.packages(“devtools”) devtools::install_github(“ewenharrison/finalfit”) It is recommended that this package is used together with dplyr, which is a dependent. Some of the functions require rstan and boot. These have been left as Suggests rather than Depends to avoid unnecessary installation. If needed, they can be installed in the normal way: install.packages(“rstan”) install.packages(“boot”) To install off-line…

Original Post: Elegant regression results tables and plots in R: the finalfit package

## Install github package on safe haven server

I’ve had few enquires about how to install the summarizer package on a server without internet access, such as the NHS Safe Havens. Upload summarizer-master.zip from here to server. Unzip. Run this: library(devtools)source = devtools:::source_pkg(“summarizer-master”)install(source) Related To leave a comment for the author, please follow the link and comment on their blog: R – DataSurg. R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more… If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook…

Original Post: Install github package on safe haven server

## P-values from random effects linear regression models

lme4::lmer is a useful frequentist approach to hierarchical/multilevel linear regression modelling. For good reason, the model output only includes t-values and doesn’t include p-values (partly due to the difficulty in estimating the degrees of freedom, as discussed here). Yes, p-values are evil and we should continue to try and expunge them from our analyses. But I keep getting asked about this. So here is a simple bootstrap method to generate two-sided parametric p-values on the fixed effects coefficients. Interpret with caution. library(lme4) # Run model with lme4 example data fit = lmer(angle ~ recipe + temp + (1|recipe:replicate), cake) # Model summary summary(fit) # lme4 profile method confidence intervals confint(fit) # Bootstrapped parametric p-values boot.out = bootMer(fit, fixef, nsim=1000) #nsim determines p-value decimal places p = rbind( (1-apply(boot.out$t<0, 2, mean))*2, (1-apply(boot.out$t>0, 2, mean))*2) apply(p, 2, min) # Alternative “pipe” syntax…

Original Post: P-values from random effects linear regression models