jenniferthompson / jthelpers Goto Github PK
View Code? Open in Web Editor NEWA package of helper functions for my own frequent use.
A package of helper functions for my own frequent use.
create_countprocess_data
shouldn't import anything from dplyr, tidyr, magrittr"P values larger than 0.01 should be reported to two decimal places, and those between 0.01 and 0.001 to three decimal places; P values smaller than 0.001 should be reported as P<0.001. Notable exceptions to this policy include P values arising from the application of stopping rules to the analysis of clinical trials and from genetic-screening studies."
create_countprocess_data()
breaks if
data.set[, time.var]
is missing for a given IDMight be good to fix that. Or at least give better warnings so people know to take care of it on the front end.
Also, let people name the status variable something other than died
. Confusing when the event isn't death.
Originally written for DelDepLTCI
## -- Function to make huxtable from rms_model_results() df + col headers ------
make_modresults_ht <- function(resultsdf){
ht <- resultsdf %>%
hux() %>%
## Align variable name to left, all other columns to right
set_align(row = everywhere, col = everywhere, byrow = TRUE,
value = c("left", rep("right", ncol(resultsdf) - 1))) %>%
## Set p-value column to three decimal places by default
set_number_format(row = everywhere, col = 7, value = 3) %>%
## Bold column headers, add line after first row
set_bold(row = 1, col = everywhere, TRUE) %>%
set_bottom_border(row = 1, col = everywhere, value = 1) %>%
## Gray out all info except the row for history of depression, our main
## exposure of interest
set_text_color(
row = grep("^hx\\.depression$", resultsdf$label, invert = TRUE),
col = everywhere,
value = "#838383"
) %>%
## Table should take up 90% of document width
set_width(0.9)
}
Should work pretty much like lrm()
Many thanks to Yonghao Pua for catching this and creating a reprex.
Currently, rms_model_results() works beautifully with ols and lrm objects but I'm wondering if you could very kindly extend its reach to Gls objects. With orm objects, rms_model_results() works reasonably well; with Gls objects, it balks with an error message: "Error in label == "d.f." : comparison (1) is possible only for atomic and list types". Below, I provide a minimal example.
rm(list=ls())
library(plyr)
library(dplyr)
library(tidyr)
library(rms)
library(JTHelpers)
# create tall-and-thin longitudinal dataframe
longdf <- data.frame(
expand.grid(id = seq(1:10), time = 1:5), outcome = round(runif(50, 2, 12), 0)
)
longdf <- longdf %>%
arrange(id, time) %>%
mutate( age = rep(round(runif(10, 20, 60),0), each = 5 ))
longdf.dd <- datadist(longdf); options(datadist = "longdf.dd")
glsmod <-Gls(outcome~ time + rcs(age,3), correlation = corCAR1 (form=~time|id), data=longdf)
glsmod; summary(glsmod); anova(glsmod)
rms_model_results(glsmod) # throws error mesage
Error in label == "d.f." : comparison (1) is possible only for atomic and list types
It would be nice if shortlabels
could be extended to apply to all terms (not just interactions) if the user chooses. If that's not doable, clarify the docs.
eg,
comp.string
B vs A
is more intuitive than
low high
A B
๐ข
It's in the stop.day
calculation.
Currently requires a data.frame with labelled variables to use variable labels instead of variable names. This creates issues with tibbles or data.frames that we want to use with tidyverse functions. Make it more flexible, to take either a data.frame or a named vector, eg c(age = "Age at consent")
.
Argument name is lrmObj
but Arguments includes rmsObj
.
Ideas:
When no labeldf
is passed, unexpected results for categorical variables (this is from fit.mult.impute()
with fitter = lrm
, not sure if it affects others):
12 race.comb 0.3 1
13 race.comb...Non.white.White 1.00 2.00 0.83 (0.43, 1.62) <NA>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.