最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

R語言邏輯回歸深入講解

 更新時間:2021年03月17日 15:42:57   作者:瑤池里  
這篇文章主要介紹了R語言邏輯回歸深入講解,文中對于邏輯回歸講解的很細致,有感興趣的同學可以研究下

邏輯回歸

> ###############邏輯回歸
> setwd("/Users/yaozhilin/Downloads/R_edu/data")
> accepts<-read.csv("accepts.csv")
> names(accepts)
 [1] "application_id" "account_number" "bad_ind"    "vehicle_year"  "vehicle_make" 
 [6] "bankruptcy_ind" "tot_derog"   "tot_tr"     "age_oldest_tr" "tot_open_tr"  
[11] "tot_rev_tr"   "tot_rev_debt"  "tot_rev_line"  "rev_util"    "fico_score"  
[16] "purch_price"  "msrp"      "down_pyt"    "loan_term"   "loan_amt"   
[21] "ltv"      "tot_income"   "veh_mileage"  "used_ind"   
> accepts<-accepts[complete.cases(accepts),]
> select<-sample(1:nrow(accepts),length(accepts$application_id)*0.7)
> train<-accepts[select,]###70%用于建模
> test<-accepts[-select,]###30%用于檢測
> attach(train)
> ###用glm(y~x,family=binomial(link="logit"))
> gl<-glm(bad_ind~fico_score,family=binomial(link = "logit"))
> summary(gl)

Call:
glm(formula = bad_ind ~ fico_score, family = binomial(link = "logit"))

Deviance Residuals: 
  Min    1Q  Median    3Q   Max 
-2.0794 -0.6790 -0.4937 -0.3073  2.6028 

Coefficients:
       Estimate Std. Error z value Pr(>|z|)  
(Intercept) 9.049667  0.629120  14.38  <2e-16 ***
fico_score -0.015407  0.000938 -16.43  <2e-16 ***
---
Signif. codes: 0 ‘***' 0.001 ‘**' 0.01 ‘*' 0.05 ‘.' 0.1 ‘ ' 1

(Dispersion parameter for binomial family taken to be 1)

  Null deviance: 2989.2 on 3046 degrees of freedom
Residual deviance: 2665.9 on 3045 degrees of freedom
AIC: 2669.9

Number of Fisher Scoring iterations: 5

多元邏輯回歸

> ###多元邏輯回歸
> gls<-glm(bad_ind~fico_score+bankruptcy_ind+age_oldest_tr+
+      tot_derog+rev_util+veh_mileage,family = binomial(link = "logit"))
> summary(gls)

Call:
glm(formula = bad_ind ~ fico_score + bankruptcy_ind + age_oldest_tr + 
  tot_derog + rev_util + veh_mileage, family = binomial(link = "logit"))

Deviance Residuals: 
  Min    1Q  Median    3Q   Max 
-2.2646 -0.6743 -0.4647 -0.2630  2.8177 

Coefficients:
         Estimate Std. Error z value Pr(>|z|)  
(Intercept)   8.205e+00 7.433e-01 11.039 < 2e-16 ***
fico_score   -1.338e-02 1.092e-03 -12.260 < 2e-16 ***
bankruptcy_indY -3.771e-01 1.855e-01 -2.033  0.0421 * 
age_oldest_tr  -4.458e-03 6.375e-04 -6.994 2.68e-12 ***
tot_derog    3.012e-02 1.552e-02  1.941  0.0523 . 
rev_util     3.763e-04 5.252e-04  0.717  0.4737  
veh_mileage   2.466e-06 1.381e-06  1.786  0.0741 . 
---
Signif. codes: 0 ‘***' 0.001 ‘**' 0.01 ‘*' 0.05 ‘.' 0.1 ‘ ' 1

(Dispersion parameter for binomial family taken to be 1)

  Null deviance: 2989.2 on 3046 degrees of freedom
Residual deviance: 2601.4 on 3040 degrees of freedom
AIC: 2615.4

Number of Fisher Scoring iterations: 5

> glss<-step(gls,direction = "both")
Start: AIC=2615.35
bad_ind ~ fico_score + bankruptcy_ind + age_oldest_tr + tot_derog + 
  rev_util + veh_mileage

         Df Deviance  AIC
- rev_util    1  2601.9 2613.9
<none>        2601.3 2615.3
- veh_mileage   1  2604.4 2616.4
- tot_derog    1  2605.1 2617.1
- bankruptcy_ind 1  2605.7 2617.7
- age_oldest_tr  1  2655.9 2667.9
- fico_score   1  2763.8 2775.8

Step: AIC=2613.88
bad_ind ~ fico_score + bankruptcy_ind + age_oldest_tr + tot_derog + 
  veh_mileage

         Df Deviance  AIC
<none>        2601.9 2613.9
- veh_mileage   1  2604.9 2614.9
+ rev_util    1  2601.3 2615.3
- tot_derog    1  2605.7 2615.7
- bankruptcy_ind 1  2606.1 2616.1
- age_oldest_tr  1  2656.9 2666.9
- fico_score   1  2773.2 2783.2
> #出來的數(shù)據(jù)是logit,我們需要轉(zhuǎn)換
> train$pre<-predict(glss,train)
> #出來的數(shù)據(jù)是logit,我們需要轉(zhuǎn)換
> train$pre<-predict(glss,train)
> summary(train$pre)
  Min. 1st Qu. Median  Mean 3rd Qu.  Max. 
 -4.868 -2.421 -1.671 -1.713 -1.011  2.497 
> train$pre_p<-1/(1+exp(-1*train$pre))
> summary(train$pre_p)
  Min. 1st Qu. Median  Mean 3rd Qu.  Max. 
0.00763 0.08157 0.15823 0.19298 0.26677 0.92395
 #邏輯回歸不需要檢測擾動項,但需要檢測共線性
 > library(car)
 > vif(glss)
 > fico_score bankruptcy_ind age_oldest_tr   tot_derog  veh_mileage 
 >1.271283    1.144846    1.075603    1.423850    1.003616 

到此這篇關于R語言邏輯回歸深入講解的文章就介紹到這了,更多相關R語言邏輯回歸內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • R語言運算符知識點講解

    R語言運算符知識點講解

    在本篇文章里小編給大家分享了一篇關于R語言運算符知識點講解內(nèi)容,有興趣的朋友們可以參考下。
    2021-03-03
  • R語言非線性模型的實現(xiàn)

    R語言非線性模型的實現(xiàn)

    本文主要介紹了R語言非線性模型的實現(xiàn),文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • R語言-實現(xiàn)將向量轉(zhuǎn)換成一個字符串

    R語言-實現(xiàn)將向量轉(zhuǎn)換成一個字符串

    這篇文章主要介紹了R語言-實現(xiàn)將向量轉(zhuǎn)換成一個字符串,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • R語言dplyr包之高效數(shù)據(jù)處理函數(shù)(filter、group_by、mutate、summarise)詳解

    R語言dplyr包之高效數(shù)據(jù)處理函數(shù)(filter、group_by、mutate、summarise)詳解

    這篇文章主要介紹了R語言dplyr包之高效數(shù)據(jù)處理函數(shù)(filter、group_by、mutate、summarise)的相關知識,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-03-03
  • 最新評論

    额敏县| 科尔| 安化县| 灵武市| 加查县| 聊城市| 穆棱市| 虞城县| 延川县| 满城县| 潼南县| 梨树县| 梅河口市| 渭源县| 景德镇市| 彩票| 盐源县| 金昌市| 北票市| 灵武市| 区。| 惠来县| 九龙城区| 视频| 喀什市| 巩义市| 博乐市| 孟津县| 阿城市| 慈利县| 孟村| 义乌市| 民和| 旺苍县| 马鞍山市| 杨浦区| 巴彦淖尔市| 高淳县| 通许县| 防城港市| 平和县|