使用 linear-ish 參數模型的置信區間的便捷函數
用法
reg_intervals(
formula,
data,
model_fn = "lm",
type = "student-t",
times = NULL,
alpha = 0.05,
filter = term != "(Intercept)",
keep_reps = FALSE,
...
)
參數
- formula
-
具有一個結果和至少一個預測變量的 R 模型公式。
- data
-
一個 DataFrame 。
- model_fn
-
適合的模型。允許的值為"lm"、"glm"、"survreg" 和"coxph"。後兩者需要安裝
survival
軟件包。 - type
-
自舉置信區間的類型。允許使用 "student-t" 和 "percentile" 的值。
- times
-
引導樣本數量的單個整數。如果保留 NULL,則 1,001 用於 t-intervals,2,001 用於百分位間隔。
- alpha
-
重要性程度。
- filter
-
用於從最終結果中刪除行的邏輯表達式,或
NULL
以保留所有行。 - keep_reps
-
是否應該保留每個引導樣本的單獨參數估計值?
- ...
-
傳遞給模型函數的選項(例如
family
forglm()
)。
值
包含列 "term"、".lower"、".estimate"、".upper"、".alpha" 和 ".method" 的小標題。如果 keep_reps = TRUE
,還會返回一個名為 ".replicates" 的附加列表列。
參考
戴維森,A. 和欣克利,D. (1997)。 Bootstrap 方法及其應用。劍橋:劍橋大學出版社。號碼:10.1017/CBO9780511802843
自舉置信區間,https://rsample.tidymodels.org/articles/Applications/Intervals.html
例子
# \donttest{
set.seed(1)
reg_intervals(mpg ~ I(1 / sqrt(disp)), data = mtcars)
#> # A tibble: 1 × 6
#> term .lower .estimate .upper .alpha .method
#> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 I(1/sqrt(disp)) 207. 249. 290. 0.05 student-t
set.seed(1)
reg_intervals(mpg ~ I(1 / sqrt(disp)), data = mtcars, keep_reps = TRUE)
#> # A tibble: 1 × 7
#> term .lower .estimate .upper .alpha .method .replicates
#> <chr> <dbl> <dbl> <dbl> <dbl> <chr> <list<tibble[,>
#> 1 I(1/sqrt(disp)) 207. 249. 290. 0.05 student-t [1,001 × 2]
# }
相關用法
- R rsample reverse_splits 反轉分析和評估集
- R rsample reshuffle_rset “重新洗牌”一個 rset 以重新生成具有相同參數的新 rset
- R rsample rset_reconstruct 使用新的 rset 子類擴展 rsample
- R rsample rolling_origin 滾動原點預測重采樣
- R rsample validation_set 創建驗證拆分以進行調整
- R rsample initial_split 簡單的訓練/測試集分割
- R rsample populate 添加評估指標
- R rsample int_pctl 自舉置信區間
- R rsample vfold_cv V 折交叉驗證
- R rsample group_mc_cv 小組蒙特卡羅交叉驗證
- R rsample group_vfold_cv V 組交叉驗證
- R rsample group_bootstraps 團體自舉
- R rsample labels.rset 從 rset 對象中查找標簽
- R rsample get_fingerprint 獲取重采樣的標識符
- R rsample bootstraps 引導抽樣
- R rsample validation_split 創建驗證集
- R rsample clustering_cv 集群交叉驗證
- R rsample initial_validation_split 創建初始訓練/驗證/測試拆分
- R rsample get_rsplit 從 rset 中檢索單個 rsplit 對象
- R rsample loo_cv 留一交叉驗證
- R rsample complement 確定評估樣本
- R rsample slide-resampling 基於時間的重采樣
- R rsample as.data.frame.rsplit 將 rsplit 對象轉換為 DataFrame
- R rsample labels.rsplit 從 rsplit 對象中查找標簽
- R rsample mc_cv 蒙特卡羅交叉驗證
注:本文由純淨天空篩選整理自Hannah Frick等大神的英文原創作品 A convenience function for confidence intervals with linear-ish parametric models。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。