-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 781b2de
Showing
29 changed files
with
6,149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^renv$ | ||
^renv\.lock$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source("renv/activate.R") | ||
|
||
devtools::load_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!/.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# R auxiliary files | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
|
||
# Other files types | ||
|
||
# htlm output | ||
Todo.html | ||
Documents/*.html | ||
*.docx | ||
|
||
# Project folders | ||
|
||
# data_raw | ||
*.rda | ||
*.rds | ||
|
||
# Mac auxiliary files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
######################## | ||
#### Analysis #### | ||
######################## | ||
|
||
#---- load env ---- | ||
env <- devtools::load_all()$env | ||
|
||
#---- Plan ----- | ||
|
||
# load plan | ||
plan <- get_analysis_plan() | ||
|
||
# Configure the analysis plan | ||
config <- drake::drake_config(plan, | ||
prework = "devtools::load_all()", | ||
envir = env) | ||
|
||
# Plot the analysis plan | ||
drake::vis_drake_graph(config, font_size = 16, targets_only = FALSE) | ||
|
||
#---- Make ---- | ||
|
||
# Delate the analysis results | ||
# drake::clean(destroy = TRUE) | ||
|
||
# Run the analysis | ||
drake::make(prework = "devtools::load_all()", | ||
envir = env, | ||
plan = plan) | ||
|
||
# Plot the analysis plan | ||
drake::vis_drake_graph(config, font_size = 16, targets_only = FALSE) | ||
|
||
#---- load ---- | ||
|
||
# data | ||
drake::loadd(data_munged) | ||
|
||
#---- cluster ---- | ||
|
||
# cluster tat | ||
drake::loadd(cluster_mother_tat) | ||
drake::loadd(cluster_father_tat) | ||
|
||
plot(cluster_mother_tat, main = "Dendrogramma") | ||
rect.hclust(cluster_mother_tat, k=4, border="red") | ||
plot(cluster_father_tat, main = "Dendrogramma") | ||
rect.hclust(cluster_father_tat, k=4, border="red") | ||
|
||
drake::loadd(data_cluster_tat) | ||
table(data_cluster_tat$cluster_mother_tat) | ||
table(data_cluster_tat$cluster_father_tat) | ||
|
||
plot_scores_mother(data = data_cluster_tat) | ||
plot_scores_father(data = data_cluster_tat) | ||
|
||
# mclust | ||
drake::loadd(mclust_mother) | ||
drake::loadd(mclust_father) | ||
|
||
plot(mclust_mother) | ||
summary(mclust_mother) | ||
|
||
plot(mclust_father) | ||
summary(mclust_father) | ||
|
||
#---- brms models ---- | ||
|
||
drake::loadd(fit_int) | ||
|
||
summary(fit_int) | ||
plot(brms::conditional_effects(fit_int), ask = FALSE) | ||
|
||
plot(fit_int) | ||
|
||
drake::loadd(stan_data) | ||
|
||
str(fit_int$fit) | ||
#----- | ||
|
||
|
||
|
||
|
||
#---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
load("Data/ddef_datiECR.rda") | ||
ddef=ddef_datiECR[ddef_datiECR$age_year<12.30,] | ||
ddef<- subset(ddef, ddef$fas !="NA") | ||
nrow(ddef) #847 | ||
|
||
#---- cluster madre ---- | ||
|
||
dcM <- dist(ddef[,c(60:71)], method = "euclidean") # distance matrix | ||
fit <- hclust(dcM, method="ward.D") | ||
plot(fit, main = "Dendrogramma") | ||
# dal dendrogramma sembrano emergere 4 cluster | ||
rect.hclust(fit, k=4, border="red") | ||
ddef$gruppiattM <- as.factor(cutree(fit, k=4)) | ||
table(ddef$gruppiattM) | ||
|
||
|
||
# profilo | ||
fattore=rep(c("Ansia","Evitamento"),rep(dim(ddef)[1],2)) | ||
y=c(scale(ddef$Anxm),scale(ddef$Avm)) | ||
y1=c(ddef$Anxm,ddef$Avm) | ||
gruppo=rep(ddef$gruppiattM,2) | ||
dprof=data.frame(y,y1,fattore,gruppo) | ||
|
||
|
||
dprof$nomi.gruppi=factor(dprof$gruppo,labels=c("Gruppo1: Sicuri (n = 231)","Gruppo 2: Ansiosi (n = 286)","Gruppo 3: Ansiosi-Evitanti (n = 100)","Gruppo 4: Evitanti (n = 230)")) | ||
par(mar=c(6, 5, 4, 2) + 0.1) | ||
|
||
sciplot::bargraph.CI(fattore, y, group = nomi.gruppi, data=dprof,legend=T,ylim=c(-2.4,1.6),x.leg=1.2, y.leg=-1.2,ylab="Punteggi standardizzati",xlab="",cex.lab=.8,cex.leg=.8, col=c("yellow","green","blue","red")) | ||
|
||
|
||
#---- cluster padre ---- | ||
|
||
dcP <- dist(ddef[,c(99:110)], method = "euclidean") # distance matrix | ||
fit <- hclust(dcP, method="ward.D") | ||
plot(fit, main = "Dendrogramma") | ||
# dal dendrogramma sembrano emergere 4 cluster | ||
rect.hclust(fit, k=4, border="red") | ||
ddef$gruppiattP <- as.factor(cutree(fit, k=4)) | ||
|
||
# Profilo | ||
fattore=rep(c("Ansia","Evitamento"),rep(dim(ddef)[1],2)) | ||
y=c(scale(ddef$Anxp),scale(ddef$Avp)) | ||
y1=c(ddef$Anxp,ddef$Avp) | ||
gruppo=rep(ddef$gruppiattP,2) | ||
dprof=data.frame(y,y1,fattore,gruppo) | ||
|
||
dprof$nomi.gruppi=factor(dprof$gruppo,labels=c("Gruppo1: Sicuri (n = 206)","Gruppo 2: Ansiosi (n = 230)","Gruppo 3: Evitanti (n = 311 )","Gruppo 4: Ansiosi-Evitanti (n = 100)")) | ||
|
||
par(mar=c(6, 5, 4, 2) + 0.1) | ||
|
||
sciplot::bargraph.CI(fattore, y, group = nomi.gruppi, data=dprof,legend=T,ylim=c(-2.4,1.6),x.leg=1.2, y.leg=-1.2,ylab="Punteggi standardizzati",xlab="",cex.lab=.8,cex.leg=.8, col=c("yellow","green","blue","red")) | ||
|
||
prop.table(table(ddef$gruppiattP, ddef$gruppiattM), margin = 1) | ||
str(ddef$gruppiattP) | ||
|
||
cor(as.numeric(ddef$gruppiattP), as.numeric(ddef$gruppiattM)) | ||
|
||
#---- fit ext ---- | ||
|
||
hist(ddef$externalizing_sum) | ||
|
||
fit_ext <- glm(round(externalizing_sum,0) ~ genere * gruppiattP * gruppiattM, ddef, | ||
family = "poisson") | ||
summary(fit_ext) | ||
car::Anova(fit_ext) | ||
plot(fit_ext) | ||
|
||
performance::check_zeroinflation(fit_ext) | ||
|
||
plot(effects::allEffects(fit_ext)) | ||
|
||
# log transform | ||
hist(log(ddef$externalizing_sum)) | ||
|
||
#---- fit ext no 0 ---- | ||
|
||
sum(ddef$externalizing_sum > 0) | ||
ddef_ext0 <- ddef[ddef$externalizing_sum > 0, ] | ||
hist(ddef_ext0$externalizing_sum) | ||
|
||
fit_ext0 <- glm(round(externalizing_sum,0) ~ genere * gruppiattP * gruppiattM, ddef_ext0, family = "poisson") | ||
summary(fit_ext0) | ||
car::Anova(fit_ext0) | ||
plot(fit_ext0) | ||
|
||
plot(effects::allEffects(fit_ext0)) | ||
|
||
|
||
summary(fit_ext0$residuals) | ||
hist(fit_ext0$residuals) | ||
|
||
|
||
#---- fit int ---- | ||
|
||
hist(ddef$internalizing_sum) | ||
sum(ddef$internalizing_sum > 0) | ||
|
||
fit_int <- glm(round(internalizing_sum,0) ~ genere * gruppiattP * gruppiattM, ddef, family = "poisson") | ||
summary(fit_int) | ||
car::Anova(fit_int) | ||
|
||
|
||
fit_int_ext <- lm(cbind(internalizing_sum, externalizing_sum) ~ genere * gruppiattP * gruppiattM, ddef) | ||
|
||
|
||
|
||
performance::check_zeroinflation(fit_int) | ||
|
||
plot(effects::allEffects(fit_int)) | ||
|
||
|
||
#---- | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: knitr | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,collate,namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Package: Attachment | ||
Type: Package | ||
Title: What the Package Does (Title Case) | ||
Version: 0.1.0 | ||
Author@R: | ||
c(person(given = "Claudio", | ||
family = "Zandonella Callegher", | ||
role = c("aut", "cre"), | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0001-7721-6318")), | ||
person(given = "Tatiana", | ||
family = "Marci", | ||
role = "aut", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-2813-0312")) | ||
person(given = "Gianmarco", | ||
family = "Altoè", | ||
role = "aut", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0003-1154-9528")) | ||
) | ||
Maintainer: Claudio Zandonella Callegher <[email protected]> | ||
Description: Analysis of atttachemnet theory | ||
License: | ||
Encoding: UTF-8 | ||
Depends: | ||
tidyverse, | ||
devtools | ||
Imports: | ||
rmarkdown | ||
Suggests: | ||
knitr, | ||
testthat (>= 3.0.0) | ||
LazyData: true | ||
Config/testthat/edition: 3 | ||
RoxygenNote: 7.1.1 | ||
VignetteBuilder: knitr |
Oops, something went wrong.