Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use division in lm

Tags:

r

lm

I would like to use lm to predict y by a/b (the quotient of a by b) when I do lm(y~a/b) I get a and b interactions, how can I do ?

like image 323
statquant Avatar asked Feb 05 '14 20:02

statquant


People also ask

What does lm Linearregression () do?

The lm() function is used to fit linear models to data frames in the R Language. It can be used to carry out regression, single stratum analysis of variance, and analysis of covariance to predict the value corresponding to data that is not in the data frame.

What method does lm use in R?

Linear Regression Example in R using lm() Function. Summary: R linear regression uses the lm() function to create a regression model given some formula, in the form of Y~X+X2. To look at the model, you use the summary() function. To analyze the residuals, you pull out the $resid variable from your new model.

How do you add an interaction variable in R?

A two step process can be followed to create an interaction variable in R. First, the input variables must be centered to mitigate multicollinearity. Second, these variables must be multiplied to create the interaction variable.


1 Answers

lm(y~I(a/b))

This is covered in ?formula.

like image 170
Sycorax Avatar answered Oct 07 '22 21:10

Sycorax