We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
STATA COMMANDS TO RUN REGRESSION
Ensure your data is in Excel format before you begin.
Open the STATA workbook Click ‘File’ on the menu bar Point the cursor on ‘Import’ Click on Excel spreadsheet from the dropdown list In the ‘Import Excel’ dialogue box, click on browse to open the file/data to be imported Check the box by the side of ‘Import first row as variable name’ Click ok, and the excel file will be imported to stata workbook In the command section, declare the data as panel data: xtset ID YEAR, yearly, and press enter. For descriptive statistics, type the command: xtsum and list all the variables in the order you wish them to appear and press enter, but preferably begin with dependent variable(s) (DV) followed by independent variables (IVs). For regression, type the command: regress and list all the variables in the order you wish them to appear and press enter, but preferably begin with DV followed by IVs. Where there is need to deal with outliers, type winsor2, enter the dependent variable, type replace, give a space and type cut; open bracket and indicate the percentage of outliers you wish to cut and the percentage to be retained, e.g. winsor2 ROE, replace cut (5 95). 5 is the percentage of outliers to be removed and 95 the percentage to be retained. You can adjust these percentages several times to get the desired result. For normality, enter in the command section: swilk and list all the variables and press enter To obtain the graph for normality, type predict resid, r and enter. Then type pnorm r and enter. For Spearman correlation, type in the command section spearman, give space and enter the dependent variable and independent variables. Where there are several dependent variables, enter each dependent variable with the independent variables one at a time. If you wish stata to star the correlation coefficients at a given level of significance, insert comma after the independent variables, type star(insert the desired level of significance, eg 0.01,0.05. 0.1) For Pearson correlation, type pwcorr dependent variable independent variables, sig star(desired level of significance) obs. Obs is the number of observations To check whether it is desirable to run a robust test if random effect is to be used: type hettest and enter. If the result is significant, then a robust test should be run, else no robust test. For multicollinearity (VIF): type collin and list the independent variables. For fixed effect (FE): xtreg DV, IVs, fe then enter. To save the result: estimate store fe) For random effect (RE): xtreg DV, IVs, re then enter. To save the result: estimate store re) For Hausman test, type hausman fe re then enter. If the result is significant, use FE, else run a Langragian test to decide whether to use RE or OLS For Langragian test: type xttest0. If the result is significant use RE, else use OLS For robust test: xtreg DV IVs, re vce (robust)