Linear regression equation R -


when run linear regression in r, under variable r save actual regression equation, mean r save equation in form:

y=b0 +b1x1 + b2x2 + b3x3 etc

i asking because call upon equation later, or need create new variable , let equal above equation , @ same time include beta values such (for example) in r

z=0.1 + 0.2x1 +0.3x2 +0.4x3 etc.

i understand 1 can use predict function not sure if looking exactly

if want coefficients, use summary() on lm.

to see model terms , estimates, ses, etc...

my_lm <- lm(sepal.length~sepal.width+petal.width+petal.length,iris) coeffients <- summary(my_lm)$coefficients coeffients                estimate std. error   t value     pr(>|t|) (intercept)   1.8559975 0.25077711  7.400984 9.853855e-12 sepal.width   0.6508372 0.06664739  9.765380 1.199846e-17 petal.width  -0.5564827 0.12754795 -4.362929 2.412876e-05 petal.length  0.7091320 0.05671929 12.502483 7.656980e-25 

you can use like. lastly, formula() return called in lm()

formula(my_lm) sepal.length ~ sepal.width + petal.width + petal.length 

if don't want use predict(), can use object instead.

my_coef<-(coeffients[,1]) my_coef  (intercept)  sepal.width  petal.width petal.length     1.8559975    0.6508372   -0.5564827    0.7091320  

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -