五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

R語言對(duì)回歸模型進(jìn)行協(xié)方差分析

2021-03-02 22:31 作者:拓端tecdat  | 我要投稿

原文鏈接:http://tecdat.cn/?p=9529

?

目錄

?

怎么做測(cè)試

協(xié)方差分析

擬合線的簡(jiǎn)單圖解

模型的p值和R平方

檢查模型的假設(shè)

具有三類和II型平方和的協(xié)方差示例分析

協(xié)方差分析

擬合線的簡(jiǎn)單圖解

組合模型的p值和R平方

檢查模型的假設(shè)

怎么做測(cè)試

具有兩個(gè)類別和II型平方和的協(xié)方差示例的分析

本示例使用II型平方和 。參數(shù)估計(jì)值在R中的計(jì)算方式不同,?

?



  1. Data = read.table(textConnection(Input),header=TRUE)

?

?

?

  1. plot(x ? = Data$Temp,

  2. y ? = Data$Pulse,

  3. col = Data$Species,

  4. pch = 16,

  5. xlab = "Temperature",

  6. ylab = "Pulse")


  7. legend('bottomright',

  8. legend = levels(Data$Species),

  9. col = 1:2,

  10. cex = 1,

  11. pch = 16)

?

?

?

協(xié)方差分析

?





  1. Anova Table (Type II tests)




  2. Sum Sq Df ?F value ? ?Pr(>F)


  3. Temp ? ? ? ? 4376.1 ?1 1388.839 < 2.2e-16 ***


  4. Species ? ? ? 598.0 ?1 ?189.789 9.907e-14 ***


  5. Temp:Species ? ?4.3 ?1 ? ?1.357 ? ?0.2542




  6. ### Interaction is not significant, so the slope across groups


  7. ### is not different.






  8. model.2 = lm (Pulse ~ Temp + Species,

  9. data = Data)


  10. library(car)


  11. Anova(model.2, type="II")




  12. Anova Table (Type II tests)




  13. Sum Sq Df F value ? ?Pr(>F)


  14. Temp ? ? ?4376.1 ?1 ?1371.4 < 2.2e-16 ***


  15. Species ? ?598.0 ?1 ? 187.4 6.272e-14 ***




  16. ### The category variable (Species) is significant,


  17. ### so the intercepts among groups are different






  18. Coefficients:


  19. Estimate Std. Error t value Pr(>|t|)


  20. (Intercept) ?-7.21091 ? ?2.55094 ?-2.827 ?0.00858 **


  21. Temp ? ? ? ? ?3.60275 ? ?0.09729 ?37.032 ?< 2e-16 ***


  22. Speciesniv ?-10.06529 ? ?0.73526 -13.689 6.27e-14 ***





  23. ### ? but the calculated results will be identical.


  24. ### The slope estimate is the same.


  25. ### The intercept for species 1 (ex) is (intercept).


  26. ### The intercept for species 2 (niv) is (intercept) + Speciesniv.


  27. ### This is determined from the contrast coding of the Species


  28. ### variable shown below, and the fact that Speciesniv is shown in


  29. ### coefficient table above.






  30. niv


  31. ex ? ?0


  32. niv ? 1

?

?

擬合線的簡(jiǎn)單圖解

?


  1. plot(x ? = Data$Temp,

  2. y ? = Data$Pulse,

  3. col = Data$Species,

  4. pch = 16,

  5. xlab = "Temperature",

  6. ylab = "Pulse")

?

模型的p值和R平方

?

?



  1. Multiple R-squared: ?0.9896, ?Adjusted R-squared: ?0.9888


  2. F-statistic: ?1331 on 2 and 28 DF, ?p-value: < 2.2e-16

?

?

檢查模型的假設(shè)

?

?

?

線性模型中殘差的直方圖。這些殘差的分布應(yīng)近似正態(tài)。

?

?

?

?

殘差與預(yù)測(cè)值的關(guān)系圖。殘差應(yīng)無偏且均等。?

?

?

  1. ### additional model checking plots with: plot(model.2)

  2. ### alternative: library(FSA); residPlot(model.2)

?

具有三類和II型平方和的協(xié)方差示例分析

本示例使用II型平方和,并考慮具有三個(gè)組的情況。?

  1. ### --------------------------------------------------------------

  2. ### Analysis of covariance, hypothetical data

  3. ### --------------------------------------------------------------



  4. Data = read.table(textConnection(Input),header=TRUE)

?

?

?

?

  1. plot(x ? = Data$Temp,

  2. y ? = Data$Pulse,

  3. col = Data$Species,

  4. pch = 16,

  5. xlab = "Temperature",

  6. ylab = "Pulse")


  7. legend('bottomright',

  8. legend = levels(Data$Species),

  9. col = 1:3,

  10. cex = 1,

  11. pch = 16)

?

?

?

協(xié)方差分析

?

  1. options(contrasts = c("contr.treatment", "contr.poly"))


  2. ### These are the default contrasts in R



  3. Anova(model.1, type="II")




  4. Sum Sq Df ? F value Pr(>F)


  5. Temp ? ? ? ? 7026.0 ?1 2452.4187 <2e-16 ***


  6. Species ? ? ?7835.7 ?2 1367.5377 <2e-16 ***


  7. Temp:Species ? ?5.2 ?2 ? ?0.9126 0.4093




  8. ### Interaction is not significant, so the slope among groups


  9. ### is not different.








  10. Anova(model.2, type="II")




  11. Sum Sq Df F value ? ?Pr(>F)


  12. Temp ? ? ?7026.0 ?1 ?2462.2 < 2.2e-16 ***


  13. Species ? 7835.7 ?2 ?1373.0 < 2.2e-16 ***


  14. Residuals ?125.6 44




  15. ### The category variable (Species) is significant,


  16. ### so the intercepts among groups are different






  17. summary(model.2)




  18. Coefficients:


  19. Estimate Std. Error t value Pr(>|t|)


  20. (Intercept) ?-6.35729 ? ?1.90713 ?-3.333 ?0.00175 **


  21. Temp ? ? ? ? ?3.56961 ? ?0.07194 ?49.621 ?< 2e-16 ***


  22. Speciesfake ?19.81429 ? ?0.66333 ?29.871 ?< 2e-16 ***


  23. Speciesniv ?-10.18571 ? ?0.66333 -15.355 ?< 2e-16 ***




  24. ### The slope estimate is the Temp coefficient.


  25. ### The intercept for species 1 (ex) is (intercept).


  26. ### The intercept for species 2 (fake) is (intercept) + Speciesfake.


  27. ### The intercept for species 3 (niv) is (intercept) + Speciesniv.


  28. ### This is determined from the contrast coding of the Species


  29. ### variable shown below.






  30. contrasts(Data$Species)




  31. fake niv


  32. ex ? ? ?0 ? 0


  33. fake ? ?1 ? 0


  34. niv ? ? 0 ? 1

?

擬合線的簡(jiǎn)單圖解

?

?

?

組合模型的p值和R平方

?

?




  1. Multiple R-squared: ?0.9919, ?Adjusted R-squared: ?0.9913


  2. F-statistic: ?1791 on 3 and 44 DF, ?p-value: < 2.2e-16

?

?

?

檢查模型的假設(shè)

  1. hist(residuals(model.2),

  2. col="darkgray")

?

?

線性模型中殘差的直方圖。這些殘差的分布應(yīng)近似正態(tài)。

?

?

  1. plot(fitted(model.2),

  2. residuals(model.2))

?

?

殘差與預(yù)測(cè)值的關(guān)系圖。殘差應(yīng)無偏且均等。?

?

?



  1. ### additional model checking plots with: plot(model.2)

  2. ### alternative: library(FSA); residPlot(model.2)



?

拓端研究室?拓端數(shù)據(jù)?編輯

拓端(http://tecdat.cn )創(chuàng)立于2016年,自成立以來,就定位為提供專業(yè)的統(tǒng)計(jì)分析與數(shù)據(jù)挖掘服務(wù)的提供商,致力于充分挖掘數(shù)據(jù)的價(jià)值,為客戶定制個(gè)性化的數(shù)據(jù)方案與報(bào)告等。
歡迎關(guān)注微信公眾號(hào):拓端數(shù)據(jù)部落、拓端數(shù)據(jù)。? ? ? ? ?


R語言對(duì)回歸模型進(jìn)行協(xié)方差分析的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
邢台县| 平遥县| 陇川县| 太康县| 钟祥市| 宜宾县| 兴山县| 连城县| 旅游| 青海省| 海原县| 乐至县| 淮阳县| 金昌市| 随州市| 麦盖提县| 大埔区| 英山县| 石阡县| 安达市| 朝阳县| 汉中市| 淮南市| 北安市| 贵溪市| 涟水县| 广灵县| 永嘉县| 台东县| 鹰潭市| 宁阳县| 长武县| 凌海市| 开平市| 张家口市| 云梦县| 厦门市| 西乌珠穆沁旗| 如东县| 鹤岗市| 南郑县|