我是R语言的新手。我想知道如何从满足回归的所有四个假设的多重线性回归模型进行模拟。
好的谢谢。
假设我要基于此数据集模拟数据:
y<-c(18.73,14.52,17.43,14.54,13.44,24.39,13.34,22.71,12.68,19.32,30.16,27.09,25.40,26.05,33.49,35.62,26.07,36.78,34.95,43.67)
x1<-c(610,950,720,840,980,530,680,540,890,730,670,770,880,1000,760,590,910,650,810,500)
x2<-c(1,1,3,2,1,1,3,3,2,2,1,3,3,2,2,2,3,3,1,2)
fit<-lm(y~x1+x2)
summary(fit)
然后我得到输出:
Call:
lm(formula = y ~ x1 + x2)
Residuals:
Min 1Q Median 3Q Max
-13.2805 -7.5169 -0.9231 7.2556 12.8209
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 42.85352 11.33229 3.782 0.00149 **
x1 -0.02534 0.01293 -1.960 0.06662 .
x2 0.33188 2.41657 0.137 0.89238
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 8.679 on 17 degrees of freedom
Multiple R-squared: 0.1869, Adjusted R-squared: 0.09127
F-statistic: 1.954 on 2 and 17 DF, p-value: 0.1722
我的问题是如何模拟模仿上面原始数据的新数据?
rnorm()
而不是11:30
),但是无论我增加多少误差(西格玛),估计的标准误差都大致相似。