Format of R's lm() Formula with a Transformation -


i can't quite figure out how following in 1 line:

data(attenu) x_temp = attenu$accel^(1/4) y_temp = log(attenu$dist) best_line = lm(y_temp ~ x_temp) 

since above works, thought following:

data(attenu) best_line = lm( log(attenu$dist) ~ (attenu$accel^(1/4)) ) 

but gives error:

error in terms.formula(formula, data = data) : invalid power in formula 

there's i'm missing when using transformed variables in r's formula format. why doesn't work?

you're looking function i ^ operator treated arithmetic in formula, ie.

x <- runif(1:100) y <- x + rnorm(100,0, 3) lm(log(y) ~ i(x^(1/4)) 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -