R/moderate.lm.R

"moderate.lm" <-
  function (x,z,y,data,mc=FALSE)
  {
    
    if(!mc)
    {
      y <-  data %>% dplyr::select({{y}}) %>% purrr::reduce(c) 
      xvalues <- data %>% dplyr::select({{x}}) %>% purrr::reduce(c) 
      zvalues <- data %>% dplyr::select({{z}}) %>% purrr::reduce(c) 
      
      mcx <-  xvalues - mean(xvalues, na.rm = TRUE) 
      mcz <-  zvalues - mean(zvalues, na.rm = TRUE) 
    }
    else {
      y <-  data %>% dplyr::select({{y}}) %>% purrr::reduce(c) 
      mcx <- data %>% dplyr::select({{x}}) %>% purrr::reduce(c) 
      mcz <- data %>% dplyr::select({{z}}) %>% purrr::reduce(c) 
    }
    
    lm1 <- lm(y ~ mcx*mcz, na.action=na.omit)
    
    return(lm1)
  }

Try the QuantPsyc package in your browser

Any scripts or data that you put into this service are public.

QuantPsyc documentation built on June 4, 2022, 1:06 a.m.