Error: NA in probability vector when using the estR0() function from the R0 package
Error: NA in probability vector when using the estR0() function from the R0 package
试图使用 R0 包给定一些数据来查找复制数,但是在使用估计功能时我在最后遇到了麻烦。这是我的工作:
## Get the incidence data
test <- c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, `2020-01-25` = 0L,
`2020-01-26` = 0L, `2020-01-27` = 0L, `2020-01-28` = 0L, `2020-01-29` = 0L,
`2020-01-30` = 0L, `2020-01-31` = 0L, `2020-02-01` = 0L, `2020-02-02` = 0L,
`2020-02-03` = 0L, `2020-02-04` = 0L, `2020-02-05` = 0L, `2020-02-06` = 0L,
`2020-02-07` = 0L, `2020-02-08` = 0L, `2020-02-09` = 0L, `2020-02-10` = 0L,
`2020-02-11` = 0L, `2020-02-12` = 0L, `2020-02-13` = 0L, `2020-02-14` = 0L,
`2020-02-15` = 0L, `2020-02-16` = 0L, `2020-02-17` = 0L, `2020-02-18` = 0L,
`2020-02-19` = 0L, `2020-02-20` = 0L, `2020-02-21` = 0L, `2020-02-22` = 0L,
`2020-02-23` = 0L, `2020-02-24` = 0L, `2020-02-25` = 0L, `2020-02-26` = 0L,
`2020-02-27` = 0L, `2020-02-28` = 1L, `2020-02-29` = 3L, `2020-03-01` = 1L,
`2020-03-02` = 0L, `2020-03-03` = 0L, `2020-03-04` = 0L, `2020-03-05` = 0L,
`2020-03-06` = 1L, `2020-03-07` = 0L, `2020-03-08` = 1L, `2020-03-09` = 0L,
`2020-03-10` = 0L, `2020-03-11` = 1L, `2020-03-12` = 4L, `2020-03-13` = 0L,
`2020-03-14` = 14L, `2020-03-15` = 15L, `2020-03-16` = 12L, `2020-03-17` = 29L,
`2020-03-18` = 11L, `2020-03-19` = 25L, `2020-03-20` = 46L, `2020-03-21` = 39L,
`2020-03-22` = 48L, `2020-03-23` = 65L, `2020-03-24` = 51L, `2020-03-25` = 38L,
`2020-03-26` = 70L, `2020-03-27` = 110L, `2020-03-28` = 132L,
`2020-03-29` = 131L, `2020-03-30` = 145L, `2020-03-31` = 101L
)
## Make a time generation distribution (these parameters were found from the disease I'm studying)
d <- generation.time("gamma", c(4.243319, 2.488787))
## Calculate R0
estR0 <- estimate.R(
epid = test,
GT = d,
begin = 45,
end = 70,
methods = c("EG", "ML", "TD", "AR", "SB"),
pop.size = 126200000,
nsim = 1000
)
这会产生一个错误和几个警告:
Waiting for profiling to be done...
Error in rmultinom(nsim, epid$incid[s] - import[s], p[1:s, s]) :
NA in probability vector
In addition: Warning messages:
1: In est.R0.TD(epid = c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, :
Simulations may take several minutes.
2: In est.R0.TD(epid = c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, :
Gap in epidemic curve is longer than the generation interval. Consider using a different GT distribution (maybe with "truncate= 37 " (length of longest gap)).
3: In est.R0.TD(epid = c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, :
Using initial incidence as initial number of cases.
切换 start/end 间隔、人口和模拟参数没有帮助。 rmultinom() 步骤中出了什么问题?
根据 est.R0.TD
的帮助页面,"begin" 和 "end" 参数实际上并未使用。
试试这个:
test2 <- test[45:70]
estimate.R(
epid = test2,
GT = d,
methods = c("EG", "ML", "TD", "AR", "SB"),
pop.size = 126200000,
nsim = 1000
)
estR0
Reproduction number estimate using Exponential Growth method.
R : 2.179363[ 2.074176 , 2.291742 ]
Reproduction number estimate using Maximum Likelihood method.
R : 1.945082[ 1.778461 , 2.121745 ]
Reproduction number estimate using Attack Rate method.
R : 1.000004[ 1.000004 , 1.000005 ]
Reproduction number estimate using Time-Dependent method.
3.294674 0 4.463411 0 0 5.772949 5.059529 0 2.858751 2.361108 ...
Reproduction number estimate using Sequential Bayesian method.
试图使用 R0 包给定一些数据来查找复制数,但是在使用估计功能时我在最后遇到了麻烦。这是我的工作:
## Get the incidence data
test <- c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, `2020-01-25` = 0L,
`2020-01-26` = 0L, `2020-01-27` = 0L, `2020-01-28` = 0L, `2020-01-29` = 0L,
`2020-01-30` = 0L, `2020-01-31` = 0L, `2020-02-01` = 0L, `2020-02-02` = 0L,
`2020-02-03` = 0L, `2020-02-04` = 0L, `2020-02-05` = 0L, `2020-02-06` = 0L,
`2020-02-07` = 0L, `2020-02-08` = 0L, `2020-02-09` = 0L, `2020-02-10` = 0L,
`2020-02-11` = 0L, `2020-02-12` = 0L, `2020-02-13` = 0L, `2020-02-14` = 0L,
`2020-02-15` = 0L, `2020-02-16` = 0L, `2020-02-17` = 0L, `2020-02-18` = 0L,
`2020-02-19` = 0L, `2020-02-20` = 0L, `2020-02-21` = 0L, `2020-02-22` = 0L,
`2020-02-23` = 0L, `2020-02-24` = 0L, `2020-02-25` = 0L, `2020-02-26` = 0L,
`2020-02-27` = 0L, `2020-02-28` = 1L, `2020-02-29` = 3L, `2020-03-01` = 1L,
`2020-03-02` = 0L, `2020-03-03` = 0L, `2020-03-04` = 0L, `2020-03-05` = 0L,
`2020-03-06` = 1L, `2020-03-07` = 0L, `2020-03-08` = 1L, `2020-03-09` = 0L,
`2020-03-10` = 0L, `2020-03-11` = 1L, `2020-03-12` = 4L, `2020-03-13` = 0L,
`2020-03-14` = 14L, `2020-03-15` = 15L, `2020-03-16` = 12L, `2020-03-17` = 29L,
`2020-03-18` = 11L, `2020-03-19` = 25L, `2020-03-20` = 46L, `2020-03-21` = 39L,
`2020-03-22` = 48L, `2020-03-23` = 65L, `2020-03-24` = 51L, `2020-03-25` = 38L,
`2020-03-26` = 70L, `2020-03-27` = 110L, `2020-03-28` = 132L,
`2020-03-29` = 131L, `2020-03-30` = 145L, `2020-03-31` = 101L
)
## Make a time generation distribution (these parameters were found from the disease I'm studying)
d <- generation.time("gamma", c(4.243319, 2.488787))
## Calculate R0
estR0 <- estimate.R(
epid = test,
GT = d,
begin = 45,
end = 70,
methods = c("EG", "ML", "TD", "AR", "SB"),
pop.size = 126200000,
nsim = 1000
)
这会产生一个错误和几个警告:
Waiting for profiling to be done...
Error in rmultinom(nsim, epid$incid[s] - import[s], p[1:s, s]) :
NA in probability vector
In addition: Warning messages:
1: In est.R0.TD(epid = c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, :
Simulations may take several minutes.
2: In est.R0.TD(epid = c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, :
Gap in epidemic curve is longer than the generation interval. Consider using a different GT distribution (maybe with "truncate= 37 " (length of longest gap)).
3: In est.R0.TD(epid = c(`2020-01-22` = 0L, `2020-01-23` = 0L, `2020-01-24` = 0L, :
Using initial incidence as initial number of cases.
切换 start/end 间隔、人口和模拟参数没有帮助。 rmultinom() 步骤中出了什么问题?
根据 est.R0.TD
的帮助页面,"begin" 和 "end" 参数实际上并未使用。
试试这个:
test2 <- test[45:70]
estimate.R(
epid = test2,
GT = d,
methods = c("EG", "ML", "TD", "AR", "SB"),
pop.size = 126200000,
nsim = 1000
)
estR0
Reproduction number estimate using Exponential Growth method.
R : 2.179363[ 2.074176 , 2.291742 ]
Reproduction number estimate using Maximum Likelihood method.
R : 1.945082[ 1.778461 , 2.121745 ]
Reproduction number estimate using Attack Rate method.
R : 1.000004[ 1.000004 , 1.000005 ]
Reproduction number estimate using Time-Dependent method.
3.294674 0 4.463411 0 0 5.772949 5.059529 0 2.858751 2.361108 ...
Reproduction number estimate using Sequential Bayesian method.