library(learnr) library(learnSTATS) library(faux) library(emmeans) if("MeMoBootR" %in% rownames(installed.packages()) == FALSE) {warning("Please install MeMoBootR using devtools::install_github('doomlab/MeMoBootR') \n If you see an error saying Error: (converted from warning) package 'packagename' was built under R version NUMBER, then first run: Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS='true'), followed by devtools::install_github('doomlab/MeMoBootR')")} library(MeMoBootR) data("regress_data") regress_data <- na.omit(regress_data) regress_data <- sim_df(regress_data, #data frame sample(40:50, 1), #how many of each group between = "type_work") regress_data <- regress_data[ , -1] knitr::opts_chunk$set(echo = FALSE)
In the previous lecture, you learned about linear regression. This section will cover two special instances of regression that are popular: mediation and moderation. You will learn the following:
The following videos are provided as a lecture for the class material. The lectures are provided here as part of the flow for the course. You can view the lecture notes within R using vignette("Mediation-Moderation", "learnSTATS")
. You can skip these pages if you are in class to go on to the assignment.
In this next section, you will answer questions using the R code blocks provided. Be sure to use the solution
option to see the answer if you need it!
Please enter your name for submission. If you do not need to submit, just type anything you'd like in this box.
question_text( "Student Name:", answer("Your Name", correct = TRUE), incorrect = "Thanks!", try_again_button = "Modify your answer", allow_retry = TRUE )
NOTE: This dataset is the same as last week!
Title: The influence of cognitive and affective based job satisfaction measures on the relationship between satisfaction and organizational citizenship behavior
Abstract: One of the most widely believed maxims of management is that a happy worker is a productive worker. However, most research on the nature of the relationship between job satisfaction and job performance has not yielded convincing evidence that such a relationship exists to the degree most managers believe. One reason for this might lie in the way in which job performance is measured. Numerous studies have been published that showed that using Organizational Citizenship Behavior to supplant more traditional measures of job performance has resulted in a more robust relationship between job satisfaction and job performance. Yet, recent work has suggested that the relationship between job satisfaction and citizenship may be more complex than originally reported. This study investigated whether the relationship between job satisfaction and citizenship could depend upon the nature of the job satisfaction measure used. Specifically, it was hypothesized that job satisfaction measures which reflect a cognitive basis would be more strongly related to OCB than measures of job satisfaction, which reflect an affective basis. Results from data collected in two midwestern companies show support for the relative importance of cognition based satisfaction over affect based satisfaction. Implications for research on the causes of citizenship are discussed.
library(learnSTATS) data("regress_data") head(regress_data)
head(regress_data)
Using the same data as last week, we will now practice our special regression using mediation and moderation. Use regress_data
as our calculated dataset from the last class does not apply to this analysis.
Using MeMoBootR
, let's calculate a mediation analysis with number of years mediating the relationship between affective measurements and the OCB. Be sure to print out the Sobel test and/or the bootstrapped results to answer questions.
Note: You can install MeMoBootR
using devtools::install_github('doomlab/MeMoBootR')
. If you see an error saying Error: (converted from warning) package 'packagename' was built under R version NUMBER
, then first run: Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS="true")
, followed by devtools::install_github('doomlab/MeMoBootR')
.
library(MeMoBootR)
library(MeMoBootR) output <- mediation1(y = "OCB", x = "affective", m = "years", df = regress_data) output$z.score; output$p.value output$boot.ci
question_text( "Since the graphs print out for data screening - do you meet the assumption for normality? ", answer("Depends on simulation, slight skew.", correct = TRUE), incorrect = "My data had a slight negative skew but was mostly ok.", try_again_button = "Modify your answer", allow_retry = TRUE )
question_text( "Is there any evidence of mediation? Explain either Sobel and bootstrapping.", answer("Sobel test was not significant. The bootstrapping effect confidence interval included zero. Therefore, no mediation.", correct = TRUE), incorrect = "Sobel test was not significant. The bootstrapping effect confidence interval included zero. Therefore, no mediation.", try_again_button = "Modify your answer", allow_retry = TRUE )
Using MeMoBootR
, let's calculate a moderation analysis where the cognitive and affective measurements interact to predict OCB. Be sure to print out your graphslopes
and a summary(output$model1)
to help you see if moderation has occurred.
output <- moderation1(y = "OCB", x = "affective", m = "cognitive", df = regress_data) output$graphslopes summary(output$model1)
question_text( "Since the graphs print out for data screening - do you meet the assumption for linearity? ", answer("Depends on simulation, but likely yes.", correct = TRUE), incorrect = "My results indicated the data was linear.", try_again_button = "Modify your answer", allow_retry = TRUE )
question_text( "Is there any evidence of moderation?", answer("No, the interaction term was not significant. The slopes are parallel on the graph.", correct = TRUE), incorrect = "No, the interaction term was not significant. The slopes are parallel on the graph.", try_again_button = "Modify your answer", allow_retry = TRUE )
On this page, you will create the submission for your instructor (if necessary). Please copy this report and submit using a Word document or paste into the text window of your submission page. Click "Generate Submission" to get your work!
encoder_logic()
encoder_ui()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.