全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1329 3
2019-11-21
> library(msm)
Warning message:
程辑包‘msm’是用R版本3.5.3 来建造的
> library(readxl)
Warning message:
程辑包‘readxl’是用R版本3.5.3 来建造的
>  w<-read_excel("C:\\Users\\HEART\\Desktop\\2组分合在一起 - 把葡萄糖异常删除 - 副本.xlsx")


> statetable.msm(state, id, data=w)
    to
from    1    2    3    4    5    6    7    8
   1 5840  754  206  565  177  628  603  177
   2  707  658   44   98   37   67  368  123
   3  149   25  533   11    6   26  472  204
   4  521  101   22  487   33   70  326   94
   5  127   24    8   14   81   21  103   41
   6  795   96   37   84   31 1034  445  155
   7  481  379  471  283  105  380 2365 1622
   8  186  114  189   93   54  124 1556 5212
> Q<-rbind(c(0,0.076,0.021,0.057,0.018,0.064,0,0),c(0.303,0,0,0,0,0,0.158,0),c(0.095,0,0,0,0,0,0.301,0),c(0.278,0,0,0,0,0,0.174,0),c(0.278,0,0,0,0,0,0.225,0),c(0.266,0,0,0,0,0,0.149,0),c(0,0.056,0.07,0.042,0.015,0.056,0,0.239),c(0,0,0,0,0,0,0.183,0))
>  w.msm <-msm(state~years,subject=id,data=w,qmatrix=Q,method="BFGS",control=list(fnscale=4000,maxit = 10000))
>  w.msm

Call:
msm(formula = state ~ years, subject = id, data = w, qmatrix = Q,     method = "BFGS", control = list(fnscale = 4000, maxit = 10000))

Maximum likelihood estimates

Transition intensities
                  Baseline                    
State 1 - State 1 -0.58522 (-0.61048,-0.56100)
State 1 - State 2  0.19909 ( 0.18334, 0.21619)
State 1 - State 3  0.03462 ( 0.02907, 0.04123)
State 1 - State 4  0.15597 ( 0.14213, 0.17115)
State 1 - State 5  0.05810 ( 0.04881, 0.06917)
State 1 - State 6  0.13743 ( 0.12608, 0.14982)
State 2 - State 1  0.79712 ( 0.73381, 0.86588)
State 2 - State 2 -1.30868 (-1.39260,-1.22980)
State 2 - State 7  0.51156 ( 0.46458, 0.56329)
State 3 - State 1  0.13088 ( 0.10375, 0.16510)
State 3 - State 3 -1.06508 (-1.14861,-0.98763)
State 3 - State 7  0.93421 ( 0.85878, 1.01626)
State 4 - State 1  0.77544 ( 0.70415, 0.85395)
State 4 - State 4 -1.35278 (-1.45096,-1.26125)
State 4 - State 7  0.57734 ( 0.51998, 0.64104)
State 5 - State 1  0.85265 ( 0.70122, 1.03679)
State 5 - State 5 -1.78058 (-2.03825,-1.55548)
State 5 - State 7  0.92793 ( 0.77261, 1.11446)
State 6 - State 1  0.58219 ( 0.54008, 0.62758)
State 6 - State 6 -0.99816 (-1.05453,-0.94480)
State 6 - State 7  0.41597 ( 0.38092, 0.45424)
State 7 - State 2  0.17568 ( 0.15932, 0.19371)
State 7 - State 3  0.21970 ( 0.20092, 0.24024)
State 7 - State 4  0.13616 ( 0.12145, 0.15265)
State 7 - State 5  0.07462 ( 0.06203, 0.08977)
State 7 - State 6  0.15766 ( 0.14343, 0.17330)
State 7 - State 7 -1.34904 (-1.39583,-1.30383)
State 7 - State 8  0.58523 ( 0.55758, 0.61425)
State 8 - State 7  0.45551 ( 0.43437, 0.47769)
State 8 - State 8 -0.45551 (-0.47769,-0.43437)

-2 * log-likelihood:  84896.27
[Note, to obtain old print format, use "printold.msm"]
>  wsex.msm<-msm(state~years,subject=id,data=w,qmatrix=Q,covariates=~sex,method="BFGS",control=list(fnscale=4000,maxit = 10000))
>
>  wsex.msm

Call:
msm(formula = state ~ years, subject = id, data = w, qmatrix = Q,     covariates = ~sex, method = "BFGS", control = list(fnscale = 4000,         maxit = 10000))

Maximum likelihood estimates
Baselines are with covariates set to their means

Transition intensities with hazard ratios for each covariate
                  Baseline                     sex                  
State 1 - State 1 -0.62922 (-0.66039,-0.59951)                       
State 1 - State 2  0.22903 ( 0.21023, 0.24952) 2.2194 (1.8618,2.6458)
State 1 - State 3  0.03974 ( 0.03338, 0.04730) 2.2846 (1.6021,3.2578)
State 1 - State 4  0.17580 ( 0.15951, 0.19376) 1.4521 (1.1895,1.7727)
State 1 - State 5  0.07166 ( 0.05940, 0.08645) 2.1730 (1.5008,3.1463)
State 1 - State 6  0.11298 ( 0.09900, 0.12893) 0.4881 (0.3658,0.6512)
State 2 - State 1  0.82039 ( 0.75262, 0.89426) 0.8834 (0.7398,1.0550)
State 2 - State 2 -1.32824 (-1.41713,-1.24493)                       
State 2 - State 7  0.50785 ( 0.45974, 0.56099) 1.3547 (1.1130,1.6490)
State 3 - State 1  0.12923 ( 0.10066, 0.16591) 0.4415 (0.2616,0.7452)
State 3 - State 3 -1.02507 (-1.10930,-0.94724)                       
State 3 - State 7  0.89584 ( 0.82034, 0.97828) 1.4418 (1.2139,1.7126)
State 4 - State 1  0.78820 ( 0.71339, 0.87087) 0.5789 (0.4722,0.7097)
State 4 - State 4 -1.36592 (-1.46858,-1.27044)                       
State 4 - State 7  0.57771 ( 0.51870, 0.64344) 1.0267 (0.8301,1.2700)
State 5 - State 1  0.99065 ( 0.80458, 1.21976) 0.4765 (0.3159,0.7186)
State 5 - State 5 -1.84215 (-2.16339,-1.56862)                       
State 5 - State 7  0.85150 ( 0.67478, 1.07450) 1.3672 (0.8818,2.1197)
State 6 - State 1  0.62860 ( 0.56722, 0.69661) 1.2830 (1.0273,1.6024)
State 6 - State 6 -1.13878 (-1.22434,-1.05919)                       
State 6 - State 7  0.51018 ( 0.45594, 0.57087) 1.3472 (1.0580,1.7154)
State 7 - State 2  0.17893 ( 0.16179, 0.19789) 0.8279 (0.6785,1.0103)
State 7 - State 3  0.21149 ( 0.19264, 0.23217) 1.3226 (1.1016,1.5878)
State 7 - State 4  0.13843 ( 0.12286, 0.15598) 0.7639 (0.6045,0.9654)
State 7 - State 5  0.07099 ( 0.05714, 0.08819) 1.2569 (0.8308,1.9014)
State 7 - State 6  0.15341 ( 0.13677, 0.17208) 0.1946 (0.1523,0.2487)
State 7 - State 7 -1.33600 (-1.38551,-1.28826)                       
State 7 - State 8  0.58275 ( 0.55339, 0.61366) 1.2173 (1.1011,1.3459)
State 8 - State 7  0.49909 ( 0.47424, 0.52524) 0.7183 (0.6506,0.7930)
State 8 - State 8 -0.49909 (-0.52524,-0.47424)                       

-2 * log-likelihood:  83676.95
[Note, to obtain old print format, use "printold.msm"]
>  wage.msm<-msm(state~years,subject=id,data=w,qmatrix=Q,covariates=~age,method="BFGS",control=list(fnscale=4000,maxit = 10000))
Error in Ccall.msm(params, do.what = "lik", ...) :
  numerical overflow in calculating likelihood
其中numerical overflow in calculating likelihood是什么意思?该怎么解决呢?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2019-11-21 14:02:17
坐等大哥们解答
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2019-11-21 14:26:45
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2024-3-7 13:10:05
王heart 发表于 2019-11-21 14:02
坐等大哥们解答
请问您解决了吗 急切
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群