This function returns a numeric vector raised to a given power.
pow(x, y)
Arguments
x: A numeric vector.
y: A numeric value for the power x should be raised to.
Returns
a numeric vector containing x to the power of y.
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.
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))