mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-21 19:30:22 +01:00
upd
This commit is contained in:
parent
ed49de3b8d
commit
0378e6f24d
@ -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.9002
|
Version: 0.1.0.9003
|
||||||
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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#' A repeated regression function for change-in-estimate analysis
|
#' A repeated regression function for change-in-estimate analysis
|
||||||
#'
|
#'
|
||||||
#' For bivariate analyses. From "Modeling and variable selection in epidemiologic analysis." - S. Greenland, 1989.
|
#' For bivariate analyses, binary logistic or linear regression. From "Modeling and variable selection in epidemiologic analysis." - S. Greenland, 1989.
|
||||||
#' @param meas Effect meassure. Input as c() of columnnames, use dput().
|
#' @param meas Effect meassure. Input as c() of columnnames, use dput().
|
||||||
#' @param vars variables in model. Input as c() of columnnames, use dput().
|
#' @param vars variables in model. Input as c() of columnnames, use dput().
|
||||||
#' @param string variables to test. Input as c() of columnnames, use dput().
|
#' @param string variables to test. Input as c() of columnnames, use dput().
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#' @examples
|
#' @examples
|
||||||
#' rep_reg_cie()
|
#' rep_reg_cie()
|
||||||
|
|
||||||
rep_reg_cie<-function(meas,vars,string,data,logistic=FALSE,cut=0.1){
|
rep_reg_cie<-function(meas,vars,string,data,cut=0.1){
|
||||||
|
|
||||||
require(broom)
|
require(broom)
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ rep_reg_cie<-function(meas,vars,string,data,logistic=FALSE,cut=0.1){
|
|||||||
|
|
||||||
c<-as.numeric(cut)
|
c<-as.numeric(cut)
|
||||||
|
|
||||||
if(logistic==FALSE){
|
if(!is.factor(y)){
|
||||||
|
|
||||||
if (is.factor(y)){stop("Logistic is flagged as FALSE, but the provided meassure is formatted as a factor!")}
|
meth<-"linear regression"
|
||||||
|
|
||||||
e<-as.numeric(round(coef(lm(y~.,data = dt)),3))[1]
|
e<-as.numeric(round(coef(lm(y~.,data = dt)),3))[1]
|
||||||
df<-data.frame(pred="base",b=e)
|
df<-data.frame(pred="base",b=e)
|
||||||
@ -42,14 +42,13 @@ if (is.factor(y)){stop("Logistic is flagged as FALSE, but the provided meassure
|
|||||||
|
|
||||||
df<-rbind(df,cbind(pred,b)) }
|
df<-rbind(df,cbind(pred,b)) }
|
||||||
|
|
||||||
di<-as.vector(abs(e-as.numeric(df[-1,2]))/e)
|
di<-as.vector(round(abs(e-as.numeric(df[-1,2]))/e,3))
|
||||||
dif<-c(NA,di)
|
dif<-c(NA,di)
|
||||||
t<-c(NA,ifelse(di>=c,"include","drop"))
|
t<-c(NA,ifelse(di>=c,"include","drop"))
|
||||||
r<-cbind(df,dif,t) }
|
r<-cbind(df,dif,t) }
|
||||||
|
|
||||||
if(logistic==TRUE){
|
if(is.factor(y)){
|
||||||
|
meth="logistic regression"
|
||||||
if (!is.factor(y)){stop("Logistic is flagged as TRUE, but the provided meassure is NOT formatted as a factor!")}
|
|
||||||
|
|
||||||
e<-as.numeric(round(exp(coef(glm(y~.,family=binomial(),data=dt))),3))[1]
|
e<-as.numeric(round(exp(coef(glm(y~.,family=binomial(),data=dt))),3))[1]
|
||||||
|
|
||||||
@ -65,10 +64,10 @@ if (!is.factor(y)){stop("Logistic is flagged as TRUE, but the provided meassure
|
|||||||
|
|
||||||
df<-rbind(df,cbind(pred,b)) }
|
df<-rbind(df,cbind(pred,b)) }
|
||||||
|
|
||||||
di<-as.vector(abs(e-as.numeric(df[-1,2]))/e)
|
di<-as.vector(round(abs(e-as.numeric(df[-1,2]))/e,3))
|
||||||
dif<-c(NA,di)
|
dif<-c(NA,di)
|
||||||
t<-c(NA,ifelse(di>=c,"include","drop"))
|
t<-c(NA,ifelse(di>=c,"include","drop"))
|
||||||
r<-cbind(df,dif,t)
|
r<-cbind(df,dif,t)
|
||||||
}
|
}
|
||||||
return(r)
|
return(list("method"=meth,"analyses"=r))
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
\alias{rep_reg_cie}
|
\alias{rep_reg_cie}
|
||||||
\title{A repeated regression function for change-in-estimate analysis}
|
\title{A repeated regression function for change-in-estimate analysis}
|
||||||
\usage{
|
\usage{
|
||||||
rep_reg_cie(meas, vars, string, data, logistic = FALSE, cut = 0.1)
|
rep_reg_cie(meas, vars, string, data, cut = 0.1)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{meas}{Effect meassure. Input as c() of columnnames, use dput().}
|
\item{meas}{Effect meassure. Input as c() of columnnames, use dput().}
|
||||||
@ -15,12 +15,12 @@ rep_reg_cie(meas, vars, string, data, logistic = FALSE, cut = 0.1)
|
|||||||
|
|
||||||
\item{data}{data frame to pull variables from.}
|
\item{data}{data frame to pull variables from.}
|
||||||
|
|
||||||
\item{logistic}{flag to set logistic (TRUE) or linear (FALSE,standard) analysis.}
|
|
||||||
|
|
||||||
\item{cut}{cut value for gating if including or dropping the tested variable. As suggested bu S. Greenland (1989).}
|
\item{cut}{cut value for gating if including or dropping the tested variable. As suggested bu S. Greenland (1989).}
|
||||||
|
|
||||||
|
\item{logistic}{flag to set logistic (TRUE) or linear (FALSE,standard) analysis.}
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
For bivariate analyses. From "Modeling and variable selection in epidemiologic analysis." - S. Greenland, 1989.
|
For bivariate analyses, binary logistic or linear regression. From "Modeling and variable selection in epidemiologic analysis." - S. Greenland, 1989.
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
rep_reg_cie()
|
rep_reg_cie()
|
||||||
|
Loading…
Reference in New Issue
Block a user