Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inverse of a predictor in a linear model - R

I have this linear model in r:

a<-lm(NA. ~ PC +SPCI,data=DSET)

Now, what I want to run is a linear model with the inverse of SPCI, which is (1/SCPCI).

I guessed that the sintaxis was : a<-lm(NA. ~ PC +(1/SPCI),data=DSET). But it doesn`t make sense for that code because (1/SPCI) is completely ignored , it's just adding 0.

So, What should I do to run the inverse of a predictor in a linear model in R.

like image 240
CreamStat Avatar asked Jan 12 '23 11:01

CreamStat


1 Answers

I think you need to to use the notation of I in your formula. See ?formula for details.

From help of formula: the function I() can be used to bracket those portions of a model formula where the operators are used in their arithmetic sense. For example, in the formula y ~ a + I(b+c), the term b+c is to be interpreted as the sum of b and c

Example:

a<-lm(NA. ~ PC + I(1/SPCI), data=DSET)
like image 190
Marc in the box Avatar answered Jan 16 '23 17:01

Marc in the box