- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想从逻辑回归模型列表中提取标准误差。
这是逻辑回归函数,以这种方式设计,因此我可以一次运行多个分析:
glmfunk <- function(x) glm( ldata$DFREE ~ x , family=binomial)
glmkort <- lapply(ldata[,c(2,3,5,6,7,8)],glmfunk)
sapply(glmkørt, "[[", "coefficients")
str(glmkort)
List of 6
$ AGE :List of 30
..$ coefficients : Named num [1:2] -1.17201 -0.00199
.. ..- attr(*, "names")= chr [1:2] "(Intercept)" "x"
..$ residuals : Named num [1:40] -1.29 -1.29 -1.29 -1.29 4.39 ...
.. ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
..$ fitted.values : Named num [1:40] 0.223 0.225 0.225 0.225 0.228 ...
.. ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
..$ effects : Named num [1:40] 3.2662 -0.0282 -0.4595 -0.4464 2.042 ...
.. ..- attr(*, "names")= chr [1:40] "(Intercept)" "x" "" "" ...
..$ R : num [1:2, 1:2] -2.64 0 -86.01 14.18
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "(Intercept)" "x"
.. .. ..$ : chr [1:2] "(Intercept)" "x"
..$ rank : int 2
..$ qr :List of 5
.. ..$ qr : num [1:40, 1:2] -2.641 0.158 0.158 0.158 0.159 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:40] "1" "2" "3" "4" ...
.. .. .. ..$ : chr [1:2] "(Intercept)" "x"
.. ..$ rank : int 2
.. ..$ qraux: num [1:2] 1.16 1.01
.. ..$ pivot: int [1:2] 1 2
.. ..$ tol : num 1e-11
.. ..- attr(*, "class")= chr "qr"
..$ family :List of 12
.. ..$ family : chr "binomial"
.. ..$ link : chr "logit"
.. ..$ linkfun :function (mu)
.. ..$ linkinv :function (eta)
.. ..$ variance :function (mu)
.. ..$ dev.resids:function (y, mu, wt)
.. ..$ aic :function (y, n, mu, wt, dev)
.. ..$ mu.eta :function (eta)
.. ..$ initialize: expression({ if (NCOL(y) == 1) { if (is.factor(y)) y <- y != levels(y)[1L] n <- rep.int(1, nobs) y[weights == 0] <- 0 if (any(y < 0 | y > 1)) stop("y values must be 0 <= y <= 1") mustart <- (weights * y + 0.5)/(weights + 1) m <- weights * y if (any(abs(m - round(m)) > 0.001)) warning("non-integer #successes in a binomial glm!") } else if (NCOL(y) == 2) { if (any(abs(y - round(y)) > 0.001)) warning("non-integer counts in a binomial glm!") n <- y[, 1] + y[, 2] y <- ifelse(n == 0, 0, y[, 1]/n) weights <- weights * n mustart <- (n * y + 0.5)/(n + 1) } else stop("for the binomial family, y must be a vector of 0 and 1's\n", "or a 2 column matrix where col 1 is no. successes and col 2 is no. failures") })
.. ..$ validmu :function (mu)
.. ..$ valideta :function (eta)
.. ..$ simulate :function (object, nsim)
.. ..- attr(*, "class")= chr "family"
..$ linear.predictors: Named num [1:40] -1.25 -1.24 -1.24 -1.24 -1.22 ...
.. ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
..$ deviance : num 42.7
..$ aic : num 46.7
..$ null.deviance : num 42.7
..$ iter : int 4
..$ weights : Named num [1:40] 0.173 0.174 0.174 0.174 0.176 ...
.. ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
..$ prior.weights : Named num [1:40] 1 1 1 1 1 1 1 1 1 1 ...
.. ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
..$ df.residual : int 38
..$ df.null : int 39
..$ y : Named num [1:40] 0 0 0 0 1 0 1 0 0 0 ...
.. ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
..$ converged : logi TRUE
..$ boundary : logi FALSE
..$ model :'data.frame': 40 obs. of 2 variables:
.. ..$ ldata$DFREE: int [1:40] 0 0 0 0 1 0 1 0 0 0 ...
.. ..$ x : int [1:40] 39 33 33 32 24 30 39 27 40 36 ...
.. ..- attr(*, "terms")=Classes 'terms', 'formula' length 3 ldata$DFREE ~ x
.. .. .. ..- attr(*, "variables")= language list(ldata$DFREE, x)
.. .. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. ..$ : chr [1:2] "ldata$DFREE" "x"
.. .. .. .. .. ..$ : chr "x"
.. .. .. ..- attr(*, "term.labels")= chr "x"
.. .. .. ..- attr(*, "order")= int 1
.. .. .. ..- attr(*, "intercept")= int 1
.. .. .. ..- attr(*, "response")= int 1
.. .. .. ..- attr(*, ".Environment")=<environment: 0x017a5674>
.. .. .. ..- attr(*, "predvars")= language list(ldata$DFREE, x)
.. .. .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric"
.. .. .. .. ..- attr(*, "names")= chr [1:2] "ldata$DFREE" "x"
..$ call : language glm(formula = ldata$DFREE ~ x, family = binomial)
..$ formula :Class 'formula' length 3 ldata$DFREE ~ x
.. .. ..- attr(*, ".Environment")=<environment: 0x017a5674>
..$ terms :Classes 'terms', 'formula' length 3 ldata$DFREE ~ x
.. .. ..- attr(*, "variables")= language list(ldata$DFREE, x)
.. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : chr [1:2] "ldata$DFREE" "x"
.. .. .. .. ..$ : chr "x"
.. .. ..- attr(*, "term.labels")= chr "x"
.. .. ..- attr(*, "order")= int 1
.. .. ..- attr(*, "intercept")= int 1
.. .. ..- attr(*, "response")= int 1
.. .. ..- attr(*, ".Environment")=<environment: 0x017a5674>
.. .. ..- attr(*, "predvars")= language list(ldata$DFREE, x)
.. .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric"
.. .. .. ..- attr(*, "names")= chr [1:2] "ldata$DFREE" "x"
..$ data :<environment: 0x017a5674>
..$ offset : NULL
..$ control :List of 3
.. ..$ epsilon: num 1e-08
.. ..$ maxit : num 25
.. ..$ trace : logi FALSE
..$ method : chr "glm.fit"
..$ contrasts : NULL
..$ xlevels : Named list()
..- attr(*, "class")= chr [1:2] "glm" "lm"
$ BECK :List of 30
> ldata
ID AGE BECK IVHX NDRUGTX RACE TREAT SITE DFREE
1 1 39 9.000 3 1 0 1 0 0
2 2 33 34.000 2 8 0 1 0 0
3 3 33 10.000 3 3 0 1 0 0
4 4 32 20.000 3 1 0 0 0 0
5 5 24 5.000 1 5 1 1 0 1
6 6 30 32.550 3 1 0 1 0 0
7 7 39 19.000 3 34 0 1 0 1
8 8 27 10.000 3 2 0 1 0 0
9 9 40 29.000 3 3 0 1 0 0
10 10 36 25.000 3 7 0 1 0 0
11 11 38 18.900 3 8 0 1 0 0
12 12 29 16.000 1 1 0 1 0 0
13 13 32 36.000 3 2 1 1 0 1
14 14 41 19.000 3 8 0 1 0 0
15 15 31 18.000 3 1 0 1 0 0
16 16 27 12.000 3 3 0 1 0 0
17 17 28 34.000 3 6 0 1 0 0
18 18 28 23.000 2 1 0 1 0 0
19 19 36 26.000 1 15 1 1 0 1
20 20 32 18.900 3 5 0 1 0 1
21 21 33 15.000 1 1 0 0 0 1
22 22 28 25.200 3 8 0 0 0 0
23 23 29 6.632 2 0 0 0 0 0
24 24 35 2.100 3 9 0 0 0 0
25 25 45 26.000 3 6 0 0 0 0
26 26 35 39.789 3 5 0 0 0 0
27 27 24 20.000 1 3 0 0 0 0
28 28 36 16.000 3 7 0 0 0 0
29 29 39 22.000 3 9 0 0 0 1
30 30 36 9.947 2 10 0 0 0 0
31 31 37 9.450 3 1 0 0 0 0
32 32 30 39.000 3 1 0 0 0 0
33 33 44 41.000 3 5 0 0 0 0
34 34 28 31.000 1 6 1 0 0 1
35 35 25 20.000 1 3 1 0 0 0
36 36 30 8.000 3 7 0 1 0 0
37 37 24 9.000 1 1 0 0 0 0
38 38 27 20.000 1 1 0 0 0 0
39 39 30 8.000 1 2 1 0 0 1
40 40 34 8.000 3 0 0 1 0 0
最佳答案
使用 ?glm
中的示例
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
## copy twice to a list to illustrate
lmod <- list(mod1 = glm.D93, mod2 = glm.D93)
summary()
将,或在调用
summary()
后提取它们.前者效率更高,因为你只计算你想要的。后者不依赖于了解标准误差是如何得出的。
vcov()
提取器函数为我们获取方差 - 协方差矩阵,我们将对角线与
sqrt(diag())
平方根:
> lapply(lmod, function(x) sqrt(diag(vcov(x))))
$mod1
(Intercept) outcome2 outcome3 treatment2 treatment3
0.1708987 0.2021708 0.1927423 0.2000000 0.2000000
$mod2
(Intercept) outcome2 outcome3 treatment2 treatment3
0.1708987 0.2021708 0.1927423 0.2000000 0.2000000
summary()
的调用中提取它们
summary()
计算标准误差(以及更多),然后使用
lapply()
或
sapply()
应用提取
coef(summary(x))
的匿名函数并取第二列(其中存储标准错误)。
lapply(lmod, function(x) coef(summary(x))[,2])
> lapply(lmod, function(x) coef(summary(x))[,2])
$mod1
(Intercept) outcome2 outcome3 treatment2 treatment3
0.1708987 0.2021708 0.1927423 0.2000000 0.2000000
$mod2
(Intercept) outcome2 outcome3 treatment2 treatment3
0.1708987 0.2021708 0.1927423 0.2000000 0.2000000
sapply()
会给:
> sapply(lmod, function(x) coef(summary(x))[,2])
mod1 mod2
(Intercept) 0.1708987 0.1708987
outcome2 0.2021708 0.2021708
outcome3 0.1927423 0.1927423
treatment2 0.2000000 0.2000000
treatment3 0.2000000 0.2000000
> lapply(lmod, function(x) coef(summary(x))[,1:2])
$mod1
Estimate Std. Error
(Intercept) 3.044522e+00 0.1708987
outcome2 -4.542553e-01 0.2021708
outcome3 -2.929871e-01 0.1927423
treatment2 1.337909e-15 0.2000000
treatment3 1.421085e-15 0.2000000
$mod2
Estimate Std. Error
(Intercept) 3.044522e+00 0.1708987
outcome2 -4.542553e-01 0.2021708
outcome3 -2.929871e-01 0.1927423
treatment2 1.337909e-15 0.2000000
treatment3 1.421085e-15 0.2000000
关于r - 从逻辑回归列表中提取系数的所有标准误差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13045032/
我已经训练了一个线性回归模型来以多输出方式进行预测。这是一个时间序列预测问题,根据一组输入来估计 future 12 个月的需求。在过去 - 如果我只预测一个输出值 - 我会简单地调用以下命令来访问模
我的应用程序对原始音频信号执行FFT(所有麦克风读数均为values中的16位整数值,即1024个单元)。它首先根据16位对读数进行归一化。然后提取频率为400Hz的幅度。 int sample_ra
我从包含相同语音内容的两个大约 30 秒的音频文件中提取了两个系列 MFCC 系数。音频文件从不同来源录制在同一位置。应该估计音频是否包含相同的对话或不同的对话。目前我已经测试了两个Mfcc系列的相关
我正在尝试使用两个自变量(批处理和方法)和一个因变量 (conc) 运行线性回归。当我运行回归时,我得到一个系数的 NA 值。当我更改模型中自变量的顺序时,NA 值显示为不同的变量。这是一个可重现的数
我想要的,大图:我想知道如何在 Java 中模仿 Mathematica 的 ExtendedGCD[...] 功能。有关该功能的信息可以在 here 中找到,但为了完整起见,我将对其进行简要描述。
我用 R 编写了这个套索代码,并且得到了一些 beta 值: #Lasso library(MASS) library(glmnet) Boston=na.omit(Boston) x=model.m
我有一个幅频响应点列表。振幅以分贝为单位给出。 任务是将此 AFR 列表导出为某些硬件 DSP 设备的一组系数。我知道此设备的文件格式。该设备的规范表明它需要 12288 个系数,并且 DSP 有 2
是否可以替换 lm 对象中的系数? 我认为以下会起作用 # sample data set.seed(2157010) x1 <- 1998:2011 x2 <- x1 + rnorm(length(
我正在尝试使用 lm.ridge 方法执行岭回归。我的问题是如何获得拟合模型的系数?我从调用中得到不同的结果: 模型$coef 系数(模型) 哪个是正确的?另外,为什么我从调用中得到不同的结果: co
以下代码片段死于 Eigen 断言: MatrixXd L; VectorXd x, b; ... ASSERT_MATRIX_EQ(L*x, b); 与, template void ASSERT
有没有办法从编码的图像和视频中轻松提取 DCT 系数(和量化参数)?任何解码器软件都必须使用它们来解码 block DCT 编码的图像和视频。所以我很确定解码器知道它们是什么。有没有办法将它们暴露给使
如何找到矢量 w 是多少,即垂直于分离平面? 最佳答案 我就是这样做的here .如果我没记错的话,这是基于 dual form 的SVM 优化的结果。 model = svmtrain(...);
我是 FFMPEG 的新手。我知道如何提取关键帧, 但现在我想提取那些 I 帧的 DC 系数。 您能否帮助编写 FFMPEG 命令的正确语法以获取 DC 系数? 问候 最佳答案 FFmpeg 命令不会
任何人都可以共享任何代码或可调用以从 HEVC 比特流中提取变换系数 (DCT/DST) 的函数吗? 我检查了 HM 16.0 的源代码。文件\source\Lib\TLibCommon\TComTr
我需要从 MPEG4 视频中提取有关运动矢量和 DC 系数的信息。我搜索了相关站点和主题,发现一个好的解决方案是使用 ffmpeg 编解码器的代码。尤其是 libavcodec/mpegvideo.c
我想删除sympy符号表达式中等于1的任何系数,例如:我希望 1.0x**2 成为 x**2 ,有办法做到吗?另外,如果可能的话,可以对整数进行舍入,例如将 2.0x**2 变为 2*x**2 最佳答
我想删除sympy符号表达式中等于1的任何系数,例如:我希望 1.0x**2 成为 x**2 ,有办法做到吗?另外,如果可能的话,可以对整数进行舍入,例如将 2.0x**2 变为 2*x**2 最佳答
我最近的任务是将 PMML 解析回 R 模型。 (我进行了广泛搜索,没有库可以为您进行这种转换。)我正在尝试将包含多项逻辑回归的 PMML 转换回 R 模型,但我不知道如何转换任何PMML 文档中保存
当使用 pandas statsmodels 的 .summary() 函数时,OLS 回归结果包括以下字段。 coef std err t P>|t| [
我正在 STM32F4 微 Controller 上使用 CMSIS 库开发 PID Controller 。我实在无法理解PID参数的归一化。现在我有了 PID Controller 的三个 Kp、
我是一名优秀的程序员,十分优秀!