[英]Logistic regression in matlab using mnrfit
I'm trying to use the mnrfit
function but I get the error我正在尝试使用
mnrfit
函数,但出现错误
If Y is a column vector, it must contain positive integer category numbers.
. .
My data is in a double and my Y values are floats , eg 0.6667.我的数据是双精度的,我的 Y 值是浮点数,例如 0.6667。 Is there a way that I can adjust my data to be able to use the mnrfit function?
有没有办法调整我的数据以便能够使用 mnrfit 函数?
Thanks in advance!提前致谢! An unexperienced beginner
一个没有经验的初学者
Y
should be a "nominal outcome", ie non-continuous, to use mnrfit
. Y
应该是使用mnrfit
的“标称结果”,即非连续mnrfit
。 We don't need to turn Y
into integers, just categoricals. 我们不需要将
Y
变成整数,只需要分类即可。 A categorical array is discrete as far as MATLAB is concerned, regardless whether the categories are represented by double values. 就MATLAB而言,分类数组是离散的,无论类别是否用双精度值表示。
X = rand(5,3); % Predictors (should be double or single)
Y = rand(5,1); % Response (doubles, will cause error)
B = mnrfit( X, Y )
% ERROR: If Y is a column vector, it must contain positive integer category numbers.
B = mnrfit( X, categorical(Y) )
% No error, regression matrix B is output successfully.
Be careful , if you're expecting a continuous response variable (hence why Y
is a vector of doubles) then mnrfit
may not be suitable in the first place! 请注意 ,如果您期望一个连续的响应变量(因此,为什么
Y
是双精度的向量),那么mnrfit
可能不合适!
Note the valid data types are specified in the docs 请注意,有效数据类型在docs中指定
Y can be one of the following:
Y可以是以下之一:
An n-by-k matrix, where Y(i,j) is the number of outcomes of the multinomial category j for the predictor combinations given by X(i,:).
n×k矩阵,其中Y(i,j)是X(i,:)给出的预测变量组合的多项式类别j的结果数。 In this case, the number of observations are made at each predictor combination.
在这种情况下,在每个预测变量组合处进行观察的次数。
An n-by-1 column vector of scalar integers from 1 to k indicating the value of the response for each observation.
标量整数从1到k的n×1列向量,指示每个观察的响应值。 In this case, all sample sizes are 1.
在这种情况下,所有样本大小均为1。
An n-by-1 categorical array indicating the nominal or ordinal value of the response for each observation.
一个n×1类别数组,指示每个观察结果的响应的标称值或序数值。 In this case, all sample sizes are 1.
在这种情况下,所有样本大小均为1。
I have quick question when I use "B = merit( X, categorical(Y) )" I am getting a negative Beta value but the actual Beta value is positive of what I got.当我使用“B = Merit(X, categorical(Y))”时,我有一个快速的问题,我得到了一个负的 Beta 值,但实际的 Beta 值是我得到的正值。 EX) actual Beta = 50 , -90 , 8 what I am getting= -50, 90 ,-8
EX) 实际 Beta = 50 , -90 , 8 我得到的 = -50, 90 ,-8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.