R中的多项式的拟合值:参考类别的系数?

编程入门 行业动态 更新时间:2024-10-21 20:31:28
本文介绍了R中的多项式的拟合值:参考类别的系数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用nnet软件包中的函数multinom来运行多项式逻辑回归.

I'm using the function multinom from the nnet package to run a multinomial logistic regression.

在多项逻辑回归中,据我所知,系数是响应概率与参考响应概率之比的对数的变化(即ln(P( i )/P( r ))= B 1 + B 2 * X ...其中i是一个响应类别,r为参考类别,而X是一些预测变量).

In multinomial logistic regression, as I understand it, the coefficients are the changes in the log of the ratio of the probability of a response over the probability of the reference response (i.e., ln(P(i)/P(r))=B1+B2*X... where i is one response category, r is the reference category, and X is some predictor).

但是,fit(multinom(...))会为每个类别(甚至是参考类别 r )生成估算值.

However, fitted(multinom(...)) produces estimates for each category, even the reference category r.

编辑示例:

set.seed(1) library(nnet) DF <- data.frame(X = as.numeric(rnorm(30)), Y = factor(sample(letters[1:5],30, replace=TRUE))) DF$Y<-relevel(DF$Y, ref="a") #ensure a is the reference category model <- multinom(Y ~ X, data = DF) coef(model) # (Intercept) X #b 0.1756835 0.55915795 #c -0.2513414 -0.31274745 #d 0.1389806 -0.12257963 #e -0.4034968 0.06814379 head(fitted(model)) # a b c d e #1 0.2125982 0.2110692 0.18316042 0.2542913 0.1388810 #2 0.2101165 0.1041655 0.26694618 0.2926508 0.1261210 #3 0.2129182 0.2066711 0.18576567 0.2559369 0.1387081 #4 0.1733332 0.4431170 0.08798363 0.1685015 0.1270647 #5 0.2126573 0.2102819 0.18362323 0.2545859 0.1388516 #6 0.1935449 0.3475526 0.11970164 0.2032974 0.1359035 head(DF) # X Y #1 -0.3271010 a

要计算第1行的响应 b 和响应 a 之间的预测概率比,我们计算exp(0.1756835+0.55915795*(-0.3271010)) = 0.9928084.而且我看到这对应于第1行的拟合P(b)/P(a)(0.2110692/0.2125982 = 0.9928084).

To calculate the predicted probability ratio between response b and response a for row 1, we calculate exp(0.1756835+0.55915795*(-0.3271010))=0.9928084. And I see that this corresponds to the fitted P(b)/P(a) for row 1 (0.2110692/0.2125982=0.9928084).

参考类别的拟合概率是否通过代数计算(例如,0.2110692/exp(0.1756835+0.55915795*(-0.3271010)))?

Is the fitted probability for the reference category calculated algebraically (e.g., 0.2110692/exp(0.1756835+0.55915795*(-0.3271010)))?

有没有办法获得参考类别的预测概率方程?

Is there a way to obtain the equation for the predicted probability of the reference category?

推荐答案

我有相同的问题,环顾四周后,我认为解决方案是: 给定3个类:a,b,c和该算法输出的fitted(model)概率pa,pb,pc,您可以从以下3个等式重建这些概率:

I had the same question, and after looking around I think the solution is: given 3 classes: a,b,c and the fitted(model) probabilities pa,pb,pc output by the algorithm, you can reconstruct those probabilities from these 3 equations:

log(pb/pa) = beta1*X log(pc/pa) = beta2*X pa+pb+pc=1

其中beta1,beta2是coef(model)输出的行,而X是您的输入数据.

Where beta1,beta2 are the rows of the output of coef(model), and X is your input data.

使用这些方程式,您将得出:

Playing with those equations you get to:

pb = exp(beta1*X)/(1+exp(beta1*X)+exp(beta2*X)) pc = exp(beta2*X)/(1+exp(beta1*X)+exp(beta2*X)) pa = 1 - pb - pc

更多推荐

R中的多项式的拟合值:参考类别的系数?

本文发布于:2023-07-27 23:08:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1225184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多项式   系数   类别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!