Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

logbtcf

Constructs the correction-factor used when back-transforming log-transformed values.


Description

Constructs the correction-factor used when back-transforming log-transformed values according to Sprugel (1983). Sprugel's main formula – exp((syx^2)/2) – is used when syx is estimated for natural log transformed data. A correction for any base is obtained by multiplying the syx term by log_e(base) to give exp(((log_e(base)*syx)^2)/2). This more general formula is implemented here (if, of course, the base is exp(1) then the general formula reduces to the original specific formula).

Usage

logbtcf(obj, base = exp(1))

Arguments

obj

An object from lm.

base

A single numeric that indicates the base of the logarithm used.

Value

A numeric value that is the correction factor according to Sprugel (1983).

Author(s)

Derek H. Ogle, derek@derekogle.com

References

Sprugel, D.G. 1983. Correcting for bias in log-transformed allometric equations. Ecology 64:209-210.

Examples

# toy data
df <- data.frame(y=rlnorm(10),x=rlnorm(10))
df$logey <- log(df$y)
df$log10y <- log10(df$y)
df$logex <- log(df$x)
df$log10x <- log10(df$x)

# model and predictions on loge scale
lme <- lm(logey~logex,data=df)
( ploge <- predict(lme,data.frame(logex=log(10))) )
( pe <- exp(ploge) )
( cfe <- logbtcf(lme) )
( cpe <- cfe*pe )

# model and predictions on log10 scale
lm10 <- lm(log10y~log10x,data=df)
plog10 <- predict(lm10,data.frame(log10x=log10(10)))
p10 <- 10^(plog10)
( cf10 <- logbtcf(lm10,10) )
( cp10 <- cf10*p10 )

# cfe and cf10, cpe and cp10 should be equal
all.equal(cfe,cf10)
all.equal(cpe,cp10)

FSA

Simple Fisheries Stock Assessment Methods

v0.8.32
GPL (>= 2)
Authors
Derek Ogle [aut, cre] (<https://orcid.org/0000-0002-0370-9299>), Powell Wheeler [aut], Alexis Dinno [aut] (Provided base functionality of dunnTest())
Initial release
2021-1-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.