New minor function for easy forestplotting

This commit is contained in:
agdamsbo 2018-10-24 11:22:50 +02:00
parent 608afe02d8
commit 8e26088326
6 changed files with 51 additions and 5 deletions

View File

@ -1,7 +1,7 @@
Package: daDoctoR Package: daDoctoR
Type: Package Type: Package
Title: FUNCTIONS FOR HEALTH RESEARCH Title: FUNCTIONS FOR HEALTH RESEARCH
Version: 0.1.0.9015 Version: 0.1.0.9016
Author@R: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut"))) Author@R: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
Maintainer: Andreas Gammelgaard Damsbo <agdamsbo@pm.me> Maintainer: Andreas Gammelgaard Damsbo <agdamsbo@pm.me>
Description: I am a Danish medical doctor involved in neuropsychiatric research. Description: I am a Danish medical doctor involved in neuropsychiatric research.

View File

@ -3,6 +3,7 @@
export(age_calc) export(age_calc)
export(col_fact) export(col_fact)
export(col_num) export(col_num)
export(comb_olr)
export(cpr_check) export(cpr_check)
export(cpr_sex) export(cpr_sex)
export(date_convert) export(date_convert)

23
R/comb_olr.R Normal file
View File

@ -0,0 +1,23 @@
#' An ordinal logistic regression function for plotting
#'
#' Should be combined with "rep_olr()". The confint() function is rather slow, causing the whole function to hang when including many predictors and calculating the ORs with CI.
#' @param meas primary outcome (factor with >2 levels).
#' @param vars variables in model. Input as c() of columnnames, use dput().
#' @param dta data frame to pull variables from.
#' @keywords olr
#' @export
#' @examples
#' comb_olr()
comb_olr<-function(meas,vars,data){
require(MASS)
ad<-vars
d<-data
d2<-d[,c(meas,ad)]
names(d2)[1]<-"meas"
x<-polr(meas~.,data = d2,Hess = TRUE)
mat<-rbind(mat,c(exp(coef(x)), exp(confint(x))))
return(data.frame(mat,stringsAsFactors = FALSE))
}

View File

@ -2,8 +2,8 @@
#' #'
#' Repeats the epi.tests from the epiR package. Either gs or test should be of length 1. #' Repeats the epi.tests from the epiR package. Either gs or test should be of length 1.
#' @description For bivariate analyses. The confint() function is rather slow, causing the whole function to hang when including many predictors and calculating the ORs with CI. #' @description For bivariate analyses. The confint() function is rather slow, causing the whole function to hang when including many predictors and calculating the ORs with CI.
#' @param gold the test or meassure used as "golden standard". Format as dichotomised factor. #' @param gold the test or meassure used as "golden standard". Format as list of variable names to include. All variables should be formated as dichotomised factor.
#' @param test possible predictive tests to evaluate. Format as dichotomised factor. #' @param test possible predictive tests to evaluate. Format as list of variable names to include. All variables should be formated as dichotomised factor.
#' @param data dataframe to draw variables from. #' @param data dataframe to draw variables from.
#' @keywords ppv npv sensitivity specificity #' @keywords ppv npv sensitivity specificity
#' @export #' @export

22
man/comb_olr.Rd Normal file
View File

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/comb_olr.R
\name{comb_olr}
\alias{comb_olr}
\title{An ordinal logistic regression function for plotting}
\usage{
comb_olr(meas, vars, data)
}
\arguments{
\item{meas}{primary outcome (factor with >2 levels).}
\item{vars}{variables in model. Input as c() of columnnames, use dput().}
\item{dta}{data frame to pull variables from.}
}
\description{
Should be combined with "rep_olr()". The confint() function is rather slow, causing the whole function to hang when including many predictors and calculating the ORs with CI.
}
\examples{
comb_olr()
}
\keyword{olr}

View File

@ -7,9 +7,9 @@
rep_epi_tests(gold, test, data) rep_epi_tests(gold, test, data)
} }
\arguments{ \arguments{
\item{gold}{the test or meassure used as "golden standard". Format as dichotomised factor.} \item{gold}{the test or meassure used as "golden standard". Format as list of variable names to include. All variables should be formated as dichotomised factor.}
\item{test}{possible predictive tests to evaluate. Format as dichotomised factor.} \item{test}{possible predictive tests to evaluate. Format as list of variable names to include. All variables should be formated as dichotomised factor.}
\item{data}{dataframe to draw variables from.} \item{data}{dataframe to draw variables from.}
} }