Sidebar: As a general rule, one should never ever attach(data) when data is
an argument to a function that takes a formula. You will confuse R. Best,
Olivia
On 7/15/06, Gary King <king(a)harvard.edu> wrote:
you don't need to import results from Zelig into excel to compute
quantities of interest, since Zelig will do it for you automatically. See
the setx() and sim() steps.
Gary King
On Sat, 15 Jul 2006, dysgraphia2325(a)lycos.com wrote:
Using Win XP, current R and Zelig.
I am new to R and Zelig.
The ability to program Zelig/R is valuable....not available in EasyReg
In order to familiarize myself with the programs I ran the ordered
probit
model in Zelig then in EasyReg using the same
dataset.
Here are output details for my R session:
> myFile = read.table(file = "C:/TestSetForR.txt",header=T)
> attach(myFile)
> z.out <- zelig(as.factor(Grade_1_8) ~ X1 + X2 + X3 + X4, model =
"oprobit", data = myFile)
summary(z.out)
Call:
zelig(formula = as.factor(Grade_1_8) ~ X1 + X2 + X3 + X4, model =
"oprobit", data = myFile)
Coefficients:
Value Std. Error t value
X1 -0.054702 0.018865 -2.900
X2 0.005183 0.001054 4.919
X3 0.085056 0.016026 5.307
X4 -0.088101 0.014033 -6.278
Intercepts:
Value Std. Error t value
1|2 -4.857 1.006 -4.830
2|3 -4.383 1.003 -4.370
3|4 -4.055 1.002 -4.048
4|5 -3.775 1.001 -3.770
5|6 -3.519 1.001 -3.516
6|7 -3.093 1.000 -3.093
7|8 -2.516 1.000 -2.517
Residual Deviance: 3843.73
AIC: 3865.73
################################################
Here are output details for the same data run in EasyReg.
EasyReg International [April 2, 2006]
Session date: Friday July 14, 2006
Session time: 07:48:11
----------------------------------------------
Ordered Probit model:
Dependent variable:
Y = Grade_1_8
Characteristics:
Grade_1_8
First observation = 1
Last observation = 1009
Number of usable observations: 1009
Minimum value: 1.0000000E+000
Maximum value: 8.0000000E+000
Sample mean: 5.2893954E+000
This variable is integer valued.
A discrete dependent variable model is suitable.
X variables:
X(1) = X1
X(2) = X2
X(3) = X3
X(4) = X4
X(5) = 1
Model:
P(Y-1=0|x) = F(-b'x)
P(Y-1=1|x) = F(-b'x+exp(b(6)))- F(-b'x)
For j=2,..,m-1,
P(Y-1=j|x) = F(-b'x+exp(b(6))+..+exp(b(5+j)))
- F(-b'x+exp(b(6))+..+exp(b(4+j)))
and
P(Y-1=m|x) = 1 - F(-b'x+exp(b(6))+..+exp(b(4+m)))
where m =7, b'x = b(1)x(1)+..+b(5)x(5), and
F(u) = c.d.f. of N(0,1) distribution.
Newton iteration succesfully completed after 30 iterations
Last absolute parameter change = 0.0001
Last percentage change of the likelihood = -0.0459
Maximum likelihood estimation results:
Variable Par. ML estimate t-value [p-value]
x(1)=X1 b(1) -0.0547016 -2.87 [0.00407]
x(2)=X2 b(2) 0.0051827 4.75 [0.00000]
x(3)=X3 b(3) 0.0850551 5.29 [0.00000]
x(4)=X4 b(4) -0.0881011 -6.25 [0.00000]
x(5)=1 b(5) 4.8565051 4.74 [0.00000]
b(6) -0.7482279 -7.65 [0.00000]
b(7) -1.1145713 -10.92 [0.00000]
b(8) -1.2712482 -12.77 [0.00000]
b(9) -1.3635656 -13.48 [0.00000]
b(10) -0.8530407 -11.26 [0.00000]
b(11) -0.5500365 -8.14 [0.00000]
[The two-sided p-values are based on the normal approximation]
Log likelihood: -1.05015155949E+003
Sample size (n): 1009
Information criteria:
Akaike: 2.103373
Hannan-Quinn: 2.123736
Schwarz: 2.156974
In the main the independent coefficients and t-values were quite close
in value
except that
the intercepts are dissimilar...not unexpected as
the contrasts are
defined differently, as differences.
As shown above, EasyReg provides expressions for
the probabilities for
the various levels viz
P(Y-1=0|x) = F(-b'x)
P(Y-1=1|x) = F(-b'x+exp(b(6)))- F(-b'x)
For j=2,..,m-1,
P(Y-1=j|x) = F(-b'x+exp(b(6))+..+exp(b(5+j)))
- F(-b'x+exp(b(6))+..+exp(b(4+j)))
and
P(Y-1=m|x) = 1 - F(-b'x+exp(b(6))+..+exp(b(4+m)))
where m =7, b'x = b(1)x(1)+..+b(5)x(5), and
F(u) = c.d.f. of N(0,1) distribution.
This is useful for me as I enter these equations into an Excel
spreadsheet, useful
to test holdout samples and for teaching purposes for
example.
My question: in the Zelig documentation does
there exist equivalent
equations to calculate probabilities of the different
levels?
Any advice appreciated!....Cheers, Peter.
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options:
http://lists.gking.harvard.edu/?info=zelig
Zelig program information:
http://gking.harvard.edu/zelig/