|
研究过程,有时候需要比较两条回归的斜率和截距,可以用simba包diffslope和diffic函数。参考的文献为:Nekola, J. C. and White, P. S. (1999) The distance decay of similarity in biogeography and ecology. Journal of Biogeography 26: 867-878.
#install.packages("simba") library(simba)
下面的代码全部是随机生成的数据,读者自己的数据读进来直接赋值给即x1,y1,x2,y2即可
x1 <- 1:10y1 <- 3*x1+7+rnorm(10) x2 <- 2:11y2 <- 4*x2+7.2+rnorm(10) plot(x1,y1) abline(lm(y1~x1)) points(x2,y2,col=2) abline(lm(y2~x2))
#斜率的差异比较,差异显著 diffslope(x1, y1, x2, y2)
## ## Is difference in slope significant? ## Significance is based on 1000 permutations ## ## Call: ## diffslope(x1 = x1, y1 = y1, x2 = x2, y2 = y2) ## ## Difference in Slope: -1.124 ## Significance: 0.001 ## ## Empirical upper confidence limits of r: ## 90% 95% 97.5% 99% ## 0.535 0.667 0.815 0.958
#截距的差异比较,差异不显著 diffic(x1, y1, x2, y2)
## ## Is difference in slope significant? ## Significance is based on 1000 permutations ## ## Call: ## diffic(x1 = x1, y1 = y1, x2 = x2, y2 = y2) ## ## Difference in Slope: 0.1191 ## Significance: 0.523 ## ## Empirical upper confidence limits of r: ## 90% 95% 97.5% 99% ## 4.19 5.10 6.23 6.77
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-26 09:37
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社