0

I want to adjust a function like this:

fit4 = lm(mut ~ ent + score + wt + I(ent^2) + I(score^2) +I(wt^2))

when I summary(fit4) I get:

Coefficients:                 
                          Estimate   Std. Error t value Pr(>|t|)   
(Intercept)              -1.779381   0.086256 -20.629   <2e-16   
ent                       2.724036   0.072543  37.550   <2e-16   
score                     0.473230   0.009450  50.077   <2e-16   
wt                       -0.464216   0.031141 -14.907   <2e-16
I(ent^2)                 -0.473427   0.018814 -25.164   <2e-16
I(score^2)                0.030187   0.004851   6.222    5e-10
I(wt^2)                   0.043386   0.004609   9.413   <2e-16
---

Now I would like to obtain the same, but doing the root square error of the above function: sqrt(ent + score + wt + I(ent^2) + I(score^2) +I(wt^2)), but when I simply add "sqrt()", the summary returns something like:

                    Estimate 
(Intercept)          1.066025                                                                                                                    
I(sqrt(ent + score + wt + I(ent^2) + I(score^2) + I(wt^2))) -0.24028    

(and same for Std.Error, t-value, etc.)

How can I add "root squared" or "log" and still obtain the values for each element of the function?

PGreen
  • 3,239
  • 3
  • 24
  • 29

1 Answers1

2

You have to apply the function to all of them induvidually. So

fit4 = lm(mut ~ log(ent) + log(score) + log(wt) + 
                log(I(ent^2)) + log(I(score^2)) +log(I(wt^2)))

will do the desired

Reason:

log(ent + score + wt + I(ent^2) + I(score^2) +I(wt^2))

is interpreted as a single regressor. So to r it is like lm(mut~x) where x=log(...) instead of

x=log(ent) + ... + log(I(wt^2))

Rentrop
  • 20,979
  • 10
  • 72
  • 100
  • Although matematically speaking it's not the same, right? sqrt(a+b+c) isn't sqrt(a)+sqrt(b)+sqrt(c). Later I thought that doing y^2 ~ a+b+c would be equivalent to y ~ sqrt(a+b+c), isn't it? Thanks – PGreen Feb 17 '14 at 16:25
  • `sqrt(a+b+c)` is NOT! `sqrt(a)+sqrt(b)+sqrt(c)` thats right. (sqrt(2+2)=2 != 1.4+1.4) `y^2~a+b+c` is also not equivalent (in the mathematical sence of equivalent) to `y~sqrt(a+b+c)` because `sqrt` always has 2 solutins plus and minus. Eg y=2 and y=-2 are solutions of y=sqrt(2+2). But taking y^2 is ok in most cases. – Rentrop Feb 17 '14 at 17:03
  • Thanks @Floo0. Therefore, is there a way to do sqrt(a+b+c) and not being interpreted as a single regressor? – PGreen Feb 17 '14 at 17:07