我有一个简单的问题,我使用下面的方法运行线性模型
model1 <- lm(output ~. , data=df)
我得到一些输出,我想直接提取线性方程,而不是查看原始形式的输出
我知道扫帚包我最擅长的是
library(broom)
tidy(mod1)
我想要表单输出
output=1.1*var1 + 1.2*var2+....
最佳答案
您应该看看等式包 ( https://github.com/datalorax/equatiomatic )
下面的代码应该可以解决您的问题,我以 iris 为例
remotes::install_github("datalorax/equatiomatic")
library(equatiomatic)
mod1 <- lm(Petal.Width~.-Species, data= iris)
extract_eq(mod1, use_coefs = TRUE, wrap=TRUE,fix_signs = FALSE,ital_vars = TRUE,terms_per_line = 4)
关于python - 从具有系数的模型中提取方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57917369/