Giter VIP home page Giter VIP logo

memobootr's Introduction

MeMoBootR

This package is in (ok fine somewhat) active development. I am working on updating as I go through the different models involved in mediation and moderation. You can check out videos / updates on my YouTube channel, as well as watching or starring the github repo.

To install the package take the following steps:

  1. Install devtools if you do not have it. devtools is a package that allows you to install packages from github. install.packages("devtools")

  2. Install the MeMoBootR package by running the following: devtools::install_github("doomlab/MeMoBootR")

  3. Load the library to get started! library(MeMoBootR)

  4. Enjoy mediation and moderation complete with data screening.

  5. Cite the package! Buchanan, E.M. (2018). MeMoBootR [Computer Program]. Avaliable at: https://github.com/doomlab/MeMoBootR.

More tutorials, details, and other information added as I go.

Many thanks to KD Valentine for the fantastic name suggestion.

Table of Possibilities

PROCESS MeMoBootR Label Categorical X Categorical M
Model 1 moderation1() Two-way moderation No Yes
Model 2 moderation2() Double Two-way moderation No Yes
Model 4 mediation1() Simple mediation Yes No
Model 6 mediation2() Serial mediation Yes No
Model 6-7 Hybrid mediation2_moda() Serial Mediation with Moderator on A Yes No for mediators/moderators
  • For moderation models with categorical variables, make those variables M, rather than X. For X and M categorical, use ANOVA (ez is a great package).
  • Mediation should allow for categorical X and M, just haven't gotten there yet.

Examples

Head over to the OSF Page to view examples of the function in action. Included on the OSF page are youtube videos that explain the different functions and examples. Additionally, you can find information about the translation of the model numbers from PROCESSv3 to MeMoBootR.

Version Information

Version: 0.0.0.7000

  • Adding serial mediation with a continuous moderator on the A path. Should be able to do all paths at some point.

Version: 0.0.0.6001

  • Fixed bug with mediation1(), moderation1() that did not allow cvs to show up.

Version: 0.0.0.6000

  • Added double two-way moderation - which is two two-way interactions with two moderators (model 2).
  • The next goals are to make mediation2 and moderation2 work for categorical variables over the next couple of weeks.

Version: 0.0.0.5000

  • Added serial mediation with two mediators (model 6). The model can handle covariates and should be able to do categorical X. I will be testing categorical X more next week.

Version: 0.0.0.4000

  • Added categorical moderators, where X is continuous, M can be categorical or continuous. Please note that it will not run with X categorical. (model 1 - moderation)

Version: 0.0.0.3000

  • Added two way interactions (model 1 - moderation)
  • No good categorical options yet (i.e., it'll run but not what you want probably yet)
  • Updated data screening so it can handle categorical CV values across all analyses

Version: 0.0.0.2000

  • Added diagram ability with diagram library (wouldn't mind help here, the diagrams for mediation are only ok)
  • Added ability for categorical X variables in simple mediation

Version: 0.0.0.1000:

  • Initial build
  • Simple mediation with categorical variables added

memobootr's People

Contributors

doomlab avatar jgeller112 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

memobootr's Issues

tibbles and column spaces

From Kelsey Sewell:

Update:

I tried converting Demographic.E4 allele to a factor with 2 levels (as opposed to a character variable) and I still was getting the same error. Please note, there are no NA’s in this variable:
summary(ImputesAmyloid$Demographic.E4 allele)
No Yes
173 51

I then tried to recreate the error using the states dataset from R and I couldn’t. I used this code and it ran fine:
states = as.data.frame(state.x77)
states$murdercat = states$Murder
states$murdercat= as.factor(ifelse(states$Murder <= 5, "Low",
ifelse(states$Murder > 5, "High", NA)))
test = moderation1(y = "Income",
x = "Illiteracy",
m = "murdercat",
cvs = "Frost",
df = states,
with_out = T)

I so I created a new ‘categorical’ variable in my dataset (even though Demographic.E4 allele was already categorical):
ImputesAmyloid$allelecat = ImputesAmyloid$Demographic.E4 allele
ImputesAmyloid$allelecat = as.factor(ifelse(ImputesAmyloid$Demographic.E4 allele == "No", "No",
ifelse(ImputesAmyloid$Demographic.E4 allele == "Yes", "Yes", NA)))

Then ran the model using the new variable and it ran fine.

doublemodtest <- moderation1(y = "Image.PET.Centiloid",
                  x = "totalMETs",
                  m = "allelecat",
                  cvs = c("Age", "Demographic.Sex", "mood.y", "premorbidIQ.y", "`PSQI.Q7-Medicine-Induced Sleep`", "Collection"),
                  with_out = F,
                  df = ImputesAmyloid)

I really have no idea why this worked as Demographic.E4 allele and allelecat appear to be exactly the same?

str(ImputesAmyloid$Demographic.E4 allele)
Factor w/ 2 levels "No","Yes": 1 1 1 1 1 2 1 1 1 1 ...
str(ImputesAmyloid$allelecat)
Factor w/ 2 levels "No","Yes": 1 1 1 1 1 2 1 1 1 1 ...

The only difference I can think of is that Demographic.E4 allele was read in from excel using the readxl package, whereas allelecat wasn’t.

Cant install MeMoBootR

I'm not sure if anyone has similar problems but I get this when I try to download MeMoBootR in R via

devtools::install_github("doomlab/MeMoBootR")

I get this message in the end (in the console):

Downloading GitHub repo doomlab/MeMoBootR@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: rlang (0.4.10 -> 0.4.11) [CRAN]
5: pillar (1.4.7 -> 1.6.1 ) [CRAN]
6: fansi (0.4.2 -> 0.5.0 ) [CRAN]
7: tibble (3.1.1 -> 3.1.2 ) [CRAN]
8: shape (1.4.5 -> 1.4.6 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates:
Error: Failed to install 'MeMoBootR' from GitHub:
System command 'Rcmd.exe' failed, exit status: -1, stdout + stderr empty

This is when I don't update any of the packages. Updating the pacakges results in the same thing but with more errors, if that helps:

devtools::install_github("doomlab/MeMoBootR")
Downloading GitHub repo doomlab/MeMoBootR@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: rlang (0.4.10 -> 0.4.11) [CRAN]
5: pillar (1.4.7 -> 1.6.1 ) [CRAN]
6: fansi (0.4.2 -> 0.5.0 ) [CRAN]
7: tibble (3.1.1 -> 3.1.2 ) [CRAN]
8: shape (1.4.5 -> 1.4.6 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 1
rlang (0.4.10 -> 0.4.11) [CRAN]
pillar (1.4.7 -> 1.6.1 ) [CRAN]
fansi (0.4.2 -> 0.5.0 ) [CRAN]
tibble (3.1.1 -> 3.1.2 ) [CRAN]
shape (1.4.5 -> 1.4.6 ) [CRAN]
Installing 5 packages: rlang, pillar, fansi, tibble, shape
Installing packages into ‘C:/Users/user/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)

There are binary versions available but the source versions are
later:
binary source needs_compilation
pillar 1.6.0 1.6.1 FALSE
fansi 0.4.2 0.5.0 TRUE
tibble 3.1.1 3.1.2 TRUE
shape 1.4.5 1.4.6 FALSE

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rlang_0.4.11.zip'
Content type 'application/zip' length 1224139 bytes (1.2 MB)
downloaded 1.2 MB

package ‘rlang’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘rlang’
Warning: restored ‘rlang’

The downloaded binary packages are in
C:\Users\user\AppData\Local\Temp\Rtmpc9VAJT\downloaded_packages
installing the source packages ‘pillar’, ‘fansi’, ‘tibble’, ‘shape’

trying URL 'https://cran.rstudio.com/src/contrib/pillar_1.6.1.tar.gz'
Content type 'application/x-gzip' length 1111747 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/src/contrib/fansi_0.5.0.tar.gz'
Content type 'application/x-gzip' length 301724 bytes (294 KB)
downloaded 294 KB

trying URL 'https://cran.rstudio.com/src/contrib/tibble_3.1.2.tar.gz'
Content type 'application/x-gzip' length 686145 bytes (670 KB)
downloaded 670 KB

trying URL 'https://cran.rstudio.com/src/contrib/shape_1.4.6.tar.gz'
Content type 'application/x-gzip' length 677262 bytes (661 KB)
downloaded 661 KB

The downloaded source packages are in
‘C:\Users\user\AppData\Local\Temp\Rtmpc9VAJT\downloaded_packages’
Error: Failed to install 'MeMoBootR' from GitHub:
System command 'Rcmd.exe' failed, exit status: -1, stdout + stderr empty
In addition: Warning messages:
1: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Users\user\Documents\R\win-library\3.6\00LOCK\rlang\libs\x64\rlang.dll to C:\Users\user\Documents\R\win-library\3.6\rlang\libs\x64\rlang.dll: Permission denied
2: In i.p(...) : installation of package ‘fansi’ had non-zero exit status
3: In i.p(...) : installation of package ‘shape’ had non-zero exit status
4: In i.p(...) : installation of package ‘pillar’ had non-zero exit status
5: In i.p(...) : installation of package ‘tibble’ had non-zero exit status

Does anyone know how to deal with this? I tried running RStudio as admin and that didn't work.

bca boot type

Hi Erin!

It appears that the boot.ci function only outputs normal cis. I feel like there should be an argument to specify what type of cis you want to perform. Am I missing something? If not, can I make a pull request and change?

mediation1

Thanks for these great tutorials. I just followed your youtube video for mediation1, but my output is different. for example, when showing "model$boot.results" i have 2 lines of output that give results at 2 different levels of cyl (cyl6 and cyl8). i don't think i turned on this function, since i made sure the model was identical to that in your script in the video... Is this an intentional change in the output of the mediation1?

Mediation/Moderation

Hi,
Thanks a lot for this package, and the youtube videos too.
I have a model where one variable is a mediator for a few independent variables and at the same time a moderator for a few other independent variables. I am not sure which example is the best to work on my data.
I appreciate if you could help me to know if the problem is solvable.

Regards,
Saeed

Missing data and categorical M

Dear Dr. Erin M. Buchanan,

Thank you very much for developing this R package and providing code, examples, and more! It is so educational and I appreciate it greatly.

My data suffers missing data (in the dv), and I think it is why get the following error:

Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 122, 72
In addition: Warning messages:
1: In badmahal + badleverage :
longer object length is not a multiple of shorter object length
2: In badmahal + badleverage + badcooks :
longer object length is not a multiple of shorter object length

I did not manage to find an argument for excluding NAs; is that correct? Do you know if there is a way around this problem?

Furthermore, I wonder if the mediation1 function could be used for a categorical M? I have found the processR (catMediation)
package, but again no argument for omitting/excluding NAs.

Thank you very much for your time.

Best regards,
Emma

Mediation with Dichotomous Y Variable

Hello!

First of all, thank you for this amazing package and all of your incredible YouTube videos. I have really learned a lot!

I was doing a mediation with a dichotomous X, dichotomous Y, and a continuous M using the mediation1() function. When it runs I get the error Error in mediation1(y = "SuicideBIN_Text", x = "cp_np", m = "rh_G_postcentral_thickness", : Y should not be a categorical variable. Log regression options are coming soon.

I was wondering if there was an update coming soon for this. Thanks for all your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.