A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://rishvish.github.io/DImodelsVis/reference/simplex_path.html below:

Visualising the change in a response variable between two points in the simplex space — simplex_path • DImodelsVis

library(DImodels)
data(sim2)

# Fit model
mod <- DI(y = "response", prop = 3:6, DImodel = "AV", data = sim2)
#> Fitted model: Average interactions 'AV' DImodel

# Create plot
# Move from p3 monoculture to p4 monoculture
simplex_path(model = mod,
             starts = data.frame(p1 = 0, p2 = 0, p3 = 1, p4 = 0),
             ends = data.frame(p1 = 0, p2 = 0, p3 = 0, p4 = 1))
#>  Finished data preparation.
#>  Created plot.


# Move from each 70% dominant mixtures to p1 monoculture
simplex_path(model = mod,
             starts = sim2[c(1, 5, 9, 13), 3:6],
             ends = data.frame(p1 = 1, p2 = 0, p3 = 0, p4 = 0))
#>  Finished data preparation.
#>  Created plot.


# Move from centroid community to each monoculture
simplex_path(model = mod,
             starts = sim2[c(18),],
             ends = sim2[c(48, 52, 56, 60), ])
#>  Finished data preparation.
#>  Created plot.


# Show change across multiple points simultaneously and show confidence bands
# using `se = TRUE`
simplex_path(model = mod,
             starts = sim2[c(1, 17, 22), ],
             ends = sim2[c(5, 14, 17), ], se = TRUE)
#>  Finished data preparation.
#>  Created plot.


# Change pie_colours using `pie_colours` and show pie-glyph at different
# points along the curve using `pie_positions`
simplex_path(model = mod,
             starts = sim2[c(1, 17, 22), ],
             ends = sim2[c(5, 14, 17), ], se = TRUE,
             pie_positions = c(0, 0.25, 0.5, 0.75, 1),
             pie_colours = c("steelblue1", "steelblue4", "orange1", "orange4"))
#>  Finished data preparation.
#>  Created plot.


# Facet based on existing variables
# \donttest{
simplex_path(model = mod,
             starts = sim2[c(1, 17, 22), ],
             ends = sim2[c(5, 14, 17), ], se = TRUE, facet_var = "block",
             pie_colours = c("steelblue1", "steelblue4", "orange1", "orange4"))
#>  Finished data preparation.
#>  Created plot.


# Add additional variables and create a separate plot for each
simplex_path(model = mod,
             starts = sim2[c(1, 17, 22), 3:6],
             ends = sim2[c(5, 14, 17), 3:6], se = TRUE,
             pie_colours = c("steelblue1", "steelblue4", "orange1", "orange4"),
             add_var = list("block" = factor(c(1, 3),
                                             levels = c(1, 2, 3, 4))))
#>  Finished data preparation.
#>  Created all plots.

# }

## Specify `plot = FALSE` to not create the plot but return the prepared data
head(simplex_path(model = mod, plot = FALSE,
                  starts = sim2[c(1, 17, 22), 3:6],
                  ends = sim2[c(5, 14, 17), 3:6], se = TRUE,
                  pie_colours = c("steelblue1", "steelblue4",
                                  "orange1", "orange4"),
                  add_var = list("block" = factor(c(1, 3),
                                                  levels = c(1, 2, 3, 4)))))
#>  Finished data preparation.
#>      p1    p2  p3  p4 .InterpConst .Group block .add_str_ID    .Pred   .Lower
#> 1 0.700 0.100 0.1 0.1         0.00      1     1    block: 1 18.19429 17.45473
#> 2 0.694 0.106 0.1 0.1         0.01      1     1    block: 1 18.30217 17.56890
#> 3 0.688 0.112 0.1 0.1         0.02      1     1    block: 1 18.40775 17.68057
#> 4 0.682 0.118 0.1 0.1         0.03      1     1    block: 1 18.51103 17.78973
#> 5 0.676 0.124 0.1 0.1         0.04      1     1    block: 1 18.61200 17.89639
#> 6 0.670 0.130 0.1 0.1         0.05      1     1    block: 1 18.71068 18.00055
#>     .Upper
#> 1 18.93385
#> 2 19.03544
#> 3 19.13494
#> 4 19.23233
#> 5 19.32762
#> 6 19.42080

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4