Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hot Topic_Cool Choices
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nc71qaxa
Hot Topic_Cool Choices
Commits
78a22af9
Commit
78a22af9
authored
8 months ago
by
nc71qaxa
Browse files
Options
Downloads
Patches
Plain Diff
visualize distributions
parent
004a1e65
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Scripts/visualize_distr_spli.R
+50
-8
50 additions, 8 deletions
Scripts/visualize_distr_spli.R
with
50 additions
and
8 deletions
Scripts/visualize_distr_spli.R
+
50
−
8
View file @
78a22af9
...
...
@@ -16,6 +16,38 @@ models <- list(
"Treated Pred"
=
MXL_wtp_Treated_Pred_model
)
group_color_mapping
<-
c
(
"Control"
=
"grey"
,
"Treated"
=
"red"
,
"Optional"
=
"yellow"
)
# Define line type mapping for prediction status
prediction_line_mapping
<-
c
(
"Not Predicted"
=
"dashed"
,
"Predicted"
=
"solid"
)
# Create a mapping for the groups
group_mapping
<-
c
(
"Control Not Pred"
=
"Control"
,
"Control Pred"
=
"Control"
,
"Treated Not Pred"
=
"Treated"
,
"Treated Pred"
=
"Treated"
,
"Opt Not Pred"
=
"Optional"
,
"Opt Pred"
=
"Optional"
)
# Create a mapping for prediction status
prediction_mapping
<-
c
(
"Control Not Pred"
=
"Not Predicted"
,
"Control Pred"
=
"Predicted"
,
"Treated Not Pred"
=
"Not Predicted"
,
"Treated Pred"
=
"Predicted"
,
"Opt Not Pred"
=
"Not Predicted"
,
"Opt Pred"
=
"Predicted"
)
# Define the x-range for plotting (1000 values)
x_range
<-
seq
(
-20
,
100
,
length.out
=
1000
)
...
...
@@ -36,22 +68,32 @@ for (i in seq_along(models)) {
y
<-
dnorm
(
x_range
,
mean
,
sd
)
# Create a data frame for this model and append it to the main data frame
temp_data
<-
data.frame
(
x
=
x_range
,
density
=
y
,
model
=
model_name
)
temp_data
<-
data.frame
(
x
=
x_range
,
density
=
y
,
model
=
model_name
,
Group
=
group_mapping
[[
model_name
]],
Prediction
=
prediction_mapping
[[
model_name
]]
)
plot_data
<-
bind_rows
(
plot_data
,
temp_data
)
}
# Plot using ggplot2
ggplot
(
plot_data
,
aes
(
x
=
x
,
y
=
density
,
color
=
model
))
+
geom_line
()
+
# Plot using ggplot2 with custom color and linetype mappings
ggplot
(
plot_data
,
aes
(
x
=
x
,
y
=
density
,
color
=
Group
,
linetype
=
Prediction
))
+
geom_line
(
size
=
1
)
+
scale_color_manual
(
values
=
group_color_mapping
)
+
# Set custom colors for groups
scale_linetype_manual
(
values
=
prediction_line_mapping
)
+
# Set custom linetypes for prediction status
labs
(
title
=
"Normal Distributions from Multiple MXL Models"
,
x
=
"
x
"
,
x
=
"
WTP Naturalness (€/month)
"
,
y
=
"Density"
,
color
=
"Model"
color
=
"Group"
,
linetype
=
"Prediction"
)
+
theme_minimal
()
+
theme
(
legend.position
=
"right"
)
+
scale_color_brewer
(
palette
=
"Set1"
)
theme
(
legend.position
=
"right"
)
#### Z-test if distributions are different
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment