Skip to content

Commit

Permalink
update vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgirard committed Oct 25, 2024
1 parent 9ed0fab commit f9e9705
Show file tree
Hide file tree
Showing 37 changed files with 1,740 additions and 1,100 deletions.
6 changes: 3 additions & 3 deletions R/ssm_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ ssm_analyze_corrs <- function(data, scales, angles, measures, grouping,

# Get names of measures (using labels if provided)
if (is.null(measures_labels)) {
measure_labels <- measures_names
measures_labels <- measures_names
}

# Calculate observed correlation scores
Expand All @@ -322,7 +322,7 @@ ssm_analyze_corrs <- function(data, scales, angles, measures, grouping,
}
scores <- as.data.frame(scores)
Group <- rep(group_levels, each = n_measures)
Measure <- rep(measure_labels, times = n_groups)
Measure <- rep(measures_labels, times = n_groups)
if (contrast && is.null(grouping)) {
Group <- c(Group, Group[[1]])
Measure <- c(Measure, paste0(Measure[[2]], " - ", Measure[[1]]))
Expand Down Expand Up @@ -363,7 +363,7 @@ ssm_analyze_corrs <- function(data, scales, angles, measures, grouping,
)

Group <- rep(group_levels, each = n_measures)
Measure <- rep(measure_labels, times = n_groups)
Measure <- rep(measures_labels, times = n_groups)
if (contrast && is.null(grouping)) {
Group <- c(Group, Group[[1]])
Measure <- c(Measure, paste0(Measure[[2]], " - ", Measure[[1]]))
Expand Down
17 changes: 2 additions & 15 deletions R/ssm_visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ ssm_plot_contrast <- function(.ssm_object, drop_xy = FALSE,
) +
ggplot2::geom_errorbar(
ggplot2::aes(x = "1", ymin = lci, ymax = uci),
linewidth = linesize, width = 0.1
linewidth = linesize, width = 0.15
) +
ggplot2::geom_point(
ggplot2::aes(x = "1", y = Difference, fill = sig),
Expand All @@ -300,7 +300,7 @@ ssm_plot_contrast <- function(.ssm_object, drop_xy = FALSE,
shape = 21
) +
ggplot2::scale_fill_manual(
"Signficant",
"Significant",
values = c("TRUE" = sig_color, "FALSE" = ns_color)
) +
ggplot2::labs(y = paste0("Contrast (", res$label, ")")) +
Expand Down Expand Up @@ -453,19 +453,6 @@ ssm_table <- function(.ssm_object, caption = NULL,
no = "Profile"
)

# Add delta symbol to column names if results are contrasts
if (.ssm_object$details$contrast) {
colnames(table_df) <- c(
"Contrast",
"&Delta; Elevation",
"&Delta; X Value",
"&Delta; Y Value",
"&Delta; Amplitude",
"&Delta; Displacement",
"&Delta; Fit"
)
}

# Drop the x and y columns if requested
if (drop_xy) {
table_df <- table_df[, -c(3, 4)]
Expand Down
33 changes: 31 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ devtools::install_github("jmgirard/circumplex")

## Usage

### Example 1

```{r analysis1}
data("jz2017")
results <- ssm_analyze(
Expand All @@ -54,11 +56,11 @@ summary(results)
```

``` r
ssm_table(results, xy = FALSE)
ssm_table(results, drop_xy = TRUE)
```

```{r table1, echo = FALSE, results = "asis"}
ssm_table(results, xy = FALSE, render = FALSE) %>%
ssm_table(results, drop_xy = TRUE, render = FALSE) %>%
knitr::kable(caption = circumplex:::dcaption(results)) %>%
kableExtra::kable_styling(full_width = TRUE, font_size = 12)
```
Expand All @@ -67,6 +69,33 @@ ssm_table(results, xy = FALSE, render = FALSE) %>%
ssm_plot(results)
```

### Example 2

```{r analysis2}
results2 <- ssm_analyze(
data = jz2017,
scales = PANO(),
angles = octants(),
grouping = "Gender",
contrast = TRUE
)
summary(results2)
```

``` r
ssm_table(results2, drop_xy = TRUE)
```

```{r table2, echo = FALSE, results = "asis"}
ssm_table(results2, drop_xy = TRUE, render = FALSE) %>%
knitr::kable(caption = circumplex:::dcaption(results)) %>%
kableExtra::kable_styling(full_width = TRUE, font_size = 12)
```

```{r plot2}
ssm_plot(results2)
```

## Code of Conduct
Please note that the 'circumplex' project is released with a
[Contributor Code of Conduct](https://circumplex.jmgirard.com/CODE_OF_CONDUCT.html).
Expand Down
165 changes: 153 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,28 @@ devtools::install_github("jmgirard/circumplex")

## Usage

### Example 1

``` r
data("jz2017")
results <- ssm_analyze(
.data = jz2017,
scales = c(PA, BC, DE, FG, HI, JK, LM, NO),
data = jz2017,
scales = c("PA", "BC", "DE", "FG", "HI", "JK", "LM", "NO"),
angles = c(90, 135, 180, 225, 270, 315, 360, 45),
measures = c(NARPD, ASPD),
measures = c("NARPD", "ASPD"),
measures_labels = c("Narcissistic PD", "Antisocial PD")
)
summary(results)
#> Call:
#> ssm_analyze(.data = jz2017, scales = c(PA, BC, DE, FG, HI, JK,
#> LM, NO), angles = c(90, 135, 180, 225, 270, 315, 360, 45),
#> measures = c(NARPD, ASPD), measures_labels = c("Narcissistic PD",
#> "Antisocial PD"))
#>
#> Statistical Basis: Correlation Scores
#> Bootstrap Resamples: 2000
#> Confidence Level: 0.95
#> Listwise Deletion: TRUE
#> Scale Displacements: 90 135 180 225 270 315 360 45
#>
#> Profile [Narcissistic PD]:
#>
#> # Profile [Narcissistic PD]:
#>
#> Estimate Lower CI Upper CI
#> Elevation 0.202 0.169 0.238
#> X-Value -0.062 -0.094 -0.029
Expand All @@ -69,7 +68,9 @@ summary(results)
#> Displacement 108.967 98.633 118.537
#> Model Fit 0.957
#>
#> Profile [Antisocial PD]:
#>
#> # Profile [Antisocial PD]:
#>
#> Estimate Lower CI Upper CI
#> Elevation 0.124 0.087 0.158
#> X-Value -0.099 -0.133 -0.064
Expand All @@ -80,10 +81,10 @@ summary(results)
```

``` r
ssm_table(results, xy = FALSE)
ssm_table(results, drop_xy = TRUE)
```

<table class="table" style="font-size: 12px; margin-left: auto; margin-right: auto;">
<table class="table" style="font-size: 12px; color: black; margin-left: auto; margin-right: auto;">
<caption style="font-size: initial !important;">
Correlation-based Structural Summary Statistics with 95% CIs
</caption>
Expand Down Expand Up @@ -150,6 +151,146 @@ ssm_plot(results)

![](man/figures/README-plot-1.png)<!-- -->

### Example 2

``` r
results2 <- ssm_analyze(
data = jz2017,
scales = PANO(),
angles = octants(),
grouping = "Gender",
contrast = TRUE
)
summary(results2)
#>
#> Statistical Basis: Mean Scores
#> Bootstrap Resamples: 2000
#> Confidence Level: 0.95
#> Listwise Deletion: TRUE
#> Scale Displacements: 90 135 180 225 270 315 360 45
#>
#>
#> # Profile [Female]:
#>
#> Estimate Lower CI Upper CI
#> Elevation 0.946 0.909 0.984
#> X-Value 0.459 0.421 0.498
#> Y-Value -0.310 -0.355 -0.267
#> Amplitude 0.554 0.511 0.598
#> Displacement 325.963 322.182 330.063
#> Model Fit 0.889
#>
#>
#> # Profile [Male]:
#>
#> Estimate Lower CI Upper CI
#> Elevation 0.884 0.843 0.923
#> X-Value 0.227 0.192 0.262
#> Y-Value -0.186 -0.225 -0.148
#> Amplitude 0.294 0.257 0.329
#> Displacement 320.685 313.462 327.843
#> Model Fit 0.824
#>
#>
#> # Contrast [Male - Female]:
#>
#> Estimate Lower CI Upper CI
#> Δ Elevation -0.062 -0.118 -0.005
#> Δ X-Value -0.232 -0.283 -0.181
#> Δ Y-Value 0.124 0.067 0.183
#> Δ Amplitude -0.261 -0.318 -0.202
#> Δ Displacement -5.278 -13.353 2.755
#> Δ Model Fit -0.066
```

``` r
ssm_table(results2, drop_xy = TRUE)
```

<table class="table" style="font-size: 12px; color: black; margin-left: auto; margin-right: auto;">
<caption style="font-size: initial !important;">
Correlation-based Structural Summary Statistics with 95% CIs
</caption>
<thead>
<tr>
<th style="text-align:left;">
Contrast
</th>
<th style="text-align:left;">
Elevation
</th>
<th style="text-align:left;">
Amplitude
</th>
<th style="text-align:left;">
Displacement
</th>
<th style="text-align:left;">
Fit
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">
Female
</td>
<td style="text-align:left;">
0.95 (0.91, 0.98)
</td>
<td style="text-align:left;">
0.55 (0.51, 0.60)
</td>
<td style="text-align:left;">
326.0 (322.2, 330.1)
</td>
<td style="text-align:left;">
0.889
</td>
</tr>
<tr>
<td style="text-align:left;">
Male
</td>
<td style="text-align:left;">
0.88 (0.84, 0.92)
</td>
<td style="text-align:left;">
0.29 (0.26, 0.33)
</td>
<td style="text-align:left;">
320.7 (313.5, 327.8)
</td>
<td style="text-align:left;">
0.824
</td>
</tr>
<tr>
<td style="text-align:left;">
Male - Female
</td>
<td style="text-align:left;">
-0.06 (-0.12, -0.01)
</td>
<td style="text-align:left;">
-0.26 (-0.32, -0.20)
</td>
<td style="text-align:left;">
-5.3 (-13.4, 2.8)
</td>
<td style="text-align:left;">
-0.066
</td>
</tr>
</tbody>
</table>

``` r
ssm_plot(results2)
```

![](man/figures/README-plot2-1.png)<!-- -->

## Code of Conduct

Please note that the ‘circumplex’ project is released with a
Expand Down
4 changes: 2 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ reference:
contents:
- ipsatize
- score
- standardize
- norm_standardize
- title: Primary SSM Functions
desc: Functions for implementing the Structural Summary Method
contents:
Expand All @@ -42,7 +42,6 @@ reference:
- title: Secondary SSM Functions
desc: Functions for customizing SSM results
contents:
- ssm_append
- ssm_plot_circle
- ssm_plot_contrast
- ssm_plot_scores
Expand All @@ -53,6 +52,7 @@ reference:
- octants
- poles
- quadrants
- PANO
- title: Example Data
contents:
- aw2009
Expand Down
Loading

0 comments on commit f9e9705

Please sign in to comment.