pow: Raise a numeric vector to a given power

View source: R/pow.R

powR Documentation

Raise a numeric vector to a given power

Description

This function returns a numeric vector raised to a given power.

Usage

pow(x, y)

Arguments

x

A numeric vector.

y

A numeric value for the power x should be raised to.

Details

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

Value

a numeric vector containing x to the power of y.

Author(s)

Sollano Rabelo Braga sollanorb@gmail.com

Examples

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

# Raise a numeric vector to the power of 2:
pow(iris$Petal.Length, 2)

# Fit a model that contains the dbh squared, without the need to create a new variable:
lm(log(TH) ~ DBH + pow(DBH,2), exfm15 )
# or 
lm_table(exfm15, log(TH) ~ DBH + pow(DBH,2) )


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