简体   繁体   English

如何在 R 中为线性回归模型引入这两个数据集?

[英]How can I induce these two datasets for a linear regression model in R?

For linear regression y_i=ax_i+epsilon.对于线性回归,y_i=ax_i+epsilon。 If I want to let x_i from the dataset Air.Flow (represents the rate of operation of the plant) and y_i from stack.loss (the dependent variable) in R.如果我想让 x_i 来自数据集Air.Flow (代表工厂的运行率)和 y_i 来自stack.loss (因变量)。

How can I input these two datasets in R?如何在 R 中输入这两个数据集?

For example, the code例如,代码

 library(BAS)
 data(bodyfat)
 summary(bodyfat)

is to use data set bodyfat from the library BAS .是使用来自库BAS数据集bodyfat Is there any library for Air.Flow and stack.loss ?是否有用于Air.Flowstack.loss库?

The linear regression is as follows:线性回归如下:

在此处输入图片说明

You need to get the data first:您需要先获取数据:

df = datasets::stackloss
lm(df$Air.Flow ~ df$stack.loss)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM