Moderation Practice

Jeong Eun Cheon


Preparing for the analysis

Read in data

library(tidyverse)
Study1 <- read_csv("Study1_Wider_data_full.csv")
Study2 <- read_csv("Study2_Smolinska_data.csv")

library(base)
Study3 <- read.csv("Study3_dyadic_dataset_anonymized.csv", sep = ";")

We aim to replicate the results of Czarna et al. (2022). Their research spans three studies, with the first two focusing on individual-level data and the third incorporating dyadic data. A key aspect of their investigation is exploring how narcissism moderates the link between relationship length and partner enhancement.

The authors have provided access to their datasets and scripts via the Open Science Framework (OSF). You can access these materials at the following link: https://osf.io/8j4td/?view_only=dee38744aef04831b98484076616d98d

We will use their provided codes as a basis to reconstruct and validate their core findings.

Reference:

Czarna, A. Z., Śmieja, M., Wider, M., Dufner, M., & Sedikides, C. (2022). Narcissism and partner-enhancement at different relationship stages. Journal of Research in Personality, 98, 104212. https://doi.org/10.1016/j.jrp.2022.104212

Let’s begin by replicating Study 1.

Study 1

Let’s first inspect the data

names(Study1)
##  [1] "age"                  "sex"                  "relationship_length" 
##  [4] "ses1"                 "ses2"                 "ses3"                
##  [7] "ses4"                 "ses5"                 "ses6"                
## [10] "ses7"                 "ses8"                 "ses9"                
## [13] "ses10"                "Equity1"              "Equity2"             
## [16] "Equity3"              "Equity4"              "Equity5"             
## [19] "Equity6"              "Equity7"              "Equity8"             
## [22] "Equity9"              "Equity10"             "Equity11"            
## [25] "Equity12"             "Equity13"             "Equity14"            
## [28] "Equity15"             "NPI1"                 "NPI2"                
## [31] "NPI3"                 "NPI4"                 "NPI5"                
## [34] "NPI6"                 "NPI7"                 "NPI8"                
## [37] "NPI9"                 "NPI10"                "NPI11"               
## [40] "NPI12"                "NPI13"                "NPI14"               
## [43] "NPI15"                "NPI16"                "NPI17"               
## [46] "NPI18"                "NPI19"                "NPI20"               
## [49] "NPI21"                "NPI22"                "NPI23"               
## [52] "NPI24"                "NPI25"                "NPI26"               
## [55] "NPI27"                "NPI28"                "NPI29"               
## [58] "NPI30"                "NPI31"                "NPI32"               
## [61] "NPI33"                "NPI34"                "NPI_mean"            
## [64] "ZNPI_mean"            "Zrelationship_length" "Equity_mean"         
## [67] "Equity_recoded"       "ZEquity_recoded"      "RSES"                
## [70] "ZRSES"                "sex_c"
glimpse(Study1)
## Rows: 70
## Columns: 71
## $ age                  <dbl> 22, 24, 22, 24, 22, 18, 22, 23, 19, 18, 22, 23, 2…
## $ sex                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ relationship_length  <dbl> 2, 2, 4, 4, 5, 6, 6, 7, 8, 10, 10, 10, 11, 12, 12…
## $ ses1                 <dbl> 7, 4, 3, 7, 4, 5, 6, 3, 5, 5, 5, 7, 7, 4, 3, 7, 7…
## $ ses2                 <dbl> 7, 3, 2, 7, 5, 5, 6, 4, 5, 4, 5, 6, 7, 4, 6, 7, 7…
## $ ses3                 <dbl> 7, 3, 7, 4, 5, 7, 6, 3, 6, 7, 4, 7, 7, 6, 3, 7, 6…
## $ ses4                 <dbl> 7, 4, 3, 7, 4, 4, 6, 4, 6, 7, 4, 4, 7, 4, 6, 7, 7…
## $ ses5                 <dbl> 1, 2, 2, 5, 5, 4, 6, 5, 6, 5, 5, 6, 7, 4, 4, 7, 5…
## $ ses6                 <dbl> 7, 2, 3, 5, 3, 7, 5, 3, 6, 6, 5, 6, 7, 4, 2, 5, 5…
## $ ses7                 <dbl> 7, 2, 3, 4, 3, 5, 6, 5, 6, 5, 3, 6, 5, 3, 4, 5, 6…
## $ ses8                 <dbl> 6, 7, 2, 3, 3, 7, 2, 1, 1, 2, 5, 6, 7, 4, 3, 6, 4…
## $ ses9                 <dbl> 5, 1, 1, 3, 2, 6, 3, 2, 1, 6, 5, 7, 6, 4, 3, 7, 4…
## $ ses10                <dbl> 5, 1, 1, 3, 2, 6, 3, 2, 5, 5, 7, 5, 7, 4, 2, 7, 6…
## $ Equity1              <dbl> 0, 1, -3, 2, -1, -4, 0, 2, -4, 0, 0, 0, -4, -4, 1…
## $ Equity2              <dbl> 4, 2, 0, 1, -2, -4, 0, 4, -3, 0, 2, -4, 2, -4, 0,…
## $ Equity3              <dbl> 0, 1, -2, 0, 0, 0, 2, 0, -3, 0, 0, 2, -2, -4, 0, …
## $ Equity4              <dbl> 0, 1, -2, 1, -2, -4, 1, 3, -3, 0, 0, 0, -4, -4, 0…
## $ Equity5              <dbl> 2, -1, 2, 0, 1, 1, 1, 3, -1, 0, 1, 1, 2, -3, 2, 0…
## $ Equity6              <dbl> 0, 0, 2, 0, -2, 0, -4, -3, 0, 0, 2, -2, 1, -4, 0,…
## $ Equity7              <dbl> 0, 0, 1, 0, 1, 0, -4, 4, -2, 0, 0, 1, 0, -1, -2, …
## $ Equity8              <dbl> 0, 0, 0, -2, -2, 0, -4, 0, -2, 0, 0, -2, 2, -4, 0…
## $ Equity9              <dbl> 0, 0, 3, 1, -2, 0, -2, 0, -1, 0, 0, -2, 2, -4, 0,…
## $ Equity10             <dbl> 4, 0, 1, 4, 1, 0, -4, 0, 0, 0, 2, -3, 4, -2, -3, …
## $ Equity11             <dbl> 4, 0, -4, -4, 2, -4, 3, 4, -4, 0, 0, -3, 0, 0, 0,…
## $ Equity12             <dbl> 3, 1, 3, -1, 2, -4, 0, 4, -4, 0, 2, -3, 1, 3, 0, …
## $ Equity13             <dbl> 0, -1, -1, -2, 2, -4, 3, 4, -4, 0, -2, 1, 0, 1, 0…
## $ Equity14             <dbl> 4, 4, 2, 0, 2, -4, -3, 4, -4, 0, 0, -3, 3, 1, 2, …
## $ Equity15             <dbl> 0, 0, 0, -4, 2, -1, -3, 4, -4, 0, 0, 0, 0, 3, -2,…
## $ NPI1                 <dbl> 5, 3, 3, 3, 3, 4, 5, 5, 2, 3, 3, 2, 4, 4, 4, 2, 4…
## $ NPI2                 <dbl> 5, 4, 4, 5, 4, 3, 4, 5, 4, 5, 4, 4, 4, 3, 4, 4, 3…
## $ NPI3                 <dbl> 3, 4, 5, 5, 4, 1, 3, 5, 3, 1, 4, 5, 3, 5, 5, 4, 3…
## $ NPI4                 <dbl> 3, 3, 3, 1, 3, 1, 2, 3, 5, 5, 2, 5, 2, 4, 2, 4, 1…
## $ NPI5                 <dbl> 3, 3, 2, 4, 4, 3, 3, 5, 3, 5, 4, 2, 2, 4, 2, 4, 2…
## $ NPI6                 <dbl> 5, 5, 3, 5, 2, 3, 4, 5, 3, 3, 3, 5, 2, 4, 3, 4, 4…
## $ NPI7                 <dbl> 4, 4, 2, 4, 2, 4, 3, 5, 3, 3, 4, 3, 2, 2, 4, 2, 4…
## $ NPI8                 <dbl> 5, 3, 3, 4, 3, 2, 4, 3, 4, 4, 3, 1, 4, 4, 2, 4, 3…
## $ NPI9                 <dbl> 5, 3, 1, 3, 3, 4, 2, 5, 2, 4, 2, 1, 1, 1, 2, 2, 3…
## $ NPI10                <dbl> 4, 3, 3, 1, 2, 2, 2, 5, 2, 3, 4, 3, 2, 2, 4, 3, 2…
## $ NPI11                <dbl> 4, 5, 2, 4, 2, 4, 2, 5, 4, 3, 2, 5, 4, 3, 4, 4, 4…
## $ NPI12                <dbl> 5, 4, 4, 4, 2, 3, 3, 5, 2, 3, 3, 2, 3, 4, 3, 4, 3…
## $ NPI13                <dbl> 4, 5, 3, 4, 3, 1, 3, 5, 2, 3, 4, 3, 3, 5, 4, 5, 2…
## $ NPI14                <dbl> 3, 4, 2, 3, 3, 1, 4, 3, 3, 4, 4, 2, 4, 2, 2, 3, 3…
## $ NPI15                <dbl> 3, 4, 3, 2, 4, 1, 3, 5, 2, 3, 2, 1, 4, 3, 2, 3, 4…
## $ NPI16                <dbl> 4, 4, 4, 1, 4, 1, 1, 4, 1, 2, 2, 1, 2, 5, 1, 1, 2…
## $ NPI17                <dbl> 5, 5, 3, 2, 4, 3, 2, 2, 4, 2, 2, 5, 3, 3, 2, 2, 2…
## $ NPI18                <dbl> 5, 3, 4, 2, 4, 2, 3, 4, 3, 2, 3, 1, 5, 5, 2, 4, 2…
## $ NPI19                <dbl> 5, 5, 4, 2, 4, 1, 2, 4, 4, 4, 4, 4, 3, 5, 5, 5, 4…
## $ NPI20                <dbl> 3, 3, 2, 3, 2, 4, 2, 4, 2, 5, 3, 4, 1, 1, 2, 3, 4…
## $ NPI21                <dbl> 4, 2, 3, 1, 3, 1, 3, 3, 4, 2, 2, 1, 2, 4, 2, 3, 2…
## $ NPI22                <dbl> 4, 4, 3, 4, 2, 1, 4, 4, 3, 4, 3, 5, 3, 3, 4, 1, 3…
## $ NPI23                <dbl> 3, 2, 3, 3, 3, 1, 4, 4, 2, 4, 3, 4, 4, 2, 3, 2, 4…
## $ NPI24                <dbl> 5, 2, 4, 3, 3, 3, 3, 4, 1, 3, 4, 2, 2, 3, 2, 4, 2…
## $ NPI25                <dbl> 3, 4, 4, 4, 2, 3, 3, 5, 2, 4, 4, 4, 4, 2, 4, 4, 5…
## $ NPI26                <dbl> 3, 3, 4, 4, 4, 2, 2, 5, 2, 3, 3, 1, 4, 5, 2, 3, 3…
## $ NPI27                <dbl> 1, 4, 2, 4, 3, 1, 2, 4, 1, 2, 2, 2, 1, 1, 2, 1, 2…
## $ NPI28                <dbl> 3, 5, 2, 4, 3, 4, 2, 4, 3, 3, 2, 5, 2, 2, 2, 4, 5…
## $ NPI29                <dbl> 5, 5, 4, 4, 2, 4, 2, 3, 3, 4, 3, 4, 5, 3, 1, 5, 3…
## $ NPI30                <dbl> 5, 3, 3, 1, 2, 1, 2, 2, 4, 3, 2, 1, 2, 3, 2, 3, 1…
## $ NPI31                <dbl> 3, 3, 1, 3, 4, 4, 2, 4, 1, 4, 2, 3, 1, 1, 3, 1, 4…
## $ NPI32                <dbl> 3, 3, 3, 3, 2, 2, 2, 3, 2, 3, 3, 2, 3, 3, 4, 5, 4…
## $ NPI33                <dbl> 3, 4, 4, 4, 2, 1, 2, 5, 2, 3, 3, 2, 2, 4, 2, 4, 2…
## $ NPI34                <dbl> 3, 5, 3, 3, 2, 1, 2, 4, 2, 3, 2, 5, 2, 4, 2, 4, 3…
## $ NPI_mean             <dbl> 3.852941, 3.705882, 3.029412, 3.147059, 2.911765,…
## $ ZNPI_mean            <dbl> 1.60641511, 1.33380132, 0.07977789, 0.29786892, -…
## $ Zrelationship_length <dbl> -1.02346483, -1.02346483, -0.94953032, -0.9495303…
## $ Equity_mean          <dbl> 1.4000000, 0.5333333, 0.1333333, -0.2666667, 0.13…
## $ Equity_recoded       <dbl> -1.4000000, -0.5333333, -0.1333333, 0.2666667, -0…
## $ ZEquity_recoded      <dbl> -1.5137581, -0.5830014, -0.1534214, 0.2761586, -0…
## $ RSES                 <dbl> 4.6, 3.6, 3.6, 4.7, 3.7, 3.1, 4.4, 4.1, 4.4, 3.7,…
## $ ZRSES                <dbl> 1.25020354, -0.47856782, -0.47856782, 1.42308068,…
## $ sex_c                <dbl> -0.485714, -0.485714, -0.485714, -0.485714, -0.48…
library(psych)
corr.test(Study1[c("relationship_length", "NPI_mean", "Equity_recoded")])
## Call:corr.test(x = Study1[c("relationship_length", "NPI_mean", "Equity_recoded")])
## Correlation matrix 
##                     relationship_length NPI_mean Equity_recoded
## relationship_length                1.00    -0.12          -0.13
## NPI_mean                          -0.12     1.00          -0.36
## Equity_recoded                    -0.13    -0.36           1.00
## Sample Size 
## [1] 70
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##                     relationship_length NPI_mean Equity_recoded
## relationship_length                0.00     0.57           0.57
## NPI_mean                           0.30     0.00           0.01
## Equity_recoded                     0.29     0.00           0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

variable explanation x = relationship_length w = NPImean (narcissism) y = Equity_recoded (partner enhancement)

Standardizing variables

When you standardize a variable using the equation ((x - μ) / σ), it transforms the variable so that it has a mean of 0 and a standard deviation of 1.

#1. manually scale
Study1$zmrelationship_length <- (Study1$relationship_length - mean(Study1$relationship_length))/ sd(Study1$relationship_length)

Study1$zmNPI <- (Study1$NPI_mean - mean(Study1$NPI_mean))/ sd(Study1$NPI_mean)

#2. use scale function

library(base)
Study1$zrelationship_length <- scale(Study1$relationship_length, center = TRUE, scale = TRUE)
Study1$zNPI <- scale(Study1$NPI_mean, center = TRUE, scale = TRUE)

Model specification

#creating interaction terms
Study1$RLXNPI <- Study1$zmrelationship_length*Study1$zNPI

#calculating basic model_Step1
model_Study1 <- lm(Equity_recoded ~ zNPI + zrelationship_length, data=Study1)  
summary(model_Study1)
## 
## Call:
## lm(formula = Equity_recoded ~ zNPI + zrelationship_length, data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.26350 -0.44794  0.02209  0.46967  2.23237 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)   
## (Intercept)           0.009524   0.103333   0.092  0.92684   
## zNPI                 -0.358796   0.104897  -3.420  0.00107 **
## zrelationship_length -0.165181   0.104897  -1.575  0.12004   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8645 on 67 degrees of freedom
## Multiple R-squared:  0.1629, Adjusted R-squared:  0.1379 
## F-statistic:  6.52 on 2 and 67 DF,  p-value: 0.002587
#calculating basic model_step2
model_Study1 <- lm(Equity_recoded ~ zNPI + zrelationship_length + RLXNPI, data=Study1)  
summary(model_Study1)
## 
## Call:
## lm(formula = Equity_recoded ~ zNPI + zrelationship_length + RLXNPI, 
##     data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33147 -0.46370  0.01309  0.48320  2.14537 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)   
## (Intercept)           0.03524    0.10145   0.347  0.72945   
## zNPI                 -0.32431    0.10353  -3.132  0.00259 **
## zrelationship_length -0.13700    0.10311  -1.329  0.18852   
## RLXNPI                0.20934    0.09858   2.124  0.03746 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8428 on 66 degrees of freedom
## Multiple R-squared:  0.2165, Adjusted R-squared:  0.1808 
## F-statistic: 6.077 on 3 and 66 DF,  p-value: 0.001023

Simple slopes

Czarna et al. (2022) examined the moderation effects of narcissism by calculating simple slopes. They adjusted the data points to represent low and high levels of the moderator by adding or subtracting one standard deviation (SD) from the mean, respectively. We will replicate this approach and compute the simple slopes to understand the moderation effect at different levels of narcissism.

  1. Narcissism as the moderator
##Testing simple slopes (for low and high narcissism)
#Low narcissism
Study1$ZNPI_low <- (Study1$zNPI + 1)
Study1$RLXNPI_LOW <- Study1$zrelationship_length*Study1$ZNPI_low

model_Study1_low <- lm(Equity_recoded ~ ZNPI_low + zrelationship_length + RLXNPI_LOW, data=Study1)  
summary(model_Study1_low)
## 
## Call:
## lm(formula = Equity_recoded ~ ZNPI_low + zrelationship_length + 
##     RLXNPI_LOW, data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33147 -0.46370  0.01309  0.48320  2.14537 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)   
## (Intercept)           0.35955    0.14359   2.504  0.01476 * 
## ZNPI_low             -0.32431    0.10353  -3.132  0.00259 **
## zrelationship_length -0.34634    0.13317  -2.601  0.01147 * 
## RLXNPI_LOW            0.20934    0.09858   2.124  0.03746 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8428 on 66 degrees of freedom
## Multiple R-squared:  0.2165, Adjusted R-squared:  0.1808 
## F-statistic: 6.077 on 3 and 66 DF,  p-value: 0.001023
#High narcissism
Study1$ZNPI_high <- (Study1$zNPI - 1)
Study1$RLXNPI_HIGH <- Study1$zrelationship_length*Study1$ZNPI_high

model_Study1_high<- lm(Equity_recoded ~ ZNPI_high + zrelationship_length + RLXNPI_HIGH, data=Study1)  
summary(model_Study1_high)
## 
## Call:
## lm(formula = Equity_recoded ~ ZNPI_high + zrelationship_length + 
##     RLXNPI_HIGH, data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33147 -0.46370  0.01309  0.48320  2.14537 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)   
## (Intercept)          -0.28907    0.14631  -1.976  0.05236 . 
## ZNPI_high            -0.32431    0.10353  -3.132  0.00259 **
## zrelationship_length  0.07233    0.15154   0.477  0.63471   
## RLXNPI_HIGH           0.20934    0.09858   2.124  0.03746 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8428 on 66 degrees of freedom
## Multiple R-squared:  0.2165, Adjusted R-squared:  0.1808 
## F-statistic: 6.077 on 3 and 66 DF,  p-value: 0.001023

This analysis was conducted using linear regression models. The main effects of narcissism (), relationship duration (), and their interaction () on partner enhancement were examined. The results showed that narcissism (\(\beta = -0.32\), \(SE = 0.10\), \(t = -3.13\), \(p = .002\)), but not relationship duration (\(\beta = -0.14\), \(SE = 0.10\), \(t = -1.33\), \(p = .189\)), significantly predicted partner enhancement. However, the interaction term (\(\beta = 0.21\), \(SE = 0.10\), \(t = 2.12\), \(p = .037\)) was found to be significant, indicating moderation effects. Simple slope analysis revealed that at high levels of narcissism (\(+1\) SD), the relationship between relationship duration and partner enhancement was not significant (\(\beta = 0.07\), \(t = 0.48\), \(p = .63\)). However, at low levels of narcissism (\(-1\) SD), relationship duration significantly predicted partner enhancement (\(\beta = -0.35\), \(t = -2.60\), \(p = .01\)).

  1. Relationship duration as the moderator
##Testing simple slopes (for short and long duration)
#Short duration
Study1$Zrelationship_length_low <- (Study1$zrelationship_length + 1)
Study1$RLXNPI_LOW <- Study1$Zrelationship_length_low*Study1$zNPI

model_Study1_low <- lm(Equity_recoded ~ zNPI + Zrelationship_length_low + RLXNPI_LOW, data=Study1)  
summary(model_Study1_low)
## 
## Call:
## lm(formula = Equity_recoded ~ zNPI + Zrelationship_length_low + 
##     RLXNPI_LOW, data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33147 -0.46370  0.01309  0.48320  2.14537 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.17224    0.14354   1.200  0.23444    
## zNPI                     -0.53365    0.13128  -4.065  0.00013 ***
## Zrelationship_length_low -0.13700    0.10311  -1.329  0.18852    
## RLXNPI_LOW                0.20934    0.09858   2.124  0.03746 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8428 on 66 degrees of freedom
## Multiple R-squared:  0.2165, Adjusted R-squared:  0.1808 
## F-statistic: 6.077 on 3 and 66 DF,  p-value: 0.001023
#Long duration
Study1$Zrelationship_length_high<- (Study1$zrelationship_length - 1)
Study1$RLXNPI_HIGH <- Study1$Zrelationship_length_high*Study1$zNPI

Zrelationship_length_high <- lm(Equity_recoded ~ zNPI + Zrelationship_length_high + RLXNPI_HIGH, data=Study1)  
summary(Zrelationship_length_high)
## 
## Call:
## lm(formula = Equity_recoded ~ zNPI + Zrelationship_length_high + 
##     RLXNPI_HIGH, data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33147 -0.46370  0.01309  0.48320  2.14537 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)               -0.10177    0.14576  -0.698   0.4875  
## zNPI                      -0.11497    0.15375  -0.748   0.4572  
## Zrelationship_length_high -0.13700    0.10311  -1.329   0.1885  
## RLXNPI_HIGH                0.20934    0.09858   2.124   0.0375 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8428 on 66 degrees of freedom
## Multiple R-squared:  0.2165, Adjusted R-squared:  0.1808 
## F-statistic: 6.077 on 3 and 66 DF,  p-value: 0.001023

Supplementary: using the interactions package

library(interactions)

interactionsm <- lm(Equity_recoded  ~ zrelationship_length*zNPI, Study1)

sim_slopes(model = interactionsm,
                  pred = zrelationship_length,
                  modx = zNPI)
## JOHNSON-NEYMAN INTERVAL 
## 
## When zNPI is OUTSIDE the interval [-0.34, 13.67], the slope of
## zrelationship_length is p < .05.
## 
## Note: The range of observed values of zNPI is [-2.76, 3.51]
## 
## SIMPLE SLOPES ANALYSIS 
## 
## Slope of zrelationship_length when zNPI = -1.0000000000000002220446 (- 1 SD): 
## 
##    Est.   S.E.   t val.      p
## ------- ------ -------- ------
##   -0.35   0.13    -2.60   0.01
## 
## Slope of zrelationship_length when zNPI = -0.0000000000000002100998 (Mean): 
## 
##    Est.   S.E.   t val.      p
## ------- ------ -------- ------
##   -0.14   0.10    -1.33   0.19
## 
## Slope of zrelationship_length when zNPI =  0.9999999999999997779554 (+ 1 SD): 
## 
##   Est.   S.E.   t val.      p
## ------ ------ -------- ------
##   0.07   0.15     0.48   0.63

Plot

#install.packages("ggplot2")
library("ggplot2")

model_Study1 <- lm(Equity_recoded ~ zNPI + zrelationship_length + RLXNPI, data=Study1)  
summary(model_Study1)
## 
## Call:
## lm(formula = Equity_recoded ~ zNPI + zrelationship_length + RLXNPI, 
##     data = Study1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33147 -0.46370  0.01309  0.48320  2.14537 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)   
## (Intercept)           0.03524    0.10145   0.347  0.72945   
## zNPI                 -0.32431    0.10353  -3.132  0.00259 **
## zrelationship_length -0.13700    0.10311  -1.329  0.18852   
## RLXNPI                0.20934    0.09858   2.124  0.03746 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8428 on 66 degrees of freedom
## Multiple R-squared:  0.2165, Adjusted R-squared:  0.1808 
## F-statistic: 6.077 on 3 and 66 DF,  p-value: 0.001023
b0 <- round(model_Study1$coeff[1], digits = 2)
narcissism <- round(model_Study1$coeff[2], digits = 2)
relationship_length <- round(model_Study1$coeff[3], digits = 2)
interaction <- round(model_Study1$coeff[4], digits = 2)

#intercept for low narcissism is b0 + -1 * narcissism(0.04+ (-1)*(-0.32)) = 0.36); slope for low narcissism is relationship_length + -1 * interaction 
#intercept for average narcissism is b0; slope for average narcissism is relationship_length 
#intercept for high narcissism is b0 + 1 * narcissism; slope for high narcissism is relationship_length + 1 * interaction
plot1<-ggplot(Study1, aes(x = zrelationship_length, y = Equity_recoded)) + xlim(-1,1)+ ylim(-.92,.94) + 
  geom_abline(aes(colour ="- 1 SD",intercept = .36, slope =-.35), size = 1,
              show.legend = FALSE) + 
  geom_abline(aes(colour = "  M",intercept = .04, slope = -.14), size = 1, show.legend =  FALSE) +
  geom_abline(aes(colour ="+ 1 SD", intercept = -.29, slope = .07), size = 1, show.legend = FALSE)+ 
  scale_colour_manual(name = "narcissism", values=c("red", "blue", "green"))+
  theme(
             aspect.ratio = ,
             axis.text = element_text(size = 8),
             axis.title = element_text(size = 10),
             plot.title = element_text(hjust = 0.5, size = 9, face = "bold"),
             panel.grid.major = element_blank(),
             panel.grid.minor = element_blank(),
             panel.background = element_blank(),
             panel.border = element_blank(),
             axis.line = element_line(colour ="black"),
             legend.position = "none") +
           labs(y = expression(atop("Partner-Enhancement")),x = expression(atop("Relationship Duration")),title = "Study 1")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
St1<-plot1+theme_bw()+scale_x_continuous(name="Relationship Duration", breaks=c(-1, 0, 1), labels=c("short", "average", "long"), limits=c(-.92, .94))

St1

#ggsave("St1.tiff", units="in", width=5, height=4, dpi=600, compression = 'lzw')

Study 2

Let’s first inspect the data

names(Study2)
##  [1] "sex"                  "sex_c"                "age"                 
##  [4] "relationship_length"  "Zrelationship_length" "partner_rating"      
##  [7] "Zpartner_rating"      "self_rating"          "Zself_rating"        
## [10] "narcissism"           "Znarcissism"          "RSES"                
## [13] "ZRSES"
glimpse(Study2)
## Rows: 412
## Columns: 13
## $ sex                  <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1…
## $ sex_c                <dbl> -0.099515, -0.099515, -0.099515, 0.900485, -0.099…
## $ age                  <dbl> 19, 21, 18, 26, 25, 19, 18, 22, 23, 20, 28, 22, 1…
## $ relationship_length  <dbl> 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3…
## $ Zrelationship_length <dbl> -0.8441593, -0.8441593, -0.8233252, -0.8233252, -…
## $ partner_rating       <dbl> 75, 62, 82, 80, 76, 66, 85, 87, 83, 76, 72, 82, 7…
## $ Zpartner_rating      <dbl> 0.484039030, -0.569399835, 1.051275343, 0.8892078…
## $ self_rating          <dbl> 59, 70, 73, 84, 77, 59, 54, 77, 80, 68, 73, 76, 6…
## $ Zself_rating         <dbl> -0.5727825, 0.4112396, 0.6796092, 1.6636313, 1.03…
## $ narcissism           <dbl> 2.75, 3.25, 2.75, 1.75, 1.00, 3.25, 4.50, 2.50, 2…
## $ Znarcissism          <dbl> 0.05205535, 0.53400598, 0.05205535, -0.91184591, …
## $ RSES                 <dbl> 25, 49, 16, 62, 70, 47, 23, 61, 53, 58, 67, 55, 5…
## $ ZRSES                <dbl> -2.215330782, -0.168881719, -2.982749180, 0.93961…
#creating dependent variable
Study2$Partner_enhancement<- Study2$partner_rating-Study2$self_rating
#creating control variable:
Study2$Control<- Study2$partner_rating+Study2$self_rating


library(psych)
corr.test(Study2[c("relationship_length", "narcissism", "Partner_enhancement")])
## Call:corr.test(x = Study2[c("relationship_length", "narcissism", "Partner_enhancement")])
## Correlation matrix 
##                     relationship_length narcissism Partner_enhancement
## relationship_length                1.00       0.03               -0.05
## narcissism                         0.03       1.00               -0.05
## Partner_enhancement               -0.05      -0.05                1.00
## Sample Size 
## [1] 412
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##                     relationship_length narcissism Partner_enhancement
## relationship_length                0.00       0.88                0.88
## narcissism                         0.60       0.00                0.88
## Partner_enhancement                0.33       0.29                0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

Standardizing variables

When you standardize a variable using the equation ((x - μ) / σ), it transforms the variable so that it has a mean of 0 and a standard deviation of 1.

library(base)
Study2$zrelationship_length <- scale(Study2$relationship_length)
Study2$znarcissism <- scale(Study2$narcissism)

Model specification

#creating interaction terms
Study2$RLXNar <- Study2$zrelationship_length*Study2$znarcissism

#calculating basic model_Step1
model_Study2 <- lm(Partner_enhancement ~ znarcissism + zrelationship_length + Control, data=Study2)  
summary(model_Study2)
## 
## Call:
## lm(formula = Partner_enhancement ~ znarcissism + zrelationship_length + 
##     Control, data = Study2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -57.083  -6.012   0.181   6.476  40.308 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)  
## (Intercept)          -5.03832    4.15326  -1.213   0.2258  
## znarcissism          -0.56673    0.60928  -0.930   0.3528  
## zrelationship_length -0.45125    0.61150  -0.738   0.4610  
## Control               0.06444    0.03056   2.108   0.0356 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.33 on 408 degrees of freedom
## Multiple R-squared:  0.01561,    Adjusted R-squared:  0.008371 
## F-statistic: 2.157 on 3 and 408 DF,  p-value: 0.0926
#calculating basic model_Step2
model_Study2 <- lm(Partner_enhancement ~ znarcissism + zrelationship_length + RLXNar + Control, data=Study2)  
summary(model_Study2)
## 
## Call:
## lm(formula = Partner_enhancement ~ znarcissism + zrelationship_length + 
##     RLXNar + Control, data = Study2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -56.794  -6.464   0.191   6.435  39.779 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)  
## (Intercept)          -5.06725    4.13469  -1.226   0.2211  
## znarcissism          -0.55747    0.60657  -0.919   0.3586  
## zrelationship_length -0.60443    0.61287  -0.986   0.3246  
## RLXNar                1.43042    0.66131   2.163   0.0311 *
## Control               0.06438    0.03043   2.116   0.0350 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.28 on 407 degrees of freedom
## Multiple R-squared:  0.0268, Adjusted R-squared:  0.01723 
## F-statistic: 2.802 on 4 and 407 DF,  p-value: 0.02566

Simple slopes

We will shift the data points to evaluate the effects at high (+1SD) and low (-1SD) levels of narcissism, following the methodology of Czarna et al. (2022).

Narcissism as the moderator:

##Testing simple slopes (for low and high narcissism)
#Low narcissism
Study2$Znarcissism_low <- (Study2$znarcissism  + 1)
Study2$RLXNar_LOW <- Study2$zrelationship_length *Study2$Znarcissism_low

model_Study2_low <- lm(Partner_enhancement ~ Znarcissism_low + zrelationship_length  + RLXNar_LOW + Control, data=Study2)  
summary(model_Study2_low)
## 
## Call:
## lm(formula = Partner_enhancement ~ Znarcissism_low + zrelationship_length + 
##     RLXNar_LOW + Control, data = Study2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -56.794  -6.464   0.191   6.435  39.779 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)  
## (Intercept)          -4.50979    4.20801  -1.072   0.2845  
## Znarcissism_low      -0.55747    0.60657  -0.919   0.3586  
## zrelationship_length -2.03486    0.95215  -2.137   0.0332 *
## RLXNar_LOW            1.43042    0.66131   2.163   0.0311 *
## Control               0.06438    0.03043   2.116   0.0350 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.28 on 407 degrees of freedom
## Multiple R-squared:  0.0268, Adjusted R-squared:  0.01723 
## F-statistic: 2.802 on 4 and 407 DF,  p-value: 0.02566
#High narcissism
Study2$Znarcissism_high <- (Study2$znarcissism - 1)
Study2$RLXNar_HIGH <- Study2$zrelationship_length *Study2$Znarcissism_high

model_Study2_high<- lm(Partner_enhancement ~ Znarcissism_high + zrelationship_length  + RLXNar_HIGH + Control, data=Study2)  
summary(model_Study2_high)
## 
## Call:
## lm(formula = Partner_enhancement ~ Znarcissism_high + zrelationship_length + 
##     RLXNar_HIGH + Control, data = Study2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -56.794  -6.464   0.191   6.435  39.779 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)  
## (Intercept)          -5.62472    4.14967  -1.355   0.1760  
## Znarcissism_high     -0.55747    0.60657  -0.919   0.3586  
## zrelationship_length  0.82599    0.84810   0.974   0.3307  
## RLXNar_HIGH           1.43042    0.66131   2.163   0.0311 *
## Control               0.06438    0.03043   2.116   0.0350 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.28 on 407 degrees of freedom
## Multiple R-squared:  0.0268, Adjusted R-squared:  0.01723 
## F-statistic: 2.802 on 4 and 407 DF,  p-value: 0.02566

We can replicate this process by using the interactions package, which provides functions for probing interactions in regression models without manual data manipulation.

interactionsm2 <- lm(Partner_enhancement  ~ znarcissism*zrelationship_length + Control, Study2)

sim_slopes(model = interactionsm2,
                  pred = zrelationship_length,
                  modx = znarcissism)
## JOHNSON-NEYMAN INTERVAL 
## 
## When znarcissism is OUTSIDE the interval [-0.68, 4.51], the slope of
## zrelationship_length is p < .05.
## 
## Note: The range of observed values of znarcissism is [-1.63, 2.22]
## 
## SIMPLE SLOPES ANALYSIS 
## 
## Slope of zrelationship_length when znarcissism = -0.99999999999999988897770 (- 1 SD): 
## 
##    Est.   S.E.   t val.      p
## ------- ------ -------- ------
##   -2.03   0.95    -2.14   0.03
## 
## Slope of zrelationship_length when znarcissism = -0.00000000000000005473642 (Mean): 
## 
##    Est.   S.E.   t val.      p
## ------- ------ -------- ------
##   -0.60   0.61    -0.99   0.32
## 
## Slope of zrelationship_length when znarcissism =  0.99999999999999988897770 (+ 1 SD): 
## 
##   Est.   S.E.   t val.      p
## ------ ------ -------- ------
##   0.83   0.85     0.97   0.33

This analysis was conducted using linear regression models. The main effects of narcissism (), relationship duration (), and their interaction () on partner enhancement were examined. The results showed that narcissism (\(\beta = -0.56\), \(SE = 0.61\), \(t = -0.92\), \(p = .36\)) and relationship duration (\(\beta = -0.60\), \(SE = 0.61\), \(t = -0.99\), \(p = .32\)) did not significantly predict partner enhancement. However, the interaction term (\(\beta = 1.43\), \(SE = 0.66\), \(t = 2.16\), \(p = .03\)) was found to be significant, indicating moderation effects. Additionally, control variables were included in the model, and the coefficient for control was significant (\(\beta = 0.06\), \(SE = 0.03\), \(t = 2.12\), \(p = .04\)). Simple slope analysis revealed that at high levels of narcissism (\(+1\) SD), the relationship between relationship duration and partner enhancement was marginally significant (\(\beta = 0.83\), \(t = 0.97\), \(p = .33\)). However, at low levels of narcissism (\(-1\) SD), relationship duration significantly predicted partner enhancement (\(\beta = -2.03\), \(t = -2.14\), \(p = .03\)).

Plot

plot2<-ggplot(Study2, aes(x = Zrelationship_length, y = Partner_enhancement)) + xlim(-.82,.317)+ ylim(-8.77,16.01) + 
  geom_abline(aes(colour ="- 1 SD",intercept =3.56, slope =-2.03), size = 1,
              show.legend = FALSE) + 
  geom_abline(aes(colour = "  M", intercept = 3.00, slope =-.6), size = 1, 
              show.legend = FALSE) +
  geom_abline(aes(colour ="+ 1 SD", intercept = 2.44, slope = .83), size = 1, 
              show.legend = FALSE)+
  scale_colour_manual(name = "narcissism", values=c("red", "blue", "green"))+
  theme(
    aspect.ratio = ,
    axis.text = element_text(size = 8),
    axis.title = element_text(size = 10),
    plot.title = element_text(hjust = 0.5, size = 9, face = "bold"),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    panel.background = element_blank(),
    panel.border = element_blank(),
    axis.line = element_line(colour ="black"),
        legend.position = "none") +
  labs(y = expression(atop("Partner-Enhancement")),x = expression(atop("Relationship Duration")),title = "Study 2")

St2<-plot2+theme_bw()+scale_x_continuous(name="Relationship Duration", breaks=c(-0.81, -.25, .316), labels=c("short", "average", "long"), limits=c(-.81, .317))
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
ggsave("St2.tiff", units="in", width=5, height=4, dpi=600, compression = 'lzw')

St2

Supplementary analysis: condition-based regression analysis (CRA)

Reference:

Humberg, S., Dufner, M., Schönbrodt, F. D., Geukes, K., Hutteman, R., Van Zalk, M. H., … & Back, M. D. (2018). Enhanced versus simply positive: A new condition-based regression analysis to disentangle effects of self-enhancement from effects of positivity of self-view. Journal of Personality and Social Psychology, 114(2), 303. https://doi.org/10.1037/pspp0000134

library(lavaan)
## This is lavaan 0.6-16
## lavaan is FREE software! Please report any bugs.
## 
## Attaching package: 'lavaan'
## The following object is masked from 'package:psych':
## 
##     cor2cov
cramodel <-  'relationship_length ~ 1 + c1*partner_rating + c2*self_rating
a1 := c1+c2
a3 := c1-c2
c1_times_2 := 2*c1
c2_times_2 := 2*c2
minus_c1_times_2 := -2*c1
minus_c2_times_2 := -2*c2'

## Determination of the parameter abs := |c1 - c2| - |c1 + c2| > 0
## c1 - c2 > 0

cramodelout <- sem(cramodel, data=Study2)
summary(cramodelout)
## lavaan 0.6.16 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         4
## 
##   Number of observations                           412
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                         Estimate  Std.Err  z-value  P(>|z|)
##   relationship_length ~                                    
##     prtnr_rtn (c1)        -0.373    0.213   -1.751    0.080
##     self_rtng (c2)        -0.083    0.235   -0.353    0.724
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .reltnshp_lngth   72.727   15.991    4.548    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .reltnshp_lngth 2272.365  158.323   14.353    0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     a1               -0.456    0.236   -1.932    0.053
##     a3               -0.290    0.382   -0.760    0.447
##     c1_times_2       -0.747    0.426   -1.751    0.080
##     c2_times_2       -0.166    0.471   -0.353    0.724
##     minus_c1_tms_2    0.747    0.426    1.751    0.080
##     minus_c2_tms_2    0.166    0.471    0.353    0.724

At -1SD:

# Calculate the mean and standard deviation
mean_narcissism <- mean(Study2$narcissism, na.rm = TRUE)
sd_narcissism <- sd(Study2$narcissism, na.rm = TRUE)

# Define the threshold for -1 standard deviation
threshold <- mean_narcissism - sd_narcissism

low <- subset(Study2, Study2$narcissism < threshold)

cramodeloutlow <- sem(cramodel, data=low)
summary(cramodeloutlow)
## lavaan 0.6.16 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         4
## 
##   Number of observations                            78
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                         Estimate  Std.Err  z-value  P(>|z|)
##   relationship_length ~                                    
##     prtnr_rtn (c1)        -0.682    0.359   -1.897    0.058
##     self_rtng (c2)         0.513    0.380    1.351    0.177
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .reltnshp_lngth   51.174   23.789    2.151    0.031
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .reltnshp_lngth 1292.663  206.992    6.245    0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     a1               -0.169    0.345   -0.490    0.624
##     a3               -1.195    0.654   -1.826    0.068
##     c1_times_2       -1.364    0.719   -1.897    0.058
##     c2_times_2        1.026    0.760    1.351    0.177
##     minus_c1_tms_2    1.364    0.719    1.897    0.058
##     minus_c2_tms_2   -1.026    0.760   -1.351    0.177
estimates <- parameterEstimates(cramodeloutlow)
library(dplyr) # needed for easier handling of data frames

if (subset(estimates, label == "a3")["est"]>=0 & subset(estimates, label == "a1")["est"]>0){
  abs <- round(subset(estimates, label == "minus_c2_times_2")["est"],2)
  se <- round(subset(estimates, label == "minus_c2_times_2")["se"],2)
  a3_is <- "positive"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "minus_c2_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "minus_c2_times_2")["pvalue"]/2), 5)}
}


if (subset(estimates, label == "a3")["est"]<0 & subset(estimates, label == "a1")["est"]>0){
  abs <- round(subset(estimates, label == "minus_c1_times_2")["est"],2)
  se <- round(subset(estimates, label == "minus_c1_times_2")["se"],2)
  a3_is <- "negative"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "minus_c1_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "minus_c1_times_2")["pvalue"]/2), 5)}
}


if (subset(estimates, label == "a3")["est"]>=0 & subset(estimates, label == "a1")["est"]<0){
  abs <- round(subset(estimates, label == "c1_times_2")["est"],2)
  se <- round(subset(estimates, label == "c1_times_2")["se"],2)
  a3_is <- "positive"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "c1_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "c1_times_2")["pvalue"]/2), 5)}
}


if (subset(estimates, label == "a3")["est"]<0 & subset(estimates, label == "a1")["est"]<0){
  abs <- round(subset(estimates, label == "c2_times_2")["est"],2)
  se <- round(subset(estimates, label == "c2_times_2")["se"],2)
  a3_is <- "negative"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "c2_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "c2_times_2")["pvalue"]/2), 5)}
}

print(c("abs"=abs,se,pvalue,"a3 is"=a3_is))
## $abs.est
## [1] 1.03
## 
## $se
## [1] 0.76
## 
## $pvalue
## [1] 0.08838
## 
## $`a3 is`
## [1] "negative"
##########################################################################
## Interpretation: 
## If abs is significantly bigger than zero, there is an effect of 
## self enhancement (SE) that has the same sign as a3 := (c1 - c2).

#individuals who partner enhance tend to have shorter relationship duration
##########################################################################
##########################################################################

At +1SD:

# Calculate the mean and standard deviation
mean_narcissism <- mean(Study2$narcissism, na.rm = TRUE)
sd_narcissism <- sd(Study2$narcissism, na.rm = TRUE)

# Define the threshold for -1 standard deviation
threshold <- mean_narcissism + sd_narcissism

high <- subset(Study2, Study2$narcissism > threshold)

cramodelouthigh <- sem(cramodel, data=high)
summary(cramodelouthigh)
## lavaan 0.6.16 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         4
## 
##   Number of observations                            84
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                         Estimate  Std.Err  z-value  P(>|z|)
##   relationship_length ~                                    
##     prtnr_rtn (c1)         0.468    0.337    1.390    0.165
##     self_rtng (c2)        -0.257    0.412   -0.625    0.532
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .reltnshp_lngth   25.777   30.997    0.832    0.406
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .reltnshp_lngth 1462.516  225.671    6.481    0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     a1                0.211    0.464    0.454    0.650
##     a3                0.725    0.592    1.225    0.221
##     c1_times_2        0.936    0.674    1.390    0.165
##     c2_times_2       -0.514    0.823   -0.625    0.532
##     minus_c1_tms_2   -0.936    0.674   -1.390    0.165
##     minus_c2_tms_2    0.514    0.823    0.625    0.532
estimates <- parameterEstimates(cramodelouthigh)
library(dplyr) # needed for easier handling of data frames

if (subset(estimates, label == "a3")["est"]>=0 & subset(estimates, label == "a1")["est"]>0){
  abs <- round(subset(estimates, label == "minus_c2_times_2")["est"],2)
  se <- round(subset(estimates, label == "minus_c2_times_2")["se"],2)
  a3_is <- "positive"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "minus_c2_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "minus_c2_times_2")["pvalue"]/2), 5)}
}


if (subset(estimates, label == "a3")["est"]<0 & subset(estimates, label == "a1")["est"]>0){
  abs <- round(subset(estimates, label == "minus_c1_times_2")["est"],2)
  se <- round(subset(estimates, label == "minus_c1_times_2")["se"],2)
  a3_is <- "negative"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "minus_c1_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "minus_c1_times_2")["pvalue"]/2), 5)}
}


if (subset(estimates, label == "a3")["est"]>=0 & subset(estimates, label == "a1")["est"]<0){
  abs <- round(subset(estimates, label == "c1_times_2")["est"],2)
  se <- round(subset(estimates, label == "c1_times_2")["se"],2)
  a3_is <- "positive"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "c1_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "c1_times_2")["pvalue"]/2), 5)}
}


if (subset(estimates, label == "a3")["est"]<0 & subset(estimates, label == "a1")["est"]<0){
  abs <- round(subset(estimates, label == "c2_times_2")["est"],2)
  se <- round(subset(estimates, label == "c2_times_2")["se"],2)
  a3_is <- "negative"
  
  # compute one-tailed p-value of abs for the hypothesis abs > 0, 
  # depending on the tail in which abs is positioned
  if (abs >= 0){pvalue <- round(subset(estimates, label == "c2_times_2")["pvalue"]/2, 5)}
  if (abs < 0){pvalue <- round(1 - (subset(estimates, label == "c2_times_2")["pvalue"]/2), 5)}
}

print(c("abs"=abs,se,pvalue,"a3 is"=a3_is))
## $abs.est
## [1] 0.51
## 
## $se
## [1] 0.82
## 
## $pvalue
## [1] 0.26602
## 
## $`a3 is`
## [1] "positive"
##########################################################################
## Interpretation: 
## If abs is significantly bigger than zero, there is an effect of 
## self enhancement (SE) that has the same sign as a3 := (c1 - c2).
#partner enhancement nonsignificantly associated with relationship duration
##########################################################################
##########################################################################