test<-lm(spreadsheet[,1]~spreadsheet[,2])
test<-test[1][[1]]
> test
(Intercept) spreadsheet[, 2]
359.6182526432944 -2.475447990866698
how to write the coefficients of a regression in order to form an equation? So that it is possible to isolate "x". Expected output:
K= 359.6182526432944 -2.475447990866698 *x
x= -(17249403*K-6203200166)/42700000
I tried using expression function but it didn't work:
> eq<- expression(test[1][[1]]*x)
> eq
expression(test[1][[1]] * x)
You can access the coefficients of your linear model object like this
b <- test$coefficients[1] ### intercept
k <- test$coefficients[2] ### slope
so
eq <- expression(b + k*x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.