Download presentation
Presentation is loading. Please wait.
1
Using NLOGIT for Discrete Choice Modeling
William Greene Department of Economics Stern School of Business
2
Getting Started
3
Upload Your Project File
4
Contents of the Project File
Open folder Name Sample size Variables
5
Use File:New/OK to open an Editing Window
7
Type Commands in the Editor
8
Use File:Open to open a command file
10
Generic Command Format
Verb ; specification ; specification ; … $ Every command ends with $ Use as many lines as desired. Use spaces wherever desired. Capital or lower case – no matter. Example: Create ; x = z*y + log(Income) $ Example; PROBIT ; Lhs = doctor ; Rhs = one,X $
11
Important Commands: SAMPLE ; first - last $
Sample ; All $ CREATE ; Variable = transformation $ Create ; loginc = Log(income) $ Create ; logincF = .5*loginc*female $ Create ; … any algebraic transformation $
12
Name Conventions CREATE ; name = any result desired $
Name is the name of a new variable No more than 8 characters in a name The first character must be a letter or _ May not contain etc. May contain _
13
Model Command Model ; Lhs = dependent variable
; Rhs = list of independent variables $ Regress ; Lhs = income ; Rhs = ONE,age,educ,female $ ONE requests the constant term Models are REGRESS, PROBIT, POISSON, LOGIT, TOBIT, … and over 100 others. All have the same form.
14
The Go Button
15
“Submitting” Commands
One line command Place cursor on that line Press “Go” button More than one line command and/or more than one command. Highlight all lines (like any text editor)
16
Describe the data DSTAT ; Rhs = * $ Kernel Estimator KERNEL ; Rhs = income $ or KERNEL ; If[female = 1 & married = 1] ; Rhs = income ; Title=Kernel Estimator for Married Women$
18
Model Commands Generic form:
Model name ; Lhs = dependent variable ; Rhs = independent variables $ Almost all models require ;Lhs and ;Rhs. Rhs should generally include ONE to request a constant term. Models have different other required specifications Many optional specifications.
19
Compute a Regression Use the whole sample REGRESS ; Lhs = income
; Rhs = One,age educ,female $ Use part of the sample REGRESS ; If [ married = 1] ; Lhs = income ; Rhs = one,age,educ,female $ The constant term in the model
21
Other Models Other Types of Models Use the whole sample
REGRESS ; Lhs = income ; Rhs = One,age educ,female $ LOGIT ; Lhs = doctor LOGIT ; If [ married = 1] ; Lhs = doctor ; Rhs = one,age,educ,female ; RPM ; Fcn = one(n),age(n),educ(n)$ Other Types of Models
22
Interactions and Nonlinearities
Regress ; Lhs = loginc ; Rhs = One,age,age^2,educ, female, female*educ $
23
Standard Three Window Operation
Commands typed in editing window Project window shows variables Results appear in output window
24
Model Results Regress ; Lhs = income ; Rhs =One,age,educ,female
; Res = e $ (Regression with residuals saved) Produces results: Displayed results in output Variables added to data set Matrices Named Scalars
25
Output Window
26
New Variable Regress;Lhs=income ;Rhs=One,age,educ,female ; Res = e $
? We can now manipulate the new ? variable created by the regression. Namelist ; z = married,hhkids $ Create;esq = e*e / (sumsqdev/nreg) – 1 $ Regress; Lhs = esq ; Rhs=One,z $ Calc ; List ; LMTstHet = nreg*Rsqrd $
27
Saved Matrices B=estimated coefficients and VARB=estimated asymptotic covariance matrix are saved by every model command. Different model estimators save other results as well. Here, we manipulate B and VARB to compute a restricted least squares estimator the hard way. REGRESS ; Lhs = income ; Rhs=One,age,educ,female $ NAMELIST ; X = One, age,educ,female $ MATRIX ; R = [0,1,1,1] ; q = [1] ; XXI=<X'X> ; m = R*B - q ; C=R*XXI*R' ; bstar = B - XXI*R'*<C>*m ; Vbstar=VARB - ssqrd*XXI*R'*<C>*R*XXI $ DISPLAY ; Parameters = bstar ; Labels = x ; Covariance = vbstar $
29
Saved Scalars Model estimates include named scalars. Linear regressions save numerous scalars. Others usually save 3 or 4, such as LOGL, and others. The program on the previous page used SSQRD saved by the regression. The LM test two pages back used NREG (the number of observations used), RSQRD (the R2 in the most recent regression), and sumsqdev.
30
Save Your Work When You Exit
31
The Project and Command files will be waiting for you when you restart the program.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.