sem_z_crit: Critical Z-Values from an SEM Given a PSM Threshold

Description Usage Arguments Details Value

View source: R/sem_z_crit.R

Description

Find site-specific critical values of a single latent factor Z in a fitted SEM corresponding to a given critical PSM risk, and differences between the critical values and current values of Z, for a specified confidence level.

Usage

1
sem_z_crit(fit, data, newsites = NULL, psm_crit, level = "site", alpha)

Arguments

fit

Object of class stanfit representing a fitted PSM SEM. Parameters mu_b0, sigma_b0, b0_std, and b0_Z must be monitored.

data

The data list passed to rstan::sampling() to estimate fit, as returned by SEMPSM::stan_data().

newsites

Optional numeric vector of length N_new giving the site numbers (coded as in data) for which predictions are to be made. If newsites is not specified, the default is to use all sites in data.

psm_crit

PSM threshold in the interval (0,1).

level

Level of grouping at which to predict. Options are "site" (site-specific interannual average, the default) or "year" (include year-within-site residual variation).

alpha

Confidence level.

Details

sem_z_crit assumes fit represents a single-factor model in which I_b0_Z == 1 (that is, the site-specific fitted intercept includes an effect of Z, and that the estimate of that effect is generally positive. Currently sem_z_crit assumes sample-average precipitation conditions; this will be relaxed in the future. Critical values of Z are found by first solving for the site-specific zero of P(PSM | Z, data) = 0 for each posterior sample, and then finding the (1 - alpha/(1 - F(0)) quantile of those sampled zeros for each site that correspond to positive slopes, where F(0) is the empirical CDF of the slope w.r.t. Z evaluated at zero. This method is conservative; it guarantees that at least proportion alpha of the posterior sample of curves (i.e., those with positive slopes) will be less than psm_crit for all Z < Z_crit, but it requires that F(0) < 1 - alpha. Otherwise an error will be returned. Differences between z_crit and the alpha-th posterior quantile of estimated site-specific Z are also calculated.

Value

A list with elements

zeros

An iter x S matrix, where S is the number of sites in fit, containing posterior samples of the site-specific zeros of P(PSM | Z) - psm_crit as a function of Z.

z_crit

Numeric vector of length S containing site-specific critical Z-values.

delta_z

Numeric vector of length S containing differences between z_crit and the alpha-th posterior quantile of site-specific Z.


ebuhle/SEMPSM documentation built on Aug. 8, 2020, 4:05 a.m.