mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-24 12:41:54 +01:00
updates
This commit is contained in:
parent
662d111f0b
commit
3573b74a1b
@ -1,7 +1,7 @@
|
||||
Package: daDoctoR
|
||||
Type: Package
|
||||
Title: FUNCTIONS FOR HEALTH RESEARCH
|
||||
Version: 0.1.0.9024
|
||||
Version: 0.1.0.9025
|
||||
Author: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
|
||||
Maintainer: Andreas Gammelgaard Damsbo <agdamsbo@pm.me>
|
||||
Description: I am a Danish medical doctor involved in neuropsychiatric research.
|
||||
|
@ -3,7 +3,7 @@
|
||||
#' Printable table of three dimensional regression analysis of group vs var for meas. By group.
|
||||
#' @param meas outcome meassure variable name in data-data.frame as a string. Can be numeric or factor. Result is calculated accordingly.
|
||||
#' @param var binary exposure variable to compare against (active vs placebo). As string.
|
||||
#' @param groups groups to compare, as string.
|
||||
#' @param group group to compare, as string.
|
||||
#' @param adj variables to adjust for, as string.
|
||||
#' @param data dataframe of data.
|
||||
#' @param dec decimals for results, standard is set to 2. Mean and sd is dec-1. pval has 3 decimals.
|
||||
|
@ -3,7 +3,7 @@
|
||||
#' Printable table of three dimensional regression analysis of group vs var for meas. By var. Includes p-values.
|
||||
#' @param meas outcome meassure variable name in data-data.frame as a string. Can be numeric or factor. Result is calculated accordingly.
|
||||
#' @param var binary exposure variable to compare against (active vs placebo). As string.
|
||||
#' @param groups groups to compare, as string.
|
||||
#' @param group groups to compare, as string.
|
||||
#' @param adj variables to adjust for, as string.
|
||||
#' @param data dataframe of data.
|
||||
#' @param dec decimals for results, standard is set to 2. Mean and sd is dec-1.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#' Print regression results according to STROBE
|
||||
#' Print ordinal logistic regression results according to STROBE
|
||||
#'
|
||||
#' Printable table of logistic regression analysis oaccording to STROBE.
|
||||
#' Printable table of ordinal logistic regression analysis oaccording to STROBE. Uses polr() funtion of the MASS-package.
|
||||
#' @param meas outcome meassure variable name in data-data.frame as a string. Can be numeric or factor. Result is calculated accordingly.
|
||||
#' @param vars variables to compare against. As vector of columnnames.
|
||||
#' @param data dataframe of data.
|
||||
|
@ -1,15 +1,16 @@
|
||||
#' Regression model of predictors according to STROBE, bi- and multivariate.
|
||||
#'
|
||||
#' Printable table of regression model according to STROBE. Includes borth bivariate and multivariate in the same table. Output is a list, with the first item being the main "output" as a dataframe. Automatically uses logistic regression model for dichotomous outcome variable and linear regression model for continous outcome variable.
|
||||
#' Printable table of regression model according to STROBE. Includes borth bivariate and multivariate in the same table. Output is a list, with the first item being the main "output" as a dataframe. Automatically uses logistic regression model for dichotomous outcome variable and linear regression model for continous outcome variable. Linear regression will give estimated adjusted true mean in list.
|
||||
#' @param meas binary outcome meassure variable, column name in data.frame as a string. Can be numeric or factor. Result is calculated accordingly.
|
||||
#' @param adj variables to adjust for, as string.
|
||||
#' @param data dataframe of data.
|
||||
#' @param dec decimals for results, standard is set to 2. Mean and sd is dec-1.
|
||||
#' @param n.by.adj flag to indicate wether to count number of patients in adjusted model or overall for outcome meassure not NA.
|
||||
#' @param p.val flag to include p-values in linear regression for now, set to FALSE as standard.
|
||||
#' @keywords logistic
|
||||
#' @export
|
||||
|
||||
strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE,p.val=FALSE){
|
||||
## Ønskeliste:
|
||||
##
|
||||
## - Tæl selv antal a NA'er
|
||||
@ -178,7 +179,7 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
ads<-d[,c(adj)]
|
||||
|
||||
dfcr<-data.frame(matrix(NA,ncol = 3))
|
||||
names(dfcr)<-c("pred","mean_ci","pv")
|
||||
names(dfcr)<-c("pred","dif_ci","pv")
|
||||
n.mn<-c()
|
||||
|
||||
nref<-c()
|
||||
@ -192,9 +193,13 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
suppressMessages(ci<-confint(mn))
|
||||
l<-round(ci[-1,1],dec)
|
||||
u<-round(ci[-1,2],dec)
|
||||
mean<-round(coef(mn)[-1],dec)
|
||||
mean_ci<-paste0(mean," (",l," to ",u,")")
|
||||
dif<-round(coef(mn)[-1],dec)
|
||||
dif_ci<-paste0(dif," (",l," to ",u,")")
|
||||
pv<-round(tidy(mn)$p.value[-1],dec+1)
|
||||
pv<-ifelse(pv<0.001,"<0.001",round(pv,3))
|
||||
pv <- ifelse(pv<=0.05|pv=="<0.001",paste0("*",pv),
|
||||
ifelse(pv>0.05&pv<=0.1,paste0(".",pv),pv))
|
||||
|
||||
x1<-ads[,i]
|
||||
|
||||
if (is.factor(x1)){
|
||||
@ -205,7 +210,7 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
pred<-names(ads)[i]
|
||||
}
|
||||
|
||||
dfcr<-rbind(dfcr,cbind(pred,mean_ci,pv))
|
||||
dfcr<-rbind(dfcr,cbind(pred,dif_ci,pv))
|
||||
}
|
||||
|
||||
## Mutually adjusted ORs
|
||||
@ -214,6 +219,7 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
ma <- lm(m ~ ., data = dat)
|
||||
miss<-length(ma$na.action)
|
||||
|
||||
|
||||
actable <- coef(summary(ma))
|
||||
pa <- actable[,4]
|
||||
pa<-ifelse(pa<0.001,"<0.001",round(pa,3))
|
||||
@ -228,6 +234,8 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
aup<-aci[,2]
|
||||
amean_ci<-paste0(aco," (",alo," to ",aup,")")
|
||||
|
||||
mean_est<-amean_ci[[1]]
|
||||
|
||||
|
||||
nq<-c()
|
||||
|
||||
@ -312,12 +320,19 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE){
|
||||
|
||||
suppressWarnings(re<-left_join(df,dfcr,by="names"))
|
||||
|
||||
if (p.val==TRUE){
|
||||
ref<-data.frame(re[,1],re[,2],re[,5],re[,6],re[,3],re[,4])
|
||||
|
||||
names(ref)<-c("Variable",paste0("N=",n.meas),"Difference (95 % CI)","p-value","Mutually adjusted difference (95 % CI)","A p-value")
|
||||
}
|
||||
else{
|
||||
ref<-data.frame(re[,1],re[,2],re[,5],re[,3])
|
||||
|
||||
names(ref)<-c("Variable",paste0("N=",n.meas),"Crude OR (95 % CI)","Mutually adjusted OR (95 % CI)")
|
||||
names(ref)<-c("Variable",paste0("N=",n.meas),"Difference (95 % CI)","Mutually adjusted difference (95 % CI)")
|
||||
}
|
||||
|
||||
ls<-list(tbl=ref,miss,n.meas,nrow(d))
|
||||
names(ls)<-c("Printable table","Deleted due to missingness in adjusted analysis","Number of outcome observations","Length of dataframe")
|
||||
ls<-list(tbl=ref,miss,n.meas,nrow(d),mean_est)
|
||||
names(ls)<-c("Printable table","Deleted due to missingness in adjusted analysis","Number of outcome observations","Length of dataframe","Estimated true mean (95 % CI) in adjusted analysis")
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,13 @@ strobe_diff_bygroup(meas, var, group, adj, data, dec = 2)
|
||||
|
||||
\item{var}{binary exposure variable to compare against (active vs placebo). As string.}
|
||||
|
||||
\item{group}{group to compare, as string.}
|
||||
|
||||
\item{adj}{variables to adjust for, as string.}
|
||||
|
||||
\item{data}{dataframe of data.}
|
||||
|
||||
\item{dec}{decimals for results, standard is set to 2. Mean and sd is dec-1. pval has 3 decimals.}
|
||||
|
||||
\item{groups}{groups to compare, as string.}
|
||||
}
|
||||
\description{
|
||||
Printable table of three dimensional regression analysis of group vs var for meas. By group.
|
||||
|
@ -11,13 +11,13 @@ strobe_diff_byvar(meas, var, group, adj, data, dec = 2)
|
||||
|
||||
\item{var}{binary exposure variable to compare against (active vs placebo). As string.}
|
||||
|
||||
\item{group}{groups to compare, as string.}
|
||||
|
||||
\item{adj}{variables to adjust for, as string.}
|
||||
|
||||
\item{data}{dataframe of data.}
|
||||
|
||||
\item{dec}{decimals for results, standard is set to 2. Mean and sd is dec-1.}
|
||||
|
||||
\item{groups}{groups to compare, as string.}
|
||||
}
|
||||
\description{
|
||||
Printable table of three dimensional regression analysis of group vs var for meas. By var. Includes p-values.
|
||||
|
@ -2,7 +2,7 @@
|
||||
% Please edit documentation in R/strobe_olr.R
|
||||
\name{strobe_olr}
|
||||
\alias{strobe_olr}
|
||||
\title{Print regression results according to STROBE}
|
||||
\title{Print ordinal logistic regression results according to STROBE}
|
||||
\usage{
|
||||
strobe_olr(meas, vars, data, dec = 2)
|
||||
}
|
||||
@ -16,6 +16,6 @@ strobe_olr(meas, vars, data, dec = 2)
|
||||
\item{dec}{decimals for results, standard is set to 2. Mean and sd is dec-1.}
|
||||
}
|
||||
\description{
|
||||
Printable table of logistic regression analysis oaccording to STROBE.
|
||||
Printable table of ordinal logistic regression analysis oaccording to STROBE. Uses polr() funtion of the MASS-package.
|
||||
}
|
||||
\keyword{olr}
|
||||
|
@ -4,7 +4,8 @@
|
||||
\alias{strobe_pred}
|
||||
\title{Regression model of predictors according to STROBE, bi- and multivariate.}
|
||||
\usage{
|
||||
strobe_pred(meas, adj, data, dec = 2, n.by.adj = FALSE)
|
||||
strobe_pred(meas, adj, data, dec = 2, n.by.adj = FALSE,
|
||||
p.val = FALSE)
|
||||
}
|
||||
\arguments{
|
||||
\item{meas}{binary outcome meassure variable, column name in data.frame as a string. Can be numeric or factor. Result is calculated accordingly.}
|
||||
@ -16,8 +17,10 @@ strobe_pred(meas, adj, data, dec = 2, n.by.adj = FALSE)
|
||||
\item{dec}{decimals for results, standard is set to 2. Mean and sd is dec-1.}
|
||||
|
||||
\item{n.by.adj}{flag to indicate wether to count number of patients in adjusted model or overall for outcome meassure not NA.}
|
||||
|
||||
\item{p.val}{flag to include p-values in linear regression for now, set to FALSE as standard.}
|
||||
}
|
||||
\description{
|
||||
Printable table of regression model according to STROBE. Includes borth bivariate and multivariate in the same table. Output is a list, with the first item being the main "output" as a dataframe. Automatically uses logistic regression model for dichotomous outcome variable and linear regression model for continous outcome variable.
|
||||
Printable table of regression model according to STROBE. Includes borth bivariate and multivariate in the same table. Output is a list, with the first item being the main "output" as a dataframe. Automatically uses logistic regression model for dichotomous outcome variable and linear regression model for continous outcome variable. Linear regression will give estimated adjusted true mean in list.
|
||||
}
|
||||
\keyword{logistic}
|
||||
|
Loading…
Reference in New Issue
Block a user