能不能给个关于协方差的用R软件编写的案例,

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 18:13:43
能不能给个关于协方差的用R软件编写的案例,

能不能给个关于协方差的用R软件编写的案例,
能不能给个关于协方差的用R软件编写的案例,

能不能给个关于协方差的用R软件编写的案例,
ancova()提供了协方差分析计算,调用方式是:
ancova(formula,data.in=sys.parent(),x,groups)
实例:为研究ABC三种饲料对猪的催肥效果,每种饲料养8头猪一段时间,测得每头猪的初始重量(X)和增重(Y),分析三种饲料对猪的催肥效果是否相同?
> #建立数据集
> feed Weight_Initial Weight_Increment data_feed anova(lm(Weight_Increment~Weight_Initial+feed),data=data_feed)
Analysis of Variance Table
Response:Weight_Increment
Df Sum Sq Mean Sq F value Pr(>F)
Weight_Initial 1 1621.12 1621.12 142.445 1.496e-10 ***
feed 2 707.22 353.61 31.071 7.322e-07 ***
Residuals 20 227.61 11.38
---
Signif.codes:0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> anova(lm(Weight_Increment~Weight_Initial*feed),data=data_feed)
Analysis of Variance Table
Response:Weight_Increment
Df Sum Sq Mean Sq F value Pr(>F)
Weight_Initial 1 1621.12 1621.12 162.4949 1.897e-10 ***
feed 2 707.22 353.61 35.4443 5.726e-07 ***
Weight_Initial:feed 2 48.04 24.02 2.4076 0.1184
Residuals 18 179.58 9.98
---
Signif.codes:0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1