微信號:moooshaaa
The tobit model, also called a censored regression model, is designed to estimate linear relationships between variables when there is either left- or right-censoring in the dependent variable (also known as censoring from below and above, respectively). Censoring from above takes place when cases with a value at or above some threshold, all take on the value of that threshold, so that the true value might be equal to the threshold, but it might also be higher. In the case of censoring from below, values those that fall at or below some threshold are censored.
Syntaxinstall.packages("rio")
library(rio)
tb<- import("tb.sav")
head(tb)
no nation education religion marriage surgical admission ability watcher painscore Spirituality fatigue anxiety depression
1 1 2 3 0 2 1 3 2 3 2 28 27 60 50
2 2 1 3 0 2 0 2 1 2 0 0 25 31 54
3 3 1 3 0 2 1 1 1 1 0 0 7 61 65
4 4 1 3 0 2 0 3 1 5 1 8 20 43 56
5 5 1 2 0 2 1 1 1 1 3 1 19 39 65
6 6 1 2 0 2 1 1 1 2 3 1 18 30 68
install.packages("ggplot2")
library(ggplot2)
ggplot(fqp,aes(x=Spirituality))+geom_histogram(binwidth = 1,color="black",fill="lightblue")+theme_classic()
table(tb$Spirituality)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 26 27 28 29 30
83 40 46 45 44 27 19 31 25 18 15 19 10 13 12 4 9 10 5 2 5 1 1 1 1 2 4 2 1 11
tb[, c(2:8)] <- lapply(tb[, c(2:8)], as.factor)
install.packages("AER")
library(AER)
tob <- tobit(Spirituality~nation+education+religion+marriage+surgical+admission+ability+watcher+painscore+fatigue+anxiety+depression, left=0, right=30,data=tb)
summary(tob)
Call:
tobit(formula = Spirituality ~ nation + education + religion +
marriage + surgical + admission + ability + watcher + painscore +
fatigue + anxiety + depression, left = 0, right = 30, data = tb)
Observations:
Total Left-censored Uncensored Right-censored
506 83 412 11
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.8173462 3.4142289 -1.411 0.158256
nation2 7.7535758 2.8050581 2.764 0.005707 **
education2 0.3342179 1.2822924 0.261 0.794369
education3 1.2602936 1.2531426 1.006 0.314557
education4 1.2096651 1.3771478 0.878 0.379735
education5 0.5244939 1.4314840 0.366 0.714068
religion1 2.1190651 0.9978343 2.124 0.033698 *
marriage2 -6.2044315 1.9804453 -3.133 0.001731 **
marriage3 -5.5268713 2.6140756 -2.114 0.034492 *
marriage4 -4.4166787 3.0722339 -1.438 0.150544
surgical1 2.3173049 0.6537617 3.545 0.000393 ***
admission2 -0.3099729 0.9072388 -0.342 0.732602
admission3 1.7618913 1.0855788 1.623 0.104590
admission4 1.0249864 0.9155694 1.120 0.262924
ability2 1.4637859 0.7993352 1.831 0.067063 .
ability3 3.3800014 4.0795092 0.829 0.407370
watcher -0.0261221 0.2562860 -0.102 0.918816
painscore 0.3798834 0.1936808 1.961 0.049834 *
fatigue 0.3041730 0.0516955 5.884 4.01e-09 ***
anxiety 0.1405580 0.0368999 3.809 0.000139 ***
depression 0.0002381 0.0354631 0.007 0.994644
Log(scale) 1.9088505 0.0361523 52.800 < 2e-16 ***
Signif. codes: 0 『***』 0.001 『**』 0.01 『*』 0.05 『.』 0.1 『 』 1
Scale: 6.745
Gaussian distribution
Number of Newton-Raphson Iterations: 4
Log-likelihood: -1461 on 22 Df
Wald-statistic: 195.5 on 20 Df, p-value: < 2.22e-16
此外, VGAM 和Zelig package 也可以實現Tobit回歸
醫學統計與R語言:唉,畫個圖!
醫學統計與R語言:多重比較P值的可視化
醫學統計與R語言:爬蟲抓取國自然基金信息
醫學統計與R語言:多元方差分析與非參數多元方差分析
醫學統計與R語言:使用R語言實現Johnson-Neyman分析
醫學統計與R語言:多層線性模型圖示
醫學統計與R語言:多層線性模型(混合線性模型
醫學統計與R語言:best subset of inputs for the glm famil
醫學統計與R語言:多重線回歸自變量篩選的幾種方法
醫學統計與R語言:關聯規則Apriori算
醫學統計與R語言:列聯表可視化的4種方
醫學統計與R語言:盤它!什麼格式文件都可
醫學統計與R語言:離群值分析(Outlier Detection
醫學統計與R語言:決策樹CHAI
醫學統計與R語言:主成分分析(PCA)及可視
醫學統計與R語言:矩陣的特徵值和奇異值分
醫學統計與R語言:聽說你還在手動畫三線表!
醫學統計與R語言:合併多個Excel文
醫學統計與R語言:政策效果評價之合成控制
醫學統計與R語言:線性回歸模型假設條件驗證與診斷醫學統計與R語言:可能是最全R語言操作手冊(cheatsheets)
醫學統計與R語言:想發表sci就畫這種Bland-Altman Plot
醫學統計與R語言:logistic回歸假設條件驗證及診斷
醫學統計與R語言:二分類Logisticl回歸和診斷強大的log.regr()函數
醫學統計與R語言:logistic回歸ROC、Nomogram繪製及模型輸出
醫學統計與R語言:logistic回歸中相加交互作用分析
醫學統計與R語言:線性回歸中交互作用可視化的5種方法
醫學統計與R語言:ggplot2一頁多圖及子圖嵌入主圖的多種實現方法
醫學統計與R語言:相關係數矩陣的可視化
醫學統計與R語言:診斷試驗評價指標
醫學統計與R語言:簡單線性回歸(區間預測及標化回歸係數)
醫學統計與R語言