簡體   English   中英

條件密度分布,兩個離散變量

[英]Conditional density distribution, two discrete variables

我已經使用cdplot(R)繪制了變量的條件密度分布圖。 我的自變量和我的因變量不是獨立的。 自變量是離散的(僅接受0到3之間的某些值),因變量也是離散的(從0到1的11個級別,以0.1為步長)。

在此處輸入圖片說明

一些數據:

dat <- read.table( text="y           x
3.00     0.0
2.75     0.0
2.75     0.1
2.75     0.1
2.75     0.2
2.25     0.2
3        0.3
2        0.3
2.25     0.4
1.75     0.4
1.75     0.5
2        0.5
1.75     0.6
1.75     0.6
1.75     0.7
1        0.7
0.54     0.8
0        0.8
0.54     0.9
0        0.9
0        1.0
0        1.0", header=TRUE, colClasses="factor")

我想知道我的變量是否適合進行這種分析。

另外,我想知道如何以學術和統計意義上的優雅方式報告此結果。

這是使用rms -packages`lrm函數的運行,該函數通常用於二進制結果,但也可以處理有序的分類變量:

library(rms) # also loads Hmisc
      # first get data in the form you described
dat[] <- lapply(dat, ordered)  # makes both columns ordered factor variables

?lrm   
#read help page ... Also look at the supporting book and citations on that page
lrm( y ~ x, data=dat)
# --- output------
Logistic Regression Model

 lrm(formula = y ~ x, data = dat)


 Frequencies of Responses

    0 0.54    1 1.75    2 2.25 2.75    3 3.00 
    4    2    1    5    2    2    4    1    1 

                        Model Likelihood        Discrimination       Rank Discrim.    
                           Ratio Test              Indexes              Indexes       
 Obs             22    LR chi2      51.66    R2             0.920    C       0.869    
 max |deriv| 0.0004    d.f.            10    g             20.742    Dxy     0.738    
                       Pr(> chi2) <0.0001    gr    1019053402.761    gamma   0.916    
                                             gp             0.500    tau-a   0.658    
                                             Brier          0.048                     

         Coef     S.E.     Wald Z Pr(>|Z|)
 y>=0.54  41.6140 108.3624  0.38  0.7010  
 y>=1     31.9345  88.0084  0.36  0.7167  
 y>=1.75  23.5277  74.2031  0.32  0.7512  
 y>=2      6.3002   2.2886  2.75  0.0059  
 y>=2.25   4.6790   2.0494  2.28  0.0224  
 y>=2.75   3.2223   1.8577  1.73  0.0828  
 y>=3      0.5919   1.4855  0.40  0.6903  
 y>=3.00  -0.4283   1.5004 -0.29  0.7753  
 x       -19.0710  19.8718 -0.96  0.3372  
 x=0.2     0.7630   3.1058  0.25  0.8059  
 x=0.3     3.0129   5.2589  0.57  0.5667  
 x=0.4     1.9526   6.9051  0.28  0.7773  
 x=0.5     2.9703   8.8464  0.34  0.7370  
 x=0.6    -3.4705  53.5272 -0.06  0.9483  
 x=0.7   -10.1780  75.2585 -0.14  0.8924  
 x=0.8   -26.3573 109.3298 -0.24  0.8095  
 x=0.9   -24.4502 109.6118 -0.22  0.8235  
 x=1     -35.5679 488.7155 -0.07  0.9420  

也有MASS::polr函數,但是我發現Harrell的版本更MASS::polr 也可以通過等級回歸來解決。 如果這是您選擇的路線,那么quantreg軟件包是非常標准的。 看着您的另一個問題,我想知道您是否嘗試過邏輯轉換作為使關系線性化的方法。 當然,圖示的lrm與有序變量的使用是“ lrm ”的邏輯轉換。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM