Sensitivity Analysis of Regression Models using Stata

Let us see how we can conduct sensitivity analysis using Stata for regression models and coefficients from different types of regression models and also for various approaches to statistical analysis. Enroll for a private and instructor led course to learn more about Econometrics using Stata.

What is sensitivity analysis?

Sensitivity Analysis is a tool used in regression modeling to analyze how the different values of a set of independent variables affect a specific dependent variable under certain specific conditions. We can see that if the regression model is estimated from a given data, then we change the values of the independent variables from lowest to highest in different ranges and look into the values of the coefficients, we can determine how sensitive is the value of coefficientIn general, Sensitivity Analysis is used in a wide range of fields, ranging from biology and geography to economics and engineering.

It is especially useful in the study and analysis of a “Black Box Processes” where the output is an opaque function of several inputs. An opaque function or process is one which for some reason can’t be studied and analyzed. For example, climate models in geography are usually very complex. As a result, the exact relationship between the inputs and outputs are not well understood. (Full article on CFI)

Stata Commands for Sensitivity Analysis using Stata

Sensitivity Analysis using Stata can be conducted on various dimensions for various situations and analysis. This first code in Stata - senspec- provides sensitivity for quantitative classification variables.

'SENSPEC': module to compute sensitivity and specificity results saved in generated variables / senspec inputs a reference variable with two values and / a quantitative classification variable. It creates, as / output, a set of new variables, containing, in each / observation, the numbers

The second method for sensitivity analysis using Stata is for multiple imputation. The code for this objective in Stata is called -mimix-.

'MIMIX': module to perform reference based multiple imputation for sensitivity analysis of longitudinal clinical trials with protocol deviation / mimix imputes missing numerical outcomes for a longitudinal / trial with protocol deviation under distinct reference group / (typically

'MBSENS': module to compute Sensitivity metric for matched sample using McNemar's test / mbsens is used for calculating the binary sensitivity metric / (gamma) using McNemar's statistic using the matched sample as the / input. / KW: sensitivity / KW: matched samples / KW: Rosenbaum / KW:

'ISA': module to perform Imbens' (2003) sensitivity analysis / isa produces a figure for the sensitivity analysis developed by / Imbens (American Economic Review, 2003). Observational studies / cannot control for the bias due to the omission of unobservables. / The sensitivity

'GSA': module to perform generalized sensitivity analysis / gsa produces a figure for the sensitivity analysis similar to / Imbens (American Economic Review, 2003). Observational studies / cannot control for the bias due to the omission of unobservables. / The sensitivity analysis provides a

'EPISENS': module for basic sensitivity analysis of epidemiological results / episens provides basic sensitivity analysis of the observed / relative risks adjusting for unmeasured confounding and / misclassification of the exposure. episensi is the / immediate form of

'EPISENSRRI': module for basic sensitivity analysis for unmeasured confounders / episensrri provides basic sensitivity analysis of the apparent or / observed relative risks according to specified plausible / values of the prevalence of the unmeasured confounding / among exposed and

The above commands can be found in Stata by running the code:

findit sensitivity

I hope this simple Stata tutorial will be useful in learning more about Sensitivity Analysis.

Spurious Correlation From Tyler Vigen

Spurious Correlation or Spurious Correlation is the concept when strong association exist between unrelated variables. This makes a lot of sense to develop the caution that not all research findings can actually be theoretical viable so authors need a strong theoretical logic and practicality to define the association. Spurious regression has been very well document by Tyler Vigen (copy paste the link if the link does not seems to work) and there are very interesting updates. We recommend their portal be visited on regular basis for evidence of spurious correlation on interesting cases.

Few examples of Spurious Correlation from Vigel's portal are presented in the following:

Margarine consumption linked to divorce is the first interesting example of spurious correlation between two very unrelated but shocking alarming indicators from real life. It is also what BBC has mention in their report mentioning some other examples from Tyler Vigel portal. Nicolas Cage is one top Hollywoord star. He has been mentioned on Tyler Viger series on spurious correlation with an example mentioning Nic's movies appearances and people drowning in ponds in US States. Similarly, we find the spurious correlation showing the association between consumption of cheese and people died through folding in their bed sheets.

Similarly, we Economists needs very strong care to define relationship between economic indicators. Theoretically and technically very unrelated time series might appear to be very strongly correlated to each other but that might be of the no use case. Hence, defining an econometric models merely from available data does not meaning anything of significance but one should all the three components of research significance profoundly available for witness. These three indicators should include:

  1. Whether the relationship has any significance for solving a real world problem.
  2. The relationship found should be able to predict too much of the theory.
  3. The data should be very strongly related in process of generation. If the data generating processes are not correlated to each, the chances of spurious correlation or spurious regression again increases.

Now enjoy the few cases of Spurious correlation found by Vigel here:




Econometric Models Selection

In this simple outline on the issue of commonly raised douts on how to select an economic model, I would like to sum the issue in this 300 words article. Econometric Models Selection is one key problem for all. The model selection is based on the type of data and type of variables. Here, we mention an order following which helps an econometric model strategy development for us. We assume to use Panel data to develop econometric model selection strategy. Initially, to determine the right set of models, the nature of data structure for the panel data follows like this: A. Check data structure. 1. if N>T, then follows B series of steps. 2. If T>N, then follow the steps in C series.

If we assume the panel data has N sufficiently greater than T, then simple panel data or instrumental/GMM models for panel data can be achieved using the following order. This helps in Econometric Models selection looking into the key steps of the econometric analysis of the given panel data.

For Case 1, follow these steps.
B1. The first stepOLS
B3. Hausman
B4. Assumptions of RE or FE from B3.
B5. Endogeneity Tests
B6. Instrumental Regression
B7. GMM if seens dynamics/autocorrelation in B4.

If the data at hands is such that T is sufficiently larger than N, the panel time series structure will be evidenced and hence our econometric models selection strategy will follow the following procedures. The unit roots and cointegration is for panel time series data which are also sometimes considered as longer time panel data or longer panel data. In such cases, the time series properties in estimators are heavily observed and hence the steps to select an econometric models selection strategy will include these.
For Case 2, follow these steps
C1. Unit Root
C2. Cointegration

Writing First Program In R

R provides an extensive environment to write all kinds of modelling and statistical programs at the cost of expertise only while nominally the price is less than 0 for you if you can get to work with it because in spite of paying for purchasing costly software, you can earn using R programming skills while spending nothing. In the following article, we will begin our first program using R.
Let us assume we want to test if a number is positive or negative. To test this using R, we need to define what a positive number is and what a negative number looks like in Roman style. It is well known that positive numbers are greater than 0 or 0 itself is a positive number. On the other hands, a negative number is always less than 0. So define the following:
1) A positive number >0 or =0
2) A negative number <0
Now plan what R will require to know to state a number of any value, an integer, a whole number of a rational number being positive or negative. We need to program it. Each R program starts with the definition of the program.
We define our program showing if the number is positive or negative using R. The program will begin typing:
givelesettter = function(thenumber){
The left side of the above definition gives the name of the program, the right side defines what the actual is, function() states R will use left side name as a function to evaluate any number being positive or negative. The syntax will start after the curly braces {.
After that, we will define the above statements for showing the number if positive and should be at least equal to 0 or greater than 0. So we write the first condition to apply in R for our program to use which should be:
if (thenumber >= 0){
followed the curly braces to define the logical value stating the nature of the number which we defined as positive number in the following line of the programe.
theletter = "Positive Number"
and end this logic with the curly bracket as below.
After defining the logic for a number to be positive, we can define any number less than 0 as negative using the following piece of code.
if (thenumber < 0){
theletter = "A Negative Number"
We end up our code/program by stating return() argument which will display the results of a right inputted argument in the program and put an end of program curly bracket.
After writing our first simple program, we can do a practice of what have intended to by defining a number whether positive or negative. Before doing this, we have to save the written program in a text file with extension .R in the working directory of R. To use the function or program we will set the working directory using:
setwd(“address of working directory folder”) like setwd(“E:/rwork”)
And load the program by typing in R workspace as:
See the example program as given:
## is used to state that here Begins the Comments
## The code will look like the following
giveletter = function(thenumber){
if (thenumber >= 0){
theletter = "Positive Number"
if (thenumber < 0){
theletter = "A Negative Number"
Type the following example to test the working of the code.
giveletter(30) ## will return the response as Positive Number
giveletter(-30) ## will return the response as Negative Number

Cointegration, Unit Root and ARDL

Assume we have three variables. X1, X2 and X3. In all of the following three cases, we can to test all of X variables for unit root by at least two to three different tests. I personally recommend using ADF and KPSS to test the opposite null hypotheses. ADF's null is unit root series and KPSS is stationary series. Case 1. If all variables are I(0), we can use VAR as Johansen-Juselieus Cointegration Pre-condition is not satisfied. Case 2. If Two variables are I(1) but only one is I(0), or Two are I(0) and one is I(1), then ARDL from Pesaran (2001) is a feasible approach. Case 3. If at least one variable is I(2) and others are either I(0) or I(1) or mixed, the Toda-Yamamoto Causality can be applied after estimated the VAR. Note also, Toda-Yamamoto is a causality test not a test of short run or long run relationship and I usually assume Granger type causality by Toda-Yamamoto or Granger Causality itself has no dependent on VECM or Cointegration.

So in nutshell, If you variables all I(0), you can use VAR. If your all variables are I(1) or I(2), use JJ and Granger Causality. If all variables are mixed I(1) and I(0) but none is I(2), use ARDL and you can also use Granger Causality after running a VAR. If you have mixed order I(0), I(1) and I(2), use Toda Yamamoto Causality Test.

Step By Step Instructions for running ARDL in Eviews.

The steps to conduct ARDL cointegration test in Eviews are:

  1. Open your time series in Eviews
  2. Dfuller and KPSS your variables to check no variable is I(2)
  3. Single click on Dependent Variable (DV)
  4. Press Ctrl Key on keyboard, and click one on all Independent variables (IV) one by one
  5. Once DV and IV are are selected, Righ click on them
  6. A small caption open, Click on Open As Equation
  7. Another selection window appear, select maximum lags for DV and IV
  8. Click on Ok go get the ARDL estimates.

The screenshot will explain the required steps in simple to understand instructions.

Cointegration, Unit Root and ARDL

Cointegration, Unit Root and ARDL

We will share the complete the silenced one minute video tutorial in next part of this tutorial.

The step by step instruction of run ARDL using Stata can be:

  1. Open your data in Stata
  2. Tsset your data with the time variable
  3. Dfuller and KPSS your variables
  4. There should be no I(2) in the variables.
  5. Findit ardl code
  6. or scc install ardl
  7. Once installed, run the code as: ardl dv ivs, lags(#) ec
  8. ## should be replaced with a number of lags.

Stata Homework Solution

As experienced academics and freelancers in Stata, Econometrics and Statistics, having seens homework questions from around the countries, we understand there a few differences among the requirements for many different types of Stata homework and assignments. In this tutorial, we are offering a step by step guide to best solve any Stata homework or other problems. In case, you have technical problems in Stata, we can help you get the Stata Homework Help for better understanding the solutions. Ask our econometrics and statistics for additional guides to ensure you learn all the details of the contents from the Stata Homework and related learning objectives for Statistics or Econometrics.

There are many agencies around the internet with uncertain system of providing solutions for many questions related to Stata homework. We, provide a complete solution each Stata Homework with an academic aim that helping to learn the difficult parts of programming for Stata homework helps a student get more benefits from the Stata homework compared to mere buying already completed solutions for Stata homework. Our academic experts in Statistics and Econometrics provide complete Stata homework help and you can ask for a complete tutorial on each question for your Stata homework to make sure you learn everything related to the Stata homework, Econometrics or Statistics.

There can be difference in opinion on how to get best grades by doing Stata homework, but our experience as academics, researchers, freelancers and stata homework solution provides to more than 400 graduate and bachelor students in Economics, Statistics and Business studies reveal that best grades can be ensured through the following key process. It can be completed independently to answer all questions of the Stata homework or you can request our top ranked freelancers in Stata and Statistics to help you solve the difficult part of answering all questions in Stata homework related to programming and writing do files in Stata. Follow the steps outlined below to get a best mark on each of your Stata homework:

  1. Clearly define your objectives of the course before submitting your Stata homework to seek guidance or if you wish to learn to do it.
  2. Make sure you provide the full data clearly labbeled and annotated in Excel or Stata.
  3. The variables should be clearly labelled and named.
  4. The lecture notes related to the Stata homework should be provided. Each professor wish to see his students follow his lessons and that they follow additional readings to learn.
  5. This needs you should highlight what specific book, research article or any tutorial on the web was referred to by the professor before givin you the details of Stata homework.
  6. Make sure you provide the lab and workshop details, data and codes already used by the professor or workshop instructor before you got your Stata homework.
  7. You should clearly specify the final date of submission of the assignments so we can set the deadline two days before the final date of submission of Stata homework. This is to ensure we complete the revisions if you need if your professor is willing to provide initial feedback on the solutions of the Stata homework
  8. You should specify the budget for the solution of Stata homework so we can send a clear proposal related to deadline, proposed solution and the fees for your Stata homework. This helps in making sure a complete agreement is settled between you and our freelancers.
  9. You should feel free to request revision. We are always happy to provide revision on selected work related your Stata homework.
As we wish you get a higher mark on your Stata homework, we are always happy to accept Stata homework request related to working on Stata programming or related do files. We will provide complete code, complete results, complete outputs, complete tutorials in replicating the work for you on your own computers and complete answers to any questions you wish to be answered related to your Stata homework.
Now, dont hesitate to send us your Stata homework problems to be discussed. Submit your request for a free quote in proposed solution for your Stata homework.
Request Stata Homework Solution