diff --git a/DESCRIPTION b/DESCRIPTION index 38c572d..9b4eddc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: daDoctoR Type: Package 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"))) Maintainer: Andreas Gammelgaard Damsbo Description: I am a Danish medical doctor involved in neuropsychiatric research. diff --git a/NAMESPACE b/NAMESPACE index 44eff6c..66d6cd7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(age_calc) export(col_fact) export(col_num) +export(comb_olr) export(cpr_check) export(cpr_sex) export(date_convert) diff --git a/R/comb_olr.R b/R/comb_olr.R new file mode 100644 index 0000000..f5b802e --- /dev/null +++ b/R/comb_olr.R @@ -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)) +} diff --git a/R/rep_epi_tests.R b/R/rep_epi_tests.R index ff17d53..95a50fc 100644 --- a/R/rep_epi_tests.R +++ b/R/rep_epi_tests.R @@ -2,8 +2,8 @@ #' #' 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. -#' @param gold the test or meassure used as "golden standard". Format as dichotomised factor. -#' @param test possible predictive tests to evaluate. 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 list of variable names to include. All variables should be formated as dichotomised factor. #' @param data dataframe to draw variables from. #' @keywords ppv npv sensitivity specificity #' @export diff --git a/man/comb_olr.Rd b/man/comb_olr.Rd new file mode 100644 index 0000000..cee811a --- /dev/null +++ b/man/comb_olr.Rd @@ -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} diff --git a/man/rep_epi_tests.Rd b/man/rep_epi_tests.Rd index 68b986c..f93b657 100644 --- a/man/rep_epi_tests.Rd +++ b/man/rep_epi_tests.Rd @@ -7,9 +7,9 @@ rep_epi_tests(gold, test, data) } \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.} }