Skip to content

Commit

Permalink
Test with Fedora 39 and Quarto 1.4.489 (#121)
Browse files Browse the repository at this point in the history
* Test with Fedora 39 and Quarto 1.4.489

* INLA fix

* disable inla

* Quarto 1.4.504
  • Loading branch information
XiangyunHuang committed Nov 15, 2023
1 parent a4c0db6 commit 1c823a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/quarto-book-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
env:
CMDSTAN_VERSION: "2.33.1"
container:
image: ghcr.io/xiangyunhuang/fedora-rstudio-pro:1.4.455
image: ghcr.io/xiangyunhuang/fedora-rstudio-pro:1.4.504
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down
31 changes: 27 additions & 4 deletions analyze-survival-data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ library(ggplot2)
library(ggfortify) # autoplot
library(ggsurvfit) # survfit2 and ggsurvfit
library(glmnet) # Cox Models
# library(VGAM) # R >= 4.4.0
library(VGAM) # R >= 4.4.0
library(INLA)
```

Expand Down Expand Up @@ -91,6 +91,13 @@ autoplot(aml_survival, data = aml) +
theme_minimal()
```

参数化的生存分析模型(参数模型,相对于非参数模型而言)

```{r}
aml_surv_reg <- survreg(Surv(time, status) ~ x, data = aml, dist = "weibull")
summary(aml_surv_reg)
```

下面 ggsurvfit 包再次拟合模型,并展示模型结果。

### ggsurvfit
Expand Down Expand Up @@ -146,7 +153,7 @@ INLA 包拟合 Cox 比例风险回归模型 [@gómez-rubio2020] 采用近似贝
```{r}
library(INLA)
inla.setOption(short.summary = TRUE)
aml_inla <- inla(inla.surv(time, status) ~ x, data = aml, family = "exponential.surv")
aml_inla <- inla(inla.surv(time, status) ~ x, data = aml, family = "exponential.surv", num.threads = "1:1")
summary(aml_inla)
```

Expand All @@ -156,9 +163,25 @@ Tobit (Tobin's Probit) regression 起源于计量经济学中的 Tobit 模型,

- 逻辑回归,响应变量是无序的分类变量,假定服从二项、多项分布,拟合函数 `glm()``nnet::multinom()`
- Probit 回归,响应变量是有序的分类变量,拟合函数 `MASS::polr()`
- Tobit 回归,响应变量是有删失/截尾的,VGAM 包依赖少,稳定,推荐使用。
- Tobit 回归,响应变量是有删失/截尾的,VGAM 包依赖少,稳定,推荐使用。VGAM 包括了广义线性模型

```{r}
# library(VGAM) # Vector Generalized Linear and Additive Models
#| eval: false
#| echo: false
library(VGAM) # Vector Generalized Linear and Additive Models
# VGAM::vglm(family = tobit(Upper = 800)) # Tobit regression
```

```{r}
library(VGAM)
with(aml, SurvS4(time, status))
```

```{r}
#| eval: false
#| echo: false
aml_vglm <- vglm(SurvS4(time, status) ~ x, data = aml, family = cens.poisson)
summary(aml_vglm)
```

0 comments on commit 1c823a4

Please sign in to comment.