get_fderiv: Calculate First Derivative and Confidence Intervals for GAM...

View source: R/get-pstar.R

get_fderivR Documentation

Calculate First Derivative and Confidence Intervals for GAM Smooth Terms

Description

This function calculates the first derivatives and confidence intervals for specified smooth terms in a generalized additive model (GAM) using central difference approximations. It provides point estimates and confidence intervals for the derivatives of the specified terms.

Usage

get_fderiv(
  gam_object,
  newdata,
  terms,
  term_columns,
  x,
  h = 0.005,
  nsim,
  level = 0.95
)

Arguments

gam_object

A fitted GAM model.

newdata

A data frame containing the values of predictor variables to calculate the derivative.

terms

A character vector specifying the smooth terms for which derivatives are calculated.

term_columns

A character vector specifying the columns in 'newdata' that correspond to the terms specified in 'terms'.

x

Name of the predictor variable with respect to which you want to calculate the derivatives.

h

Step size for the central difference approximation (default = 0.005)

nsim

The number of simulations used to estimate confidence intervals.

level

Confidence level for the intervals (default is 0.95).

Value

A tibble with the following columns:

  • smooth: Name of the smooth term.

  • newdata: Values of the corresponding term in 'newdata'.

  • derivative: Point estimate of the derivative.

  • se: Standard error of the estimate.

  • crit: Critical value for the confidence interval.

  • lower: Lower bound of the confidence interval.

  • upper: Upper bound of the confidence interval.


pbs-assess/gfsynopsis documentation built on March 26, 2024, 7:30 p.m.