Presentation is loading. Please wait.

Presentation is loading. Please wait.

How to use Limdep?. Three important windows 1.Project window (you can check e.g. the variable and matrix lists and how the variables are coded) 2. Editing.

Similar presentations


Presentation on theme: "How to use Limdep?. Three important windows 1.Project window (you can check e.g. the variable and matrix lists and how the variables are coded) 2. Editing."— Presentation transcript:

1 How to use Limdep?

2 Three important windows 1.Project window (you can check e.g. the variable and matrix lists and how the variables are coded) 2. Editing window (you write your codes and commands) 3. Output window (you can see your results) You can change between these 3 windows by using the ”window button” in the tool bar.

3 The three important windows

4 Project window

5 Click the variable folder and you see all the variables….

6 Click one of the variables and you will see how the variables are coded…

7 How to find text/command file (Editing window)? Go to the FILE ⇨ NEW…. ⇨ text/command file ⇨ OK Here you can write all your commands. Remember to save this file often. Otherwise you can loose unsaved coding if program shuts up….

8 How to run commands? Highlight the row(s) you will run in the command file (like in any text editor) and press the green ”GO” button.

9 How to run commands? Limdep will then run the row(s) you have highlighted and automatically show the results in the output window. Use ”window button” in the tool bar to switch back to the code/comando file in the editing window.

10 How to save your codes? Go to the FILE ⇨ SAVE AS….you will save your codes in your own document map as a Limdep file with the ending ”lim”. IF you want to save the variables you have created so you do not have to read in data and run your whole code/command file (that creates the variables) next time you will work with your project, you can save it as your project file with the ending ”lpj”. Go to the FILE ⇨ SAVE PROJECT AS…. So, lim-file is a file for your codes and lpj-file is a data set file.

11 Read in an Excel file READ; file = “C:\My Documents\Data\Survey.xls”; FORMAT=xls; NAMES$ READ;file="\\hgu.gu.se\empl\econ\elilam\My Documents\Teaching\Limdep course 2009\Closed.xls";format=xls;names$ The NAMES command specifies that the first row contain variable names. In most cases not necessary to specify this.

12 Load in a project file LOAD;file="\\hgu.gu.se\empl\econ\elilam\My Documents\Teaching\Limdep course 2009\CVM.lpj"$ In that case your load in an existing project file with variables that are already created. This file has the ending ”lpj”. If your data set is too large, you will get a message: ”Error 7: Read-data set is too large. Expand data area (Project….) Go to ”PROJECT” →”Settings” → Add 2 zeros in ”Number of cells” →OK → OK →Read in data again.

13 General information: All the commands end with $ All the commands are separated with ; All the variables can only have 8 charachters The first character must to be a letter

14 Basic commands (1) ”RESET” command RESET$ is used to clear all data and start a new session. Start your text/command file with Reset before you read in e.g. an excel file or load in a project file (lpj). Sometimes when Limdep get stuck or the program breaks down it helps to start from the beginning by using the ”Reset” command and read in the data again/load down the project file again.

15 Basic commands (2) ”REJECT” command REJECT is used to reject subsets of data. For example if you have missing data, (e.g. if some of the respondents have not stated their income or WTP). Missing data is in Limdep denoted by -999. Not rejecting missing observations could therefore seriously affect your results.

16 Basic commands (3) Another good command to reject all missing observations is SKIP$ which rejects every row that has a missing value in a variable that is used in the estimations. Use Skip$ in all your regressions!

17 Basic commands (4) Reject is also very good to use when you will estimate something for a subset of the data you have: For example: Rejcet;age<20$ (you will only include those older than 19) Reject;female=1$ (you will only include males) Reject;female#1$ (you will only include females)

18 Basic commands (5) You can also first create a variable and the reject all the respondents who do not fulfill the requirements of the variable. For example: Create; if (WTP=0)zeroWTP=1$ Reject;zeroWTP#1$

19 Basic commands (6) The command Sample;all$ is used to restore the data set. For example if you have rejected a subset of the data, but then wish to use the whole set again, you can use Sample;all$. Start all your commands with Sample;all$ since we often reject some observations. For example: Sample;all$ Skip$ Reject;WTP=-999$ Regress;lhs=WTP;rhs=one,female,univers$

20 Basic commands (7) It is good (and safe) to create all your variables before you write down the regressions. If you create variables after you have used REJECT command the variables will be based on a subsample and not on the whole sample. IF you create new variables when you write the code for a regression, remeber to start with Sample;all$, then create the new variable(s) you need for the regression, and first after that use the reject command for missings observations/to get a sub sample.

21 Basic commands (8 ) CREATE command creats variables. You can use +, -, /, *, >, =, <=, ^. For example: Create; Sum = x1 + x2$ Create; x3 = (x1 + x2)/(x1*x2)$ Create; x4 = x2^3$ Create;age=2016-1977$ Create;logWTP=log(WTP)$ Create;fishfem=fish*female$ (interaction term between an attribute ”fish” and variabel ”female”)

22 Basic commands (9 ) CREATE command can also be conditional: If the variable does not exists before write: Create; IF (logical expression) name = expression$ For example: Create;if(q3F7=4)university=1$ Create;if(sister=1 & brother=1)bothgend=1$ Create;if(age>19&age<25)age2024=1$ When the condition is not met, Limdep makes the ”other cathegory” automatically to be equal to 0.

23 Basic commands (10) If the variable already exists in your data set use ELSE commad since otherwise Limdep will not change the existing value of the existing variable to zero: Create;if(q13=1)bigtown=1;(else)bigtown=0$ Create;if(age>65)pension=1;(else)pension=0$ With ELSE command you ”force” the Limdep set the variable equal to zero if the condition is false.

24 Basic commands (11 ) Remeber that you must keep the missing observations as missing. If you make dummies Limdep will change even the missing observations to zeros. Create;if(QF4=1)primary=1$ Create;if(QF4=2)college=1$ Create;if(QF4=4)univ=1$ Create;if(QF4=-999)primary=-999$ Create;if(QF4=-999)college=-999$ Create;if(QF4=-999)univ=-999$

25 Descriptive statistics

26 Descriptive statistics (1) DSTAT; RHS = x1, x2$ Gives mean values, standard deviations, min and max values, number of observations and missing observations. Dstat;rhs=logbid$ Descriptive Statistics All results based on nonmissing observations. ==================================================================== Variable Mean Std.Dev. Minimum Maximum Cases Missing ==================================================================== All observations in current sample --------+--------------------------------------------------------------------- LOGBID | 7.17769 1.19814 4.60517 8.85367 562 0 Note that DSTAT actually bypasses missing observations, whether or not the SKIP command is used.

27 Descriptive statistics (2) To obtain the correlation matrix we write: DSTAT; RHS = x1, x2; OUTPUT = 2$

28 Descriptive statistics (3) Histogram: Histo;rhs=x1,x2$ Plot 2 variables against each other: Plot;lhs=x1;rhs=x2$ LHS variable will be the horisontal-axis variable Plot;lhs=x1;rhs=x2;fill$ (fills the dots with a line)

29 Descriptive statistics, histogram (4)

30 Regressions

31 Regressions(1) OLS: Regress;lhs=dependent variable;rhs=independent variables; other specifications$ For example: Regress;lhs=wtp;rhs=one,men,univ,age$ Other specifications are e.g. if we will correct for heteroskedasticity: Regress;lhs=wtp;rhs=one,men,univ,age;hetero$ ONE is the intercept in the model.

32 Regressions(2) Probit: Probit;lhs=dependent variable;rhs=independent variables; other specifications$ For example: Probit;lhs=Yes;rhs=one,bid$ (as for closed ended CVM) Probit;lhs=zeroWTP=one,female,income,age;marg$ (marg is to get marginal effects)

33 Regressions(3) -> sample;all$ --> reject;yes=-999$ --> reject;bid=-999$ --> probit;lhs=yes;rhs=one,bid$ Normal exit from iterations. Exit status=0. IMPORTANT that you will get this message!!

34 Regressions(4) +---------------------------------------------+ | Binomial Probit Model | | Maximum Likelihood Estimates | | Dependent variable YES | | Weighting variable None | | Number of observations 557 | | Iterations completed 4 | | Log likelihood function -280.4654 | | Number of parameters 2 | | Info. Criterion: AIC = 1.01424 | | Finite Sample: AIC = 1.01428 | | Info. Criterion: BIC = 1.02976 | | Info. Criterion:HQIC = 1.02030 | | Restricted log likelihood -364.2292 | | McFadden Pseudo R-squared.2299755 | | Chi squared 167.5276 | | Degrees of freedom 1 | | Prob[ChiSqd > value] =.0000000 | | Model estimated: Nov 24, 2009, 02:33:33PM | | Hosmer-Lemeshow chi-squared = 28.74046 | | P-value=.00035 with deg.fr. = 8 |

35 Regressions(5) Results: +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ +--------+Index function for probability | |Constant| 1.61309***.12171031 13.254.0000 | |BID | -.01971***.00159758 -12.335.0000 59.023339| +--------+------------------------------------------------------------+ | Note: ***, **, * = Significance at 1%, 5%, 10% level. | +---------------------------------------------------------------------+

36 Regressions(6) Logit: Logit;lhs=dependent variable;rhs=independent variables; other specifications$ For example: Logit;lhs=Yes;rhs=one,bid$ Logit;lhs=zeroWTP;rhs=one,female,kids,age,univ;marg$ (to get marginal effects)

37 Regressions(7) Other useful commands considering choice experimets: -Nlogit= Multinomial logit -Nlogit and Rpl=Random parameter logit (mixed logit) (older) OR -RPLOGIT= Random parameter logit (mixed logit) (newer) -Nlogit and LCM= Latent class logit (older) OR -LCLOGIT= Latent class logit (newer)

38 Regressions(8) Other commands you will need during this course when we estimate choice experimets: -GMXLOGIT= Generalized Mixed Logit (only new version) This is the one we use when estimating WTP space model.

39 CALC command (1) CALC command: Calc; name = result$ Calc;incb=xbr(income)$ (mean of income variable) Calc;list;med(WTP) $ (median of variabeln WTP) Or conditional Calc; if (logical expression) name = result$ For example: Calc;if(b2>100)ratio=b2/b3$

40 Calc command (2) CALC command can also be used to estimate WTP: Probit;lhs=yes;rhs=one,bid$ Calc;list;meanWTP=-b(1)/b(2)$ To be able visually inspect the variables you have calculated you have to add the command LIST. (LIST can also be used alone if you want to see e.g. one variable (x1) in the output window. In that case write:List;x1$)

41 Wald command (1) sample;all$ skip$ reject;bid=-999$ probit;lhs=yes;rhs=one,bid$ wald;labels=b1,b2;start=b;var=varb; fn1=-(b1/b2)$ Where b1= one and b2=bid You can also write labels=b_2 (IF 2 variables) so you do not have to repeat them. Practical if many variables…we will use this in CE when we have several attributes.

42 Wald command (2) +-----------------------------------------------+ | WALD procedure. Estimates and standard errors | | for nonlinear functions and joint test of | | nonlinear restrictions. | | Wald Statistic = 609.83640 | | Prob. from Chi-squared[ 1] =.00000 | +-----------------------------------------------+ +--------+--------------+----------------+--------+--------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| +--------+--------------+----------------+--------+--------+ |Fncn(1) | 81.8564*** 3.31471382 24.695.0000 | +--------+-------------------------------------------------+ | Note: ***, **, * = Significance at 1%, 5%, 10% level. | +----------------------------------------------------------+

43 Wald command (3) Wald in choice experiment An example of multinomial logit: sample;all$ reject;choice2=-999$ nlogit;lhs=choice2;choices=alt1,alt2;model: U(alt1)=aopt+bidag*idag+bequal*equal+bcost2*cost2/ U(alt2)=bidag*idag+bequal*equal+bcost2*cost2$ wald;start=b;var=varb;labels=4_b; fn1=-(b2/b4); fn2=-(b3/b4)$ (4 variables inclusive the intercept, here opt-out)


Download ppt "How to use Limdep?. Three important windows 1.Project window (you can check e.g. the variable and matrix lists and how the variables are coded) 2. Editing."

Similar presentations


Ads by Google