R/LMFindDelRow.R In AmirDJV/UsefulFunctions: What the Package Does Using Title Case

Documented in LMFindDelRow

```#' Calculates sig. level without each participant from linear regression
#'
#' `LMFindDelRow` calculates linear regression for given variables.
#' Next, tests for the same model with excluding each time diffrent
#' participant.
#'
#' @param DFDEL DF you want to analyze.
#' @param x The Predictors.
#' @param y The Outcome.
#' @param Varintrest The variable you're intrested at (the variable you want to be significant).
#' @return Data frame with all the tidy arguments.
#' @note Intresting things you need to know
#' @examples
#' DFDEL<-DF
#' x<-c("DaydScore2", "ChildScore")
#' y<-c("clock_positive_empathy_age9", "")
#' b<-paste0(x, collapse = "+")
#' Varintrest<-c("DaydScore2")
#' LMFindDelRow(df, c("price", "table"), c("depth"), c("price"))

LMFindDelRow <- function(DFDEL, x, y, Varintrest)
{
# Building main vars and Final DF
delline <- 1
row <- 1
counter <- 1
DF <- DFDEL

LMResults <- tibble(term = as.numeric(),
estimate = as.numeric(),
stderror = as.numeric(),
statistic = as.numeric(),
p = as.numeric(),
no = as.numeric())
EquationOrignal <- paste(paste(y, sep = "~" ,collapse = "~"),
paste(x, collapse = "+"),sep = "~")
print(tidy(lm(data = DFDEL, paste(EquationOrignal))))

# Looping
for (counter in 1:NROW(DF)) {
DForginal <- DF
DFTemp <- DF[-delline,]

Equation <- paste(paste(y, sep = "~" ,collapse = "~"),
paste(x, collapse = "+"),sep = "~")
Statistics <- tidy(lm(data = DFTemp,
paste(Equation))) %>%
filter(term == Varintrest)

LMResults[row,1] <- Statistics\$term
LMResults[row,2] <- Statistics\$estimate[1]
LMResults[row,3] <- Statistics\$std.error[1]
LMResults[row,4] <- Statistics\$statistic[1]
LMResults[row,5] <- Statistics\$p.value[1]
LMResults[row,6] <- DF\$ID[delline]
counter <- counter + 1
delline <- delline + 1
row <- row + 1
} #End Loop
return(LMResults)
} #End Function
```
AmirDJV/UsefulFunctions documentation built on Nov. 18, 2017, 5:10 a.m.