Contents

1 SQL Server 2008 一危 覦 ODBC誤
2 R 伎 れ蠏覿
3 蟆郁骸 伎
4 れ螻旧(Multicollinearity)
5 fRegression-package
6 Package 'SuppDists'


1 SQL Server 2008 一危 覦 ODBC誤 #

--drop table 煙
create table 煙
(
	糾 int
,	蟆一 int
,	 int
);

insert 煙 values
	(85, 3, 65)
,	(74, 7, 50)
,	(76, 5, 55)
,	(90, 1, 65)
,	(85, 3, 55)
,	(87, 3, 70)
,	(94, 1, 65)
,	(98, 2, 70)
,	(81, 4, 55)
,	(91, 2, 70)
,	(76, 3, 50)
,	(74, 4, 55);

ODBC誤 . 一危 覲 企 sql2008襦 .

2 R 伎 れ蠏覿 #

> # SQL Server 2008 磯 R貊: れ蠏覿
> library("TSodbc")
> con <-odbcConnect(dsn = "sql2008")
> options(TSconnection = con)
> #襷 一危郁 襷る select * from 煙 tablesample(1 percent) 螳 襷 .
> result = try(dbGetQuery(con, paste("SELECT 糾, , 蟆一 FROM 煙")))
> model = lm(糾 ~  + 蟆一, result)
> summary(model)

Call:
lm(formula = 糾 ~  + 蟆一, data = result)

Residuals:
   Min     1Q Median     3Q    Max 
-5.348 -2.274 -1.276  2.954  5.673 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  53.6832    14.1808   3.786  0.00431 **
          0.6073     0.1984   3.062  0.01353 * 
蟆一         -1.9346     0.9144  -2.116  0.06348 . 
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 

Residual standard error: 3.721 on 9 degrees of freedom
Multiple R-squared: 0.8289,     Adjusted R-squared: 0.7909 
F-statistic:  21.8 on 2 and 9 DF,  p-value: 0.0003544 

> anova(model) #, 螻燕, 螻燕蠏 F螳, 
Analysis of Variance Table

Response: 糾
          Df Sum Sq Mean Sq F value    Pr(>F)    
       1 541.69  541.69 39.1297 0.0001487 ***
蟆一       1  61.97   61.97  4.4762 0.0634803 .  
Residuals  9 124.59   13.84                      
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 
> dbDisconnect(con)
[1] TRUE
> options(TSconnection = NULL)
> odbcCloseAll()
> 

3 蟆郁骸 伎 #

> summary(model)

Call:
lm(formula = 糾 ~  + 蟆一, data = result)

Residuals:
   Min     1Q Median     3Q    Max 
-5.348 -2.274 -1.276  2.954  5.673 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  53.6832    14.1808   3.786  0.00431 **
          0.6073     0.1984   3.062  0.01353 * 
蟆一         -1.9346     0.9144  -2.116  0.06348 . 
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 

Residual standard error: 3.721 on 9 degrees of freedom
Multiple R-squared: 0.8289,     Adjusted R-squared: 0.7909 
F-statistic:  21.8 on 2 and 9 DF,  p-value: 0.0003544 
  • 蠏讌 y=糾, x1=, x2=蟆一 企朱, y = 53.6832 + 0.6073x1 + -1.9346x2 朱 豢.
  • -1.9346x2朱 襷企(-)螳 螳讌る 蟆 蟆一 襦 糾煙 觜讌る 蟆 覩誤.
  • '硫1=0'企朱 蠏覓願れ T 蟆糾 3.062企, 願 P螳 0.01353朱 譴 0.05 蠏覓願れ 蠍郁蟆 . 讀, 覩誤 螳企.
  • 蟆一螻 R2 anova(覿磯) 蟆郁骸 R2 = (541.69 + 61.97)/(541.69 + 61.97 + 124.59) = 0.8289186405願, 譟一 R2螳 0.7909 企. 讀, 糾煙 煙螻 蟆一 2螳 覲 83%螳 る伎.
  • F 蟆糾 21.8企, F覿 留 = 0.05, v1=2, v2=9 螳 4.26企. 讀, 21.8 > 4.26 企襦 蠏覓願(硫1=硫2=0) 蠍郁. 讀, 覩誤 螳企. p-value螳 る襦 F覿襯 覲 . 譴 0.05 > 0.0003544 企襦 蠏覓願れ 蠍郁覃 .
  • p-value螳 朱 襴所れ 讌讌螻, 貉れ覃 蠏覓願れ 讌讌. 0.0003544 蠏覓願れ 襷り 螳 蟆曙 詞伎 蟆糾覲企 蠏豪 蟆郁骸螳 襯企. 讀, 糾 豺 蠏手碓 蟆一 る(1譬 る)螳 襯.
  • 譴 0.05朱 蟆 95%襷 蠏 螳蟾 朱 螳螻, 蠏螳 覃襴 伎 5% 觜朱 螳る 蟆企.

> anova(model) #, 螻燕, 螻燕蠏 F螳, 
Analysis of Variance Table

Response: 糾
          Df Sum Sq Mean Sq F value    Pr(>F)    
       1 541.69  541.69 39.1297 0.0001487 ***
蟆一       1  61.97   61.97  4.4762 0.0634803 .  
Residuals  9 124.59   13.84                      
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1 

螻燕螻燕蠏F觜
603.6611301.8321.802950
谿124.59913.84
728.2511

  • F 蟆糾 21.8企, F覿 留 = 0.05, v1=2, v2=9 螳 4.26企. 讀, 21.8 > 4.26 企襦 蠏覓願(硫1=硫2=0) 蠍郁. 讀, 覩誤 螳企.
  • 蟆一螻 R2 R2 = 603.66/728.25 = 0.82891864 企.
  • 襦 . ろ . 螳 讌 碁 覲危 覲語 螳襯 覩誤.

4 れ螻旧(Multicollinearity) #

れ螻旧(Multicollinearity) ル 螳 蟯螳 襯 襷. 讀, 覲 x襯 觜手 蠏覿 x 蟯螳 覓 R螳 譟磯 蟆 る 蟆 襷. 讀, 譬覲 譟磯 蟯螻. 讀, "螳 襯 襷 葛" "蟲襷 螳 襷 螻螳れ 襷れ觜譴 " 襦 煙朱 . れ螻旧 覲螳 蟯蟯螻螳 るジ 覲覲企 麹 蟆曙一 . 覲企 覦覯 螻給郁骸 蟯螻覓語 螻給壱 覿覿 谿瑚.

5 fRegression-package #

蠏覿 襯 覈襴 ク蟆 蟆 覘.. 蠏碁一 れ..
http://cran.r-project.org/web/packages/fRegression/fRegression.pdf

#library(fRegression)
#regFit(formula, data, use = "lm", ...)
#use = c("lm", "rlm", "glm","gam", "ppr", "nnet", "polymars")
model = rlm(NetAMT ~ Playtime + LoginCnt, data, use = "lm")

6 Package 'SuppDists' #

豢螳 覿覈企.. 企 蟆れ り ..

Friedman
ghyper
ghypertypes
invGauss
Johnson
Kendall
KruskalWallis
maxFratio
MWC1019
NormalScore
Pearson
Spearman
ziggurat