calcWprimeBy {Morphoscape}R Documentation

Compute optimally weighted adaptive landscapes by subgroup

Description

calcWprimeBy() computes the optimally weighted adaptive landscape by searching through the adaptive landscapes formed from sets of weights and performance surfaces, and finding the set of weights that yields the greatest overall (average) fitness value (Z) across subsets of a sample dataset.

Usage

calcWprimeBy(x, by, method = "chi-squared", quantile = 0.05)

## S3 method for class 'by_Wprime'
print(x, 
      digits = max(3L, getOption("digits") - 3L), ...)

## S3 method for class 'by_Wprime'
summary(object, ...)

## S3 method for class 'summary.by_Wprime'
print(x, 
      digits = max(3L, getOption("digits") - 3L), ...)

Arguments

x

for calcWprimeBy(), an all_lscps object; the output of a call to calc_all_lscps.

for print.by_Wprime(), a by_Wprime object; the output of a call to calcWprimeBy().

for print.summary.by_Wprime(), a by_Wprime object; the output of a call to summary.by_Wprime().

by

a one-sided formula containing the grouping variable on the right hand side (e.g., ~g) or a vector containing the subgrouping variable. When supplied as a formula, the grouping variable must be present in the global environment or in the new_data component in the kriged_surfaces object originally supplied to calc_all_lscps().

method

the method used to compute the optimal weights. Allowable options include "chi-square" (the default), "quantile", or "max". "chi-square" and "quantile" involve averaging across the best several sets of weights, whereas "max" uses the singular best set of weights. Abbreviations allowed. See calcGrpWprime for details.

quantile

when method is "chi-square" or "quantile", the top quantile used to determine the best sets of weights to be included in the average to compute the optimal set of weights. Should be a number between 0 and 1, with a low value indicating that only the few top sets of weights will be used. Ignored when method = "max". See calcGrpWprime for details.

digits

the number of significant digits to print.

...

passed to print.default and print.table.

object

a by_Wprime object; the output of a call to calcWprimeBy().

Details

calcWprimeBy() splits the sample data based on the by variable and then calls calcGrpWprime on each subset. The main benefit of using calcWprimeBy() is that the subgrouping variable is part of the output object and therefore can be used in plotting using plot.by_Wprime.

Value

A by_Wprime object contaning the following components:

by

the subgrouping variable supplied to by, stored as a factor and with a "by_name" attribute containing the name of the variable.

grp_Wprimes

a list of grp_Wprime objects, one for each level of the subgrouping variable.

See Also

calc_all_lscps for computing the landscapes which are to be optimized.

calcGrpWprime for finding optimal sets of weights for a single subgroup.

plot.by_Wprime for plotting the resulting adaptive landscapes.

Examples

data("warps")
data("turtles")

warps_fnc <- as_fnc_df(warps, 
                       func.names = c("hydro", "fea"))

kr_surf <- krige_surf(warps_fnc, new_data = turtles)

grid_weights <- generate_weights(n = 3, data = kr_surf)

all_lscps <- calc_all_lscps(kr_surf,
                            grid_weights = grid_weights)
                            
wprime_Ecology <- calcWprimeBy(all_lscps, by = ~Ecology)
wprime_Ecology
summary(wprime_Ecology)
plot(wprime_Ecology)

[Package Morphoscape version 1.0.2 Index]