Simple / Linear Regression Tutorial, Examples
The multiple regression model produces an estimate of the association between BMI and systolic blood pressure that accounts for differences in systolic blood pressure due to age, gender and treatment for hypertension.
A one unit increase in BMI is associated with a 0. Each additional year of age is associated with a 0. Men have higher systolic blood pressures, by approximately 0. The multiple regression equation can be used to estimate systolic blood pressures as a function of a participant's BMI, age, gender and treatment for hypertension status. For example, we can estimate the blood pressure of a 50 year old male, with a BMI of 25 who is not on treatment for hypertension as follows:. We can estimate the blood pressure of a 50 year old female, with a BMI of 25 who is on treatment for hypertension as follows:.
On page 4 of this module we considered data from a clinical trial designed to evaluate the efficacy of a new drug to increase HDL cholesterol. One hundred patients enrolled in the study and were randomized to receive either the new drug or a placebo. The investigators were at first disappointed to find very little difference in the mean HDL cholesterol levels of treated and untreated subjects.
However, when they analyzed the data separately in men and women, they found evidence of an effect in men, but not in women. We noted that when the magnitude of association differs at different levels of another variable in this case gender , it suggests that effect modification is present.
Multiple regression analysis can be used to assess effect modification. This is done by estimating a multiple regression equation relating the outcome of interest Y to independent variables representing the treatment assignment, sex and the product of the two called the treatment by sex interaction variable.
In this case, the multiple regression analysis revealed the following: The details of the test are not shown here, but note in the table above that in this model, the regression coefficient associated with the interaction term, b 3 , is statistically significant i. The fact that this is statistically significant indicates that the association between treatment and outcome differs by sex.
The model shown above can be used to estimate the mean HDL levels for men and women who are assigned to the new medication and to the placebo. In order to use the model to generate these estimates, we must recall the coding scheme i. Notice that the expected HDL levels for men and women on the new drug and on placebo are identical to the means shown the table summarizing the stratified analysis.
Because there is effect modification, separate simple linear regression models are estimated to assess the treatment effect in men and women:. Multiple linear regression analysis is a widely applied technique.
In this section we showed here how it can be used to assess and account for confounding and to assess effect modification. The techniques we described can be extended to adjust for several confounders simultaneously and to investigate more complex effect modification e. There is an important distinction between confounding and effect modification. Confounding is a distortion of an estimated association caused by an unequal distribution of another risk factor. When there is confounding, we would like to account for it or adjust for it in order to estimate the association without distortion.
In contrast, effect modification is a biological phenomenon in which the magnitude of association is differs at different levels of another factor, e. In the example, present above it would be in inappropriate to pool the results in men and women. Instead, the goal should be to describe effect modification and report the different effects separately. There are many other applications of multiple regression analysis. A popular application is to assess the relationships between several predictor variables simultaneously, and a single, continuous outcome.
For example, it may be of interest to determine which predictors, in a relatively large set of candidate predictors, are most important or most strongly associated with an outcome. It is always important in statistical analysis, particularly in the multivariable arena, that statistical modeling is guided by biologically plausible associations.
Independent variables in regression models can be continuous or dichotomous. There is no reason to assume that you will get the same answer from options 1 and 2. Thanks, for the clarification. Can you please also guide some source where we can learn about scaled residuls.
Zulfiqar, Here are some references: Other real examples can be found in various textbooks and online. In the graph below. I think we calculate the time using linear interpolation and certain numerical methods.
In this case, I need to know the statistical method to estimate the time. We can rewrite the question as follows: How long time the process takes from initial value y0 to end value yn?
Hi, Does anyone know if there is a way to calculate the whole thing by hand? Alan, The referenced webpage tells you how to perform exponential regression based on linear regression. If you look at the webpages on linear regression as well, you will see how to perform linear regression and therefore exponential regression by hand.
This will not consist of a single formula. Hi, What do you suppose is the simplest way in which I could show and explain how the method of obtaining an exponential function via a linear model is valid to all exponential functions? If so how would I go about showing this with a given set of data? My first and second x and y values are 0, and 1, Brittany, Yes, the same technique should apply.
I have further question after finding the intercepts. If we had to calculate the value of t at end positions ex: Can linear model intepretation of slope and intercept be applied directly after take the natural log? Pranav, See the following webpage for the calculation of a and b for the linear case by hand.
Can you please explain to me how you would do the regression data analysis…? I want to know how to get the values in figure 2, Thank you! Lily, See the webpage http: Nazia, As described on the referenced webpage, you can always model data that fits an exponential function using a linear model. The non-linear model as described on the Real Statistics website will be a little more accurate. Hi, I saw in some papers that the coefficients are interpreted as semi-elasticity without outlining the initial model.
Does that mean that the model is in log-level form? When we use other functional forms to run the regression analysis, why do we then choose the functional form with the least MS residual to analyse the result?
In general, the logic behind minimizing the squared error is as described on the webpage Maximum Likelihood Function. Under what circumstances would it be appropriate to log transform only the independent variable for an exponential regression? Rachel, This transformation is appropriate when it provides a better fit for your data.
This is level-log regression as described on the webpage http: Rachel, See Power Regression Charles. I am trying to download the software or application as per your posting from http: It might be possible that I am not doing it properly, because I still can not download it to my computer and have it as an Add in tool Could you please help me out with some step by step guidance? To download the software, just go to the following webpage and click on the Free Download button assuming that you are using Excel , or for Windows Real Statistics Resource Pack.
On the Add-Ins dialog box that appears press the Browse button and locate where you stored the realstats. Once you have done this, make sure that the Realstats option on the Add-Ins dialog box is checked and click the OK button. Linest and the if function. What if we take log to the base 10 i. Will the answers differ? Then once you have it in the natural log form would you just take the equation and set it equal to marginal cost to find the profit maximizing quantity?
Sorry, but I am not sure that I understand your question, although perhaps the following webpage provides the information you are looking for. Pls I need a solution to this problem where can I get semi-log regression and double log regression in SPSS or which software can I use to solve it.
Taniya, Take any example you have for the chi-square test for independence of two variables and simply add another variable. Log-linear models analyze the resulting 3-way contingency tables. If this is not the answer to your question, please explain better. Hey, I have a doubt. If we have a data and we need to find the relation between them,we use correl to see if they have any linear relation between them.
Likewise is there any counterpart for correl to see the exponential relation between the data. If we have a data,how can we come to a conclusion that they are exponentially related and then use logest or growth to predict the further values. Petr, As described on the referenced webpage, if x and y have a exponential relationship, i. Thus you could use correl between ln y and x to test whether x and y have an exponential relationship. For exponential, logarithmic and power trend fits, Excel uses the least square method on the data pairs [x, ln y ] in the exponential case.
NOT the R-squared of your original data! So do not rely on this value in the chart! This fact is documented somewhere in Excel … not too easy to find though. I can provide examples, where the Excel trend no matter if calculated as a chart trendline or by a worksheet function like GROWTH is worse than an exponential fit calculated e. They are not — always.
So, if you want to be sure whether your data follow an exponential, logarithmic or power pattern: I appreciate your serious comment and plan to look into it. Based on your comments I may need to provide a new version of the referenced regression algorithms that provide a better fit along the lines that you have suggested. I just came across this thread and if you have already addressed this issue elsewhere, just ignore my post.
We can view the exponential model as follows. Y has a log-normal distribution while Ln Y has a normal distribution. The relationship between the Normal and Log-normal distribution is well defined. Similarly higher order moments can be defined see Wikipedia Log-normal. The following notation is not exactly right, but I hope it conveys the message. So Excel will consistently under-estimate the expected value of Y given X unless it is a perfect fit in which case MSE will be 0.
This would be the solution for the Exponential model, but not necessarily for the other models. So Jorj is correct in that the Excel may not be the best approach for non-linear estimation. Most people assume that transformations are easy … they usually are not. And this is a case in point. Krish, Thanks for your comments. I had been reluctant to spend the time necessary to implement the Levenberg-Marquardt algorithm as suggested by Jorj, but I can see that it is not sufficient to simply accept the approach used by Excel.
Shortly I will modify the website to at least comment on the discrepancy and try to come up with a compromise solution. Krish, The latest release of the software, Release 3. Jorj, The latest release of the software, Release 3.
I expect to add a description of how to use these new capabilities later today. Hi, Yes this is correct. I believe this is true for any value of b1, not just for b1 much larger than 0.
Am I able to just plot the residuals against the original x values? The residuals are in same units as the y values which have not been transformed, so the residuals should still be true for the original data.
The residuals are based on the model used, not really the original data. The residuals for these data points are 0. You can then plot these values against x. You will see a pretty random plot. Exactly how do you arrive at your residual values? Can you please explicitly show us the calculation? As an example, the residual between the observed value x of 7. The residual of the linear model is the difference between the observed value of lny and the predicted value of lny.
The least squares estimates of the regression coefficients, b 0 and b 1 , describing the relationship between BMI and HDL cholesterol are as follows: Again, the Y-intercept in uninformative because a BMI of zero is meaningless. If we compare two participants whose BMIs differ by 1 unit, we would expect their HDL cholesterols to differ by approximately 2.
Linear regression analysis rests on the assumption that the dependent variable is continuous and that the distribution of the dependent variable Y at each value of the independent variable X is approximately normally distributed.
Note, however, that the independent variable can be continuous e. We previously considered data from a clinical trial that evaluated the efficacy of a new drug to increase HDL cholesterol see page 4 of this module. We compared the mean HDL levels between treatment groups using a two independent samples t test. Note, however, that regression analysis can also be used to compare mean HDL levels between treatments. HDL cholesterol is the continuous dependent variable and treatment new drug versus placebo is the independent variable.
A simple linear regression equation is estimated as follows:. In this example, X is coded as 1 for participants who received the new drug and as 0 for participants who received the placebo. Thus, the Y-intercept is exactly equal to the mean HDL level in the placebo group. A one unit change in X represents a difference in treatment assignment placebo versus new drug.
The slope represents the difference in mean HDL levels between the treatment groups. Dichotomous or indicator variables are usually coded as 0 or 1, where 0 is assigned to participants who do not have a particular risk factor, exposure or characteristic and 1 is assigned to participants who have the particular risk factor, exposure or characteristic.
In a later section we will present multiple logistic regression analysis which applies in situations where the outcome is dichotomous e. There is convincing evidence that active smoking is a cause of lung cancer and heart disease.
Many studies done in a wide variety of circumstances have consistently demonstrated a strong association and also indicate that the risk of lung cancer and cardiovascular disease i. These studies have led to the conclusion that active smoking is causally related to lung cancer and cardiovascular disease.
Studies in active smokers have had the advantage that the lifetime exposure to tobacco smoke can be quantified with reasonable accuracy, since the unit dose is consistent one cigarette and the habitual nature of tobacco smoking makes it possible for most smokers to provide a reasonable estimate of their total lifetime exposure quantified in terms of cigarettes per day or packs per day.
Frequently, average daily exposure cigarettes or packs is combined with duration of use in years in order to quantify exposure as "pack-years". It has been much more difficult to establish whether environmental tobacco smoke ETS exposure is causally related to chronic diseases like heart disease and lung cancer, because the total lifetime exposure dosage is lower, and it is much more difficult to accurately estimate total lifetime exposure.
In addition, quantifying these risks is also complicated because of confounding factors. For example, ETS exposure is usually classified based on parental or spousal smoking, but these studies are unable to quantify other environmental exposures to tobacco smoke, and inability to quantify and adjust for other environmental exposures such as air pollution makes it difficult to demonstrate an association even if one existed.
As a result, there continues to be controversy over the risk imposed by environmental tobacco smoke ETS. Some have gone so far as to claim that even very brief exposure to ETS can cause a myocardial infarction heart attack , but a very large British Medical Journal , Volume , May 17, It should be noted, however, that the report by Enstrom and Kabat has been widely criticized for methodologic problems, and these authors also had financial ties to the tobacco industry.
Correlation analysis provides a useful tool for thinking about this controversy.