inv: Calculate the inverse of a number

View source: R/inv.R

invR Documentation

Calculate the inverse of a number

Description

This function returns the inverse of a numeric vector.

Usage

inv(x)

Arguments

x

A numeric vector

Details

This function is manly used when fitting statistical models. If one of the variables in a model is an inverse of a vector, the lm function does not properly compute the variable, if 1/vector is inserted directly in the model, leading to the need of creating a separate variable. This function allows the user to get the inverse of a given numeric vector inside the model, without the need to create a new variable.

Value

a numeric vector containing the inverse of x.

Author(s)

Sollano Rabelo Braga sollanorb@gmail.com

Examples

library(forestmangr)
data("exfm15")
head(exfm15)

# Get the inverse of a vector
inv(iris$Petal.Length)

# Fit a model that contains the inverse of a variable, without the need to
# create a new variable for the inverse:
lm(log(TH) ~ inv(DBH), exfm15 )
# or 
lm_table(exfm15, log(TH) ~ inv(DBH) )


forestmangr documentation built on Nov. 24, 2023, 1:07 a.m.