Learn R Programming

hyper.gam (version 0.2.1)

integrandSurface: Integrand Surface(s) of Sign-Adjusted Quantile Indices hyper_gam

Description

An interactive htmlwidgets of the perspective plot for hyper_gam model(s) using package plotly.

Usage

integrandSurface(
  ...,
  sign_adjusted = TRUE,
  newdata = data,
  proj_xy = TRUE,
  proj_xz = TRUE,
  proj_beta = FALSE,
  n = 501L,
  newid = seq_len(min(3L, .row_names_info(newdata, type = 2L))),
  qlim = range(X[is.finite(X)], newX[is.finite(newX)]),
  beta_col = "purple",
  surface_col = c("white", "lightgreen")
)

Value

Function integrandSurface() returns a pretty htmlwidgets created by R package plotly

to showcase the perspective plot of the estimated sign-adjusted integrand surface \(\hat{S}(p,q)\).

If a set of training/test subjects is selected (via parameter newid), then

  • the estimated sign-adjusted line integrand curve \(\hat{S}\big(p, Q_i(p)\big)\) of subject \(i\) is displayed on the surface \(\hat{S}(p,q)\);

  • the quantile curve \(Q_i(p)\) is projected on the \((p,q)\)-plain of the 3-dimensional \((p,q,s)\) cube, if proj_xy=TRUE (default);

  • the user-specified \(\tilde{p}\) is marked on the \((p,q)\)-plain of the 3D cube, if proj_xy=TRUE (default);

  • \(\hat{S}\big(p, Q_i(p)\big)\) is projected on the \((p,s)\)-plain of the 3-dimensional \((p,q,s)\) cube, if one and only one hyper_gam model is provided in in put argument ... and proj_xz=TRUE (default);

  • the estimated linear functional coefficient \(\hat{\beta}(p)\) is shown on the \((p,s)\)-plain of the 3D cube, if one and only one linear hyper_gam model is provided in input argument ... and proj_beta=TRUE (default).

Arguments

...

one or more hyper_gam models based on a same data set.

sign_adjusted

logical scalar

newdata

see function predict.hyper_gam().

proj_xy

logical scalar, whether to show the projection of \(\hat{S}\big(p, Q_i(p)\big)\) (see sections Details and Value) to the \((p,q)\)-plain, default TRUE

proj_xz

logical scalar, whether to show the projection of \(\hat{S}\big(p, Q_i(p)\big)\) to the \((p,s)\)-plain, default TRUE

proj_beta

logical scalar, whether to show \(\hat{\beta}(p)\) on the \((p,s)\)-plain when applicable, default TRUE

n

integer scalar, fineness of visualization, default 501L. See parameter n.grid of function vis.gam.

newid

integer scalar or vector, row indices of newdata to be visualized. Default 1:2, i.e., the first two test subjects. Use newid = NULL to disable visualization of newdata.

qlim

length-2 double vector, range on \(q\)-axis. Default is the range of \(X\) and \(X^{\text{new}}\) combined.

beta_col

character scalar, color of \(\hat{\beta(p)}\)

surface_col

length-2 character vector, color of the integrand surface(s), for lowest and highest surface values

Integrand Surface

The estimated integrand surface of quantile indices and non-linear quantile indices, defined on \(p\in[0,1]\) and \(q\in\text{range}\big(Q_i(p)\big)\) for all training subjects \(i=1,\cdots,n\), is $$ \hat{S}_0(p,q) = \begin{cases} \hat{\beta}(p)\cdot q & \text{for QI}\\ \hat{F}(p,q) & \text{for nlQI} \end{cases} $$

Sign-Adjustment

Ideally, we would wish that, in the training set, the estimated linear and/or non-linear quantile indices $$ \widehat{\text{QI}}_i = \displaystyle\int_0^1 \hat{S}_0\big(p, Q_i(p)\big)dp $$ be positively correlated with a more intuitive quantity, e.g., quantiles \(Q_i(\tilde{p})\) at a user-specified \(\tilde{p}\), for the interpretation of downstream analysis, Therefore, we define the sign-adjustment term $$ \hat{c} = \text{sign}\left(\text{corr}\left(Q_i(\tilde{p}), \widehat{\text{QI}}_i\right)\right),\quad i =1,\cdots,n $$ as the sign of the correlation between the estimated quantile index \(\widehat{\text{QI}}_i\) and the quantile \(Q_i(\tilde{p})\), for training subjects \(i=1,\cdots,n\).

The estimated sign-adjusted integrand surface is \(\hat{S}(p,q) = \hat{c} \cdot \hat{S}_0(p,q)\).

The estimated sign-adjusted quantile indices \(\int_0^1 \hat{S}\big(p, Q_i(p)\big)dp\) are positively correlated with subject-specific sample medians (default \(\tilde{p} = .5\)) in the training set.