-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMedMod_medflexpack.R
58 lines (48 loc) · 1.8 KB
/
MedMod_medflexpack.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
library(medflex)
data("UPBdata")
head(UPBdata)
# mediator: negaff
# predictor: att
# outcome: UPB
# data
setwd("F:\\Megasync\\transgenderdata")
data.tg <- readxl::read_xlsx("Data_transgenderBSSImodification_dataUpdated.xlsx",
sheet = "Sheet1")
data.tg2 <- read.csv("Data_transgenderBSSImodification_dataUpdatedfromspss.csv")
setwd("/Users/sulailfatima/Desktop/Megasync/transgenderdata")
tg.data <- read.spss("Data_transgenderBSSImodification_dataUpdated.sav",
to.data.frame = T,
use.value.labels = TRUE,
trim.factor.names = F,
trim_values = F)
# Scaling
## Standardized variables
## BSSI
ave.bssi <- mean(tg.data$BSSIScore2)
sd.bssi <- sd(tg.data$BSSIScore2)
tg.data$stdbssi <- ((tg.data$BSSIScore2 - ave.bssi)/sd.bssi)
## SC
ave.sc <- mean(tg.data$SCTotalScore)
sd.sc <- sd(tg.data$SCTotalScore)
tg.data$stdsc <- ((tg.data$SCTotalScore - ave.sc)/sd.sc)
## AKUADS
ave.akuads <- mean(tg.data$AKUADSScore2)
sd.akuads <- sd(tg.data$AKUADSScore2)
tg.data$stdakuads <- ((tg.data$AKUADSScore2 - ave.akuads)/sd.akuads)
medFit <- glm(AKUADSScore2 ~ SCTotalScore,
family = gaussian, data = tg.data)
w <- weights(medFit)
neMod1 <- neModel(BSSIScore2 ~ SCTotalScore0 + SCTotalScore1,
expData = medFit)
# using this paper file:///C:/Users/OWAIS/Downloads/v76i11.pdf page 24
# on this paper https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7853644/pdf/nihms-1599745.pdf page 10
expData2 <-neImpute(stdbssi ~ stdsc*stdakuads, data= tg.data)
neMod2 <-neModel(stdbssi ~ stdsc0*stdsc1, expData = expData2,
se="bootstrap",
nBoot = 1000)
neMod2eff<-neEffdecomp(neMod2)
summary(neMod2eff)
confint(neMod2eff, level=.95, type="perc")
par(mfrow = c(1,2))
plot(neMod2)
str(neMod2)