Original link: http://tecdat.cn/?p=6295
Not all results / dependent variables can be modeled using linear regression were reasonable. Perhaps the second most common regression model is logistic regression, it applies to binary outcome data. How to calculate the R-squared logistic regression model?
McFadden R squared
In R, GLM (Generalized Linear Model) command is a standard command is used to fit logistic regression. As far as I know, the object does not fit glm directly to you any pseudo R-squared value, but can be easily calculated measure of McFadden. To this end, we first fitted model we are interested in, and then only contain null model intercept. Then we can use the model number R-squared fit McFadden likelihood values calculated:
In order to understand the strength required to obtain a predictor McFadden R-squared values, we will use a single binary data to simulate the X-prediction, we first attempt to P (Y = 1 | X = 0) = 0.3 and P (Y = 1 | X = 1) = 0.7:
Therefore, even if the probability of X to Y = quite a strong impact, McFadden R2 of only 0.13. To increase it, we must make the P (Y = 1 | X = 0) and P (Y = 1 | X = 1) be more different:
Even if the X P (Y = 1) changes from 0.1 0.9, McFadden R-squared of only 0.55. Finally, we will try to values of 0.01 and 0.99 - I would call a very powerful effect!
Now we have a value closer to 1.
Two packet data with a single data
data < - data.frame(s = c(700,300),f = c(300,700),x = c(0,1)) SFX 1 700 300 0 2 300 700 1
In order to make the data suitable for logistic regression model in R, we can transfer the response to the glm function:
We will now grouped Bernoulli binomial data into the data, and for the same logistic regression model.
As expected, we get the same from the packet data box, parameter estimation and inference.
We see R-squared packet data model is 0.96, and a single data model R-squared of 0.12.
Thank you for reading this article, you have any questions please leave a comment below!
Welcome attention to micro-channel public number for more information about data dry!