sasLM R package

2020/07/02

배교수님께서 일반선형모델 분석을 위해 “sasLM” R패키지를 개발하셨다.

Type I, II, III SS를 SAS PROC GLM과 동일한 방식으로 계산하여 동일한 얻을 수 있다. 이런 기능을 제공하는 유일한 R패키지인 셈이다.

library(sasLM) # install.packages('sasLM')
ANOVA(uptake ~ Plant + Type + Treatment + conc, CO2) # SAS PROC ANOVA
## $ANOVA
## Response : uptake
##                 Df Sum Sq Mean Sq F value    Pr(>F)    
## MODEL           12 7147.2  595.60   16.52 4.441e-16 ***
## RESIDUALS       71 2559.8   36.05                      
## CORRECTED TOTAL 83 9707.0                              
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Type I`
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## Plant     11 4862.2  442.02  12.260 1.555e-12 ***
## Type       0                                     
## Treatment  0                                     
## conc       1 2285.0 2284.99  63.379 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Type II`
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Plant      9  508.56   56.51  1.5673    0.1419    
## Type       0                                      
## Treatment  0                                      
## conc       1 2284.99 2284.99 63.3785 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Type III`
## CAUTION: Singularity Exists !
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Plant      9  508.56   56.51  1.5673    0.1419    
## Type       0                                      
## Treatment  0                                      
## conc       1 2284.99 2284.99 63.3785 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
GLM(uptake ~ Plant + Type + Treatment + conc, CO2) # SAS PROC GLM
## $ANOVA
## Response : uptake
##                 Df Sum Sq Mean Sq F value    Pr(>F)    
## MODEL           12 7147.2  595.60   16.52 4.441e-16 ***
## RESIDUALS       71 2559.8   36.05                      
## CORRECTED TOTAL 83 9707.0                              
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Type I`
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## Plant     11 4862.2  442.02  12.260 1.555e-12 ***
## Type       0                                     
## Treatment  0                                     
## conc       1 2285.0 2284.99  63.379 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Type II`
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Plant      9  508.56   56.51  1.5673    0.1419    
## Type       0                                      
## Treatment  0                                      
## conc       1 2284.99 2284.99 63.3785 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Type III`
## CAUTION: Singularity Exists !
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Plant      9  508.56   56.51  1.5673    0.1419    
## Type       0                                      
## Treatment  0                                      
## conc       1 2284.99 2284.99 63.3785 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $Parameter
##                     Estimate Std. Error t value  Pr(>|t|)    
## (Intercept)          29.9015     2.4676 12.1176 < 2.2e-16 ***
## PlantMc1            -19.6143     3.2095 -6.1113 4.774e-08 ***
## PlantMc2            -25.4714     3.2095 -7.9363 2.195e-11 ***
## PlantMc3            -20.3143     3.2095 -6.3294 1.943e-08 ***
## PlantMn1            -11.2143     3.2095 -3.4941 0.0008234 ***
## PlantMn2            -10.2714     3.2095 -3.2003 0.0020535 ** 
## PlantMn3            -13.5000     3.2095 -4.2063 7.468e-05 ***
## PlantQc1             -7.6429     3.2095 -2.3813 0.0199349 *  
## PlantQc2             -4.9143     3.2095 -1.5312 0.1301715    
## PlantQc3             -5.0286     3.2095 -1.5668 0.1216132    
## PlantQn1             -4.3857     3.2095 -1.3665 0.1761008    
## PlantQn2             -2.4571     3.2095 -0.7656 0.4464613    
## PlantQn3              0.0000     0.0000                      
## TypeMississippi       0.0000     0.0000                      
## TypeQuebec            0.0000     0.0000                      
## Treatmentchilled      0.0000     0.0000                      
## Treatmentnonchilled   0.0000     0.0000                      
## conc                  0.0177     0.0022  7.9611 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
REG(uptake ~ Plant + Type + Treatment + conc, CO2) # SAS PROC REG
##                     Estimate Std. Error t value  Pr(>|t|)    
## (Intercept)          29.9015     2.4676 12.1176 < 2.2e-16 ***
## PlantMc1            -19.6143     3.2095 -6.1113 4.774e-08 ***
## PlantMc2            -25.4714     3.2095 -7.9363 2.195e-11 ***
## PlantMc3            -20.3143     3.2095 -6.3294 1.943e-08 ***
## PlantMn1            -11.2143     3.2095 -3.4941 0.0008234 ***
## PlantMn2            -10.2714     3.2095 -3.2003 0.0020535 ** 
## PlantMn3            -13.5000     3.2095 -4.2063 7.468e-05 ***
## PlantQc1             -7.6429     3.2095 -2.3813 0.0199349 *  
## PlantQc2             -4.9143     3.2095 -1.5312 0.1301715    
## PlantQc3             -5.0286     3.2095 -1.5668 0.1216132    
## PlantQn1             -4.3857     3.2095 -1.3665 0.1761008    
## PlantQn2             -2.4571     3.2095 -0.7656 0.4464613    
## PlantQn3              0.0000     0.0000                      
## TypeMississippi       0.0000     0.0000                      
## TypeQuebec            0.0000     0.0000                      
## Treatmentchilled      0.0000     0.0000                      
## Treatmentnonchilled   0.0000     0.0000                      
## conc                  0.0177     0.0022  7.9611 1.975e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1