mulangege
从散点图上看得出x1,x2这么强的线性关系,用置信椭圆当然不合适了,
简单来说拿你的数据就是
x1<-c(0.07343761,0.38317691,0.21157726,0.67017569,0.6564431,0.11192142,0.11390119,0.71534512,1.88003671,1.00499894,0.15908102,0.26075801,0.46732103,0.51549955,0.16665948,0.3159615,0.26252144,0.00463207,0.63888138,1.04249704)
x2<-c(0.05458747,0.2754349,0.15481744,0.46916854,0.4600993,0.08281826,0.08426391,0.49886885,1.21079522,0.68494454,0.11708275,0.18979956,0.33319556,0.36589357,0.12255618,0.22866193,0.19104747,0.00347204,0.44847379,0.70852397)
df <- data.frame(x1=x1,x2=x2)
# fit linear
fit <- lm(x2~x1,data =df)
# plot
plot(x1,x2)
abline(fit)
# summary
summary(fit)
#>
#> Call:
#> lm(formula = x2 ~ x1, data = df)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.033237 -0.007251 0.001621 0.010421 0.013191
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 0.019903 0.004347 4.579 0.000233 ***
#> x1 0.651120 0.006696 97.241 < 2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 0.013 on 18 degrees of freedom
#> Multiple R-squared: 0.9981, Adjusted R-squared: 0.998
#> F-statistic: 9456 on 1 and 18 DF, p-value: < 2.2e-16
<sup>Created on 2018-10-07 by the reprex package (v0.2.1)</sup>
更多
http://r-statistics.co/Linear-Regression.html