| / Home |
logist performs logistic regression.
» help logist LOGIST Fit logistic regression model. [BETA,MU,DEV,DF,SE]=LOGIST(Y,N,X,OFFSET,PRINT) All input and output arguments except Y are optional. Y - response vector containing binomial counts N - number of trials for each count. Y is assumed to be binomial(p,N). X - matrix of covariates, including the constant vector if required OFFSET - offset if required PRINT - enter any argument if output required each iteration BETA - regression parameter estimates SE - associated standard errors MU - fitted values DEV - residual deviance DF - residual degrees of freedom
A simple logistic regression. The counts are out of 10 in each case and there is one covariate.
» y=[2 0 3 1 5 5 6 9 5 9];
» n=[10 10 10 10 10 10 10 10 10 10];
» x=(1:10)';
» X=[ones(10,1) x]
X =
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
» [beta mu dev df se]=logist(y,n,X)
beta =
-2.5800
0.4202
mu =
1.0342
1.4936
2.1092
2.8921
3.8249
4.8530
5.8937
6.8602
7.6884
8.3507
dev =
13.5505
df =
8
se =
0.5839
0.0923
Here is the same regression using a different statistical program, namely R. The same results are obtained.
> y <- c(2,0,3,1,5,5,6,9,5,9);
> n <- rep(10,10);
> x <- 1:10
> out <- glm(y/n ~ x,family=binomial,weights=n)
> summary(out)
Call:
glm(formula = y/n ~ x, family = binomial, weights = n)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8472 -1.0761 0.3411 0.7306 1.6120
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.58000 0.58390 -4.419 9.94e-06 ***
x 0.42020 0.09228 4.554 5.27e-06 ***
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 40.848 on 9 degrees of freedom
Residual deviance: 13.551 on 8 degrees of freedom
AIC: 39.455
Number of Fisher Scoring iterations: 4
Collett, D. (2002). Modelling Binary Data, 2nd edn. Chapman & Hall, London.