In this section we test whether the slopes for two independent populations are equal, i.e. we test the following null and alternative hypotheses:

H_{0}: *β*_{1}* = β*_{2} i.e. *β*_{1}* – β*_{2} = 0

H1: *β*_{1}* ≠ β*_{2} i.e. *β*_{1}* – β*_{2} ≠ 0

The test statistic is

If the null hypothesis is true then

If the two error variances are equal, then as for the test for the differences in the means, we can pool the estimates of the error variances, weighing each by their degrees of freedom, and so

Since we can replace the numerators of each by the pooled value , we have

Note that the while the null hypothesis that *β* = 0 is equivalent to *ρ* = 0, the null hypothesis that *β*_{1}* = β*_{2} is not equivalent to *ρ*_{1}* = ρ*

_{2}.

**Example 1**: We have two samples, each comparing life expectancy vs. smoking. The first sample is for males and the second for females. We want to determine whether there is any significant difference in the slopes for these two populations. We assume that the two samples have the values in Figure 1 (for men the data is the same as that in Example 1 of Regression Analysis):

**Figure 1 – Data for Example 1**

As can be seen from the scatter diagrams in Figure 1, it appears that the slope for women is less steep than for that of men. In fact, as can be seen from Figure 2, the slope of the regression line for men is -0.6282 and the slope for women is -0.4679, but is this difference significant?

As can be seen from the calculations in Figure 2, using both pooled and unpooled values for *s _{Res}*, the null hypothesis, H

_{0}: the slopes are equal, cannot be rejected. And so we cannot conclude that there is any significant difference between the life expectancy of males and females for any incremental amount of smoking.

**Figure 2 – t-****test to compare slopes of regression lines**

**Real Statistics Function**: The following array function is provided by the Real Statistics Resource Pack. Here Rx1, Ry1 are ranges containing the X and Y values for one sample and Rx2, Ry2 are the ranges containing the X and Y values for a second sample.

**SlopesTest**(Rx1, Ry1, Rx2, Ry2, *b*, *lab*): outputs the standard error of the difference in slopes *s*_{b1–b2}, *t,* *df* and p-value for the test described above for comparing the slopes of the regression lines for the two samples.

If *b* = True (the default) then the pooled standard error *s*_{b1–b2} is used (as in cell T10 of Figure 2); otherwise the non-pooled standard error is used (as in cell N10 of Figure 2).

If *lab *= True then the output is a 4 × 2 range where the first column contains labels and the second column contains the values described above and if *lab* = False (the default) only the data is outputted (in the form of a 4 × 1 range).

The SlopesTest function only produces the correct results if there are no missing data elements in Rx1, Ry1, Rx2, Ry2.

**Observation**: For Example 1, the formula

=SlopesTest(A5:A19,B5:B19,D5:D20,E5:E20,FALSE,TRUE)

generates the output in range N29:N32 of Figure 3, while the formula

=SlopesTest(A5:A19,B5:B19,D5:D20,E5:E20)

generates the output in range O29:O32.

**Figure 3 – Comparing slopes using Real Statistics function**

Hi Charles, many thanks for this useful tutorial.

I’m not sure about how much the maths explained here rely on the assumption that the correlation between x and y is actually linear… How (in)accurate would it be to use this test for comparing the slopes of linear regression lines fitted on an exponential distribution? Intuitively, I would think that it is not proper usage of this test.

The reason I’m asking is that I’m reviewing someone’s work who used this test for comparing the slopes of 2 linear regression lines, but with 2 data series that are poorly modeled by a linear regression in the first place (R2 is ~0.2 for both). In fact, their dataset is best modeled as an exponential decay (R2 is ~0.8 for both). So I would suggest they first transform the y values with x->ln(x) and repeat the test. Is that sensible ?

PS: sorry for poor synthax of original post

Clement,

The test result should be valid regrading the two straight lines that best fit the two samples. If an exponential curve is a better fit for the data, then this test won’t say anything about the two exponential curves.

You can transform data so that an exponential regression model is transformed into a linear regression model. In this case the slopes test should be useful. Slopes in linear regression become exponents in exponential regression. See the following webpage regrading this type of transformation:

Exponential regression.

Charles

Dear Charles,

Thank you for the post, your website is so helpful!

I’d like to know if you can help me in a problem I have. I want to know if women are faster than men in a specific setting. The plots I have are time x distance, so in this case I have several points for each person (woman or man). I plotted them all together (all points I had for all women and all points for all men). I then ran an ANCOVA analysis to see if the slopes were different. But I was told that I should instead calculate a slope for each person (man or woman) and then compare the slopes them with a t-test. I am very confused as in my case distance x time are always related to velocity, that I want to measure, so is that one of the reasons I should not use ANCOVA for my comparisons? Do you have an opinion about what analysis should I do? Thank you very much!

Carol,

It seems like you can use a t test to test whether women are faster than men. I would need more information to understand why this wouldn’t be the correct approach.

Charles

Thank you, Charles!!!

I think I understand I can use the t-test to compare the slopes. But I don’t understand why I cannot use ANCOVA, since I am comparing the slopes?

Also, I hope it’s ok I ask you another question. To run the t-test, I will have several slopes with their respective SD. Should I combine the SD and then run the t-test? Because if I don’t combine them, I will be only comparing the slopes and ignoring the variation of each slope, correct? Does that make sense? Thank you!!!

Carol,

1. In ANCOVA you compare the slopes to determine whether ANCOVA is a suitable test. You should be able to use this test as well to compare the slopes.

2. I don’t know which t test you are referring to. In general, a t test is only used with a pair of samples: you have two slopes and not several. If you have multiple samples, then you could use ANOVA instead of the t test.

Charles

Hi, Charles!

Thank you! I will look more into the ANCOVA test to understand if it applies to my problem.

In regards to the t-test, I didn’t explain myself well. I have only two groups, but inside each group I have a number of slopes that belong to each specific group. Each slope has a SE, so my question was – when I do the t-test, should I combine these SE into one (one for each group)? Because if I don’t do that, each SE for each slope will be ignored. I hope I explained myself well! Thank you!!!

Carol,

I don’t know what this means “inside each group I have a number of slopes that belong to each specific group.”

Charles

Hi Charles,

I would realy like to use this tool, it would help a lot!

I also think my installation worked fine (=VER() returns “5.2 Excel 2007/2010 and I am using Excel 2010). But the function SlopesTest(R1, R2, R3, R4) returns only a single numeric value in a single cell. Do you have any idea what could be the problem?

Henning,

This is an array function and so you can’t simply press the Enter key. See the following webpage:

Array Formulas and Functions

Charles

Thank you for your information!

I am wondering what is the difference between using this method or using a group coefficient in the fitting slope. for example, using y = a*group*x+group+b

The second question is, what if I want to compare two quadratic curve or other like power-law curve fitting result? Can I still use the same way to compare between groups?

Heather,

1. I don’t quite understand the method using a group coefficient in the fitting slope (e.g. using y = a*group*x+group+b), that you are referring to. You would have two such equations; how would you compare them?

2. I don’t know whether this method would work for quadratic or power-law curves.

Charles

Hi Charles,

thank you for this excellent explanation. I have checked the calculations in Howell’s book that you refer to (although, in the 8th edition) and I was wondering why you in your calculations for Sb1-b2, exchange s^2y*x with 1?

Also, when deciding wether to use the pooled or unpooled estimate, is it the values for Sy*x that should be compared?

Thank you!

Vickie,

In Howell’s book he puts the pooled variance (s_y.x)^2 in the numerator of both fractions inside the square root symbol. By simple algebra these numerators can be replaced by 1 provided you place s_y.x in front of the square root symbol, as I have done.

Charles

Hi Charles – Appreciate the derivations as I’ve implemented this test in python and used your data and results to test my code.

One question/suggestion: Would it be a good idea to explicitly state what the alternative hypothesis is? I can tell from your doubling of the p-value that H1: β1 ≠ β2, but this may not be obvious to everyone visiting this site.

Michael,

Ok, I have made your suggested change.

Charles

Hi Charles,

=VER() gives 4.11 Excel 2010/2013/2016

Graham

Graham,

This means that the Real Statistics software was installed properly and so you should be able to use the SlopesTest function. When you type the function name into a cell you won’t see it reflected in a tooltip (as for standard Excel functions), but it should work.

If you are still having problems, you can send me your data and I will tell you exactly what you should do. You can find my email address at Contact Us.

Charles

Hello,

I have finally managed to find this site (and EXCEL Add-in) because comparing regression lines is a common need for my work in taxonomy. However, I cannot see in the Real Statistics package any reference/procedure for doing the comparison or the Slopetest. Can anyone provide a simple step-by-step procedure (for someone like me who is not a statistician/mathematician)? Many thanks.

GrahamB

Graham,

This capability has been implemented as a function (not as one of the data analysis tools), namely the SlopesTest function. Just use it as you would any other Excel function. The arguments are as described on the referenced webpage.

Charles

Thank you Charles, I’ll try and find may way through this. It will be a very useful tool for me when I can get it to work.

Graham

Hi Charles,

sorry to be a pain, but I cannot find the Real Statistics functions anywhere. Should it be obvious or hasn’t the resource pack downloaded properly?

Many thanks

GrahamB

Graham,

What do you see when you enter the following formula? =VER()

Charles

Dear Dr. Zaiontz,

To perform the same test for the intercept of the slopes does someone simply have to replace b1 and b2 with intercept 1 and intercept 2?

Thank you in advance,

Vasilis

No.

Hi,

Thanks forthe helpgful guide! Exactly what I was looking for! However, when I run the Real Statisitics function (Slopestest), I only get the Sb1+b2 for the data sets, no t-stat, df or p-value. This is regardless of whether lab = TRUE or not.

I tried to find this test under the ‘Data Analysis Tools’ menu, but can’t find which heading it is under. Any ideas where I can find it, or how to fix this problem?

Joshua,

The function is an array function and so you need to follow Excel’s rules for array functions, as described on the following webpage

Excel array functions and formulas

Charles

Joshua,

SlopesTest is what Excel refers to as an array function and so you can’t simply press the Enter key to use it. See the following webpage for how to use array functions:

Array formulas and functions.

Charles

Charles,

Suppose we have a monovariate regression analysis with X being discrete independent variable and Y the dependent variable. If the parent population is normally distributed how many samples I need to use to make sure my Slope and Intercept resemble the population slope and intercept with %5 error rate? What else I need to know from the parent population to answer this?

Thanks,

Reza

Reza,

The website tells how to calculate the sample size required for regression. Probably this is the value that you need. See

http://www.real-statistics.com/multiple-regression/multiple-regression-analysis/sample-size-multiple-regression/

Charles

Hi Charles,

Thank you very much for this solution. It is a simple way to check the significance on a difference in slope. I have compared it to another method, outlined here: http://socserv.socsci.mcmaster.ca/jfox/Courses/SPIDA/dummy-regression-notes.pdf

In summary, the method pools the data and creates a dummy factor that identifies the original grouping of the data (1 for group A and 0 for group B). It then uses that to derive an interaction factor, and the significance of that factor is examined. If the interaction coefficient is significant, the null hypothesis can be rejected.

I’ve used both methods on my data and have found that the two conclusions are different. Since the calculated standard error on the coefficient is different, and since the coefficient itself is the same, the t-statistic is different. The null hypothesis can be rejected in only one of the two methods (not yours).

Can you attempt to rationalize why the two methods might be giving different results? Am I perhaps interpreting the results incorrectly?

Thank you,

Keehan

Keehan,

I provide an option for the calculation of the standard error (the second to last argument of the function). Perhaps the other option yields the same result as in the other website you referenced.

Charles

Thank you Charles,

The pooled value for standard error yields the same conclusion as the non-pooled error, that is the null hypothesis cannot be rejected.

I’ve actually just discovered that my data is very slightly non-linear.

Can I still use the method you’ve outlined here for the second order coefficient?

Thanks!

Keehan

Keehan,

You are very unlikely to find data that is exactly linear, and so it really depends on how “slightly” your data is “slightly non-linear”. The test that I describe in the referenced webpage assumes linearity.

Charles

Charles,

I have paired samples in a regression model. The independent samples t test of the slopes, I believe, is inappropriate where the paired samples would actually be a dependent samples test. Do you have a test to compare slopes of paired samples. The results are measuring the same sample of subjects under different conditions. I need to know if the two different conditions create a different relationship between variables for the same subjects. Is this a change in how the slopes test is calculated or is a different test needed?

I have downloaded Real Statistics and have installed it in Excel 2016. It was not easy given your instructions, but I can start your addin with ctl m. However, I want to run a slopes test and “SlopesTest” is not an option. The dialog brings up “Choose a selection from the following” and there is no SlopesTest. Do I use some other command and how do I get to a manual for help.

Mac,

SlopesTest is a function and so can’t be accessed via Ctrl-m. This function is described on the referenced webpage.

To get information about any Real Statistics function or analysis tool, see the Tools menu on the website.

Charles

Charles,

Thanks. I downloaded the Real-Statistics Examples-Part 2 and found the template for SlopesTest. Excellent value for me–I want the test results, not the mechanics of the test. I will eventually create a macro for your template. Right now, I just need to test for difference in slopes. I greatly appreciate all the work you have put into this add in for Excel. Real-Statistics makes Excel an extremely useful tool. Great Work!

Mac

Citations? References

Steve,

See Howell’s book as shown in the Bibliography

Charles

Dear Charles,’=

Thank you for your most interesting post.

Its the following reference the one you are used?:

Howell, D. C. (2010). Statistical methods for psychology (7th ed.).

Wadsworth, Cengage Learning.

I checked the book’s table of content, and do not see anything related with slope comparison. I just want to make sure I am citing the right reference in my work.

Thank you!

Alice

Alice,

Yes. It is in section 9.11 on page 273 in my book.

Charles

Dear Charles,

what is the name of your method you described here?

How can I cite this in my paper?

David

Dear David,

I don’t know of any other name besides Comparing the Slopes of Two Independent Samples. The test is described in Howell’s textbook (see Bibliography).

Charles

Is it possible to compare the rate of growth to two exponential regression lines? I’ve tried to make the lines linear by taking ln and using the slopes in that way but I’m not sure you are allowed to do that.

If it helps, the two equations are y=24.356e^(.0437x) and y=30.101e^(.0235x)

Kirtsen,

Taking the log of both sides and using the two slope comparison test seems like a reasonable approach.

Charles

Dear Charles Zaiontz,

Thank you for you useful post. I wonder if the hypothessis testing is 95% or 90%, due to the alpha value=o.05. I got a bot confused. Hope you can help me.

Thanks in advance

Maria,

Yes, a 95% confidence interval corresponds to alpha = .05.

Charles

Dear Charles.

Is alpha=.05 also used if we want to use a two-tailed test with 95 % confidence?

Yes, although effectively you are computing the distribution value when alpha = .05/2

Charles

I created five scenarios of how inbreeding in a population increases over time. The linear regressions of these five scenarios show a similiar slope.

I want to test wether the similarity between all five scenarios is significant. How can I do this?

Florian,

Do you want to compare the slopes or do you want to compare the means of the five scenarios (or something else)?

Charles

Dear Charles, Your pack appears to be very useful for my application. When I installed for Vista/Office 2010 combination, I got an error and request for password which did not show up again. When I run SlopesTest, I get ‘std err’ or a single value but not a matrix. The value I get matches neither value in your example – I am getting a value of 0.528. Any guidance will be greatly appreciated.

Sid,

1. If you install the Real Statistics Resource Pack as described on the webpage from where you downloaded the software you should never receive a request for the password. You don-t need a password to use the software.

2. SlopesTest is an array function and so you need to highlight a range and then press Crtl-Shft-Enter instead of Enter to get the full results. See the following webpage for details

Array Functions and Formulas

Charles

Step 1: How do I access this function SlopesTest?

Glenn,

It is provided by the Real Statistics Resource Pack, which you can download for free at

http://www.real-statistics.com/free-download/real-statistics-resource-pack/

Charles

I need to compare two slopes of scores on an annual English acquisition test for English language learners. I’ll be comparing the results of one program over three years with results either from a sequence of three years previous to the new program for other students (probable) or previous scores for the same students (since many of the students began the program in kindergarten or the early elementary grades and won’t have three years previous, this will really reduce my sample size). The students will be tracked over three years, so there will be three points to construct the slopes. I know that the scores will improve over time, so all the slopes will be upward. I realize this is a time series, but all the time series analyses I’ve seen look like they are for something much more high-powered than this. I am not a statistics whiz, and I’m looking for something I can get my head around. Will the technique above be appropriate for this analysis? Thanks.

Brenda,

First of all, why do you need to compare slopes at all? Do you really need to compare slopes or are you interested in some other statistic (e.g. mean)?

The referenced test will compare two slopes. If you have three or more you could use the technique described for ANCOVA. If the data sets are not indpendent, but are dependent then you need to use the dependent version of the test (which is also decribed on the website).

Charles

Thanks for your response. I’m interested in seeing whether the program has an effect on how quickly the children acquire English. I know I could just compare the three time points and see if they are different, but I wonder if I wouldn’t gain more understanding by also looking at the slopes. This seems especially important if I’m comparing scores for the same child from years 1, 2, 3 (old program) with scores for years 4, 5, 6 (new program) – the scores will presumably improve from year to year, but I’m interested if they are improving more quickly in years 4-6. From what I’ve read of it, it doesn’t seem like ANCOVA would do this for me. Am I missing something? (Sorry if this is a little dense, I am not a great statistician but always willing to learn more.) Thanks.

Brenda,

You don’t use ANCOVA, only the test to see whether the slopes are equal. This test can be found at ANCOVA Assumptions

Charles

Hi Dr. Zaiontz,

Can this test be used to compare the time constants of the fit of an exponential function to two sets of normalized data? I want to test whether or not the time constant of the fit to one set of data is significantly different from the fit to another set (actually, before drug vs. after drug).

Thanks in advance,

Ed

Edward,

No, you can’t use this test to compare constants. Are you assuming that the slopes are equal? If not, what is the purpose of the comparison?

Charles

Charles,

Thanks very much for your reply.

I have fit an exponential function (y=exp(-t/tau)) to two sets of normalized data points, first in control and then in the presence of a drug. I observe that the tau in the presence of drug is 10% smaller. I am asking how to tell if the two taus representing each condition are significantly different. What is the appropriate test for this case?

Thanks,

Ed

Hi Charlie,

I am measuring the bacterial biodegradation of a chemical overtime using different treatments to enhance its degradation (First order reaction). Once I obtained the biodegradation rate constants (slopes) and the half life of the chemical, I want to test weather or not there is a statistical significance between the degradation of the chemical and the degradation of the chemical under the different treatments (6 treatments). Which statistical test would you recommend?

Camila,

Based on your description I am not able to recommend a specific test. It sounds like some form of ANOVA.

Charles

Wow, this is phenomenally helpful. Most of the other examples for this I have seen are focused on ANOVA which I can’t use since my points are all over the place (on the x axis). Gonna use this shortly for checking some models between different systems.

Dear Professor Charles Zaiontz,

I have one question. I try to compare four different slopes. I use your tool for pairwise comparisons. Do I have to use also Bonfferoni correction for p-value?

Best regards,

Toni

Dear Toni,

If you do multiple pairwise tests, then you would need to handle experimentwise/familywise error. Bonferroni is one method for doing this.

There may be some tests for homogeneity of slopes that handle more than two lines (e.g. to test this assumption for ANCOVA), but I don’t have time now to identify such a test.

Charles

Thanks,

Toni

an F test can handle this. with it you can compare an infinite array of slopes or lines.

Dear Professor Charles Zaiontz,

Thank you indeed for very helpful website.

I would be pleased if you could introduced ant books or articles that I can address this procedure for comparing two regression slope.

Best regards

Ali

Ali,

One reference is the following book:

Howell, D. C. (2010). Statistical methods for psychology (7th ed.). Wadsworth, Cengage Learning

Charles

First, as a recently graduated undergrad, let me say, this array function is so awesome!

My question is, do you have a similar function to compare the b-intercepts of two sets of data?

Using your your =slopestest on my data, I get a p-value=.9205, which makes sense as my plotted data looks like two parallel lines. However, the plot shows two lines that have vastly different intercepts, and I want to know if the lines have *statistically* different intercepts.

To give you a bit of context regarding the data, I am looking an intervention study, and I am comparing the frequency of hospital visits before and after intervention. Before and after intervention, the average visits are flat lines (slightly negative slopes, m =~ -0.1), but the after intervention the flat line drops down considerably.

Any help would be appreciated. I’m glad to have such a cool add-in on my excel.

Hi Grant,

Here is my first thought as to how to address this problem. If the two lines have significantly equal/different intercepts, then if you subtract the equation of one line from the other you should be able to test whether the resulting line has zero intercept.

To test whether a line has zero intercept, please look at Example 2 on the following webpage:

http://www.real-statistics.com/regression/confidence-and-prediction-intervals/

Charles

Hi all,

I used this test and was wondering what the exact name of that test is, or how to call that type of test. Concretely, in a text normally you say “…were significant (P < 0.05; T-test, ANOVA, etc…)" so what is it here ? "P < 0.05; xxx"? On the internet I found it called a MANCOVA, or just a T-test but then how to indicate concretely that the slopes were tested?

Thanks for your help!

Marieke

Hi Marieke,

I don’t know how to call this test except comparison of the slopes of regression lines from two independent samples.

I wouldn’t call it MANCOVA or T-test.

Charles

Hello!

Was there any additional thought on a name for this test? My PI doesn’t accept the notion that this analysis has no name associated with it, and I don’t know what to tell him. Is there a name given, perhaps in the Howell (2010) book referenced above?

Thanks,

Katharine

The test is called “Testing the difference between two independent slopes”

Charles

I was looking for the reference in which the unpooled comparing of slopes is based.

The pooled is based on the Kleinbaum book?

But, I was searching in Armitage book, and I can not find the unpooled formulaes when the residual variances of the two groups are quite different.

Can you help me?

Best regards,

Javier

David Howell, Statistical Methods for Psychology, Wadsworth.

Charles

Good day,

Thank-you for your fast answer! I will look in.

Best regards,

Javier

Good day,

i was trying the formula for slopestest, but first it wants rather semicolons to separate the different ranges and then it outputs me only either “stderr” (if lab = true) and or number if i do not precise b and lab. I use Excel 2010. Any help would be appreciated!

Thanks

Dirk

Hi Dirk,

You are probably using the German version of Excel, which uses semi-colons instead of commas to separate arguments in a function. The SlopesTest function is what Excel calls an array function. In this case you must highlight the range where the output will go (not just a single cell) and then press Ctrl-Shift-Enter. See the webpage Array Formulas and Functions for more details about how to use array functions.

Chrales

Thanks for the superfast response! I struggled a bit, but now managed. Thanks for your help!

Dirk

Hello,

I just made it through all of this to compare the slopes for two different sites. The difference between the slopes is so small, I know this probably sounds like a silly question. I got 0.023049 for my unpooled slope, and 0.023765 for my pooled slope. They round to 0.023 and 0.024. Does this violate the null hypothesis because it equals 0.001 and thus make the differences between slopes significantly different?

Thanks

Chris,

If the p-value = .001 then I would conclude there is a significant difference, even if the difference between the slopes seems rather small. Remember that significantly different doesn’t mean large. You use the effect size to characterize whether an effect is small or large.

Charles

Hihi,

I have a question, also for a non-expert.

I have 10 values for x and y plotted as a scatter with a trend line (which gave me an intercept and slope).

I want to test if the slope is sig. different from slope x=y.

can the test =SlopesTest be used in this example?

( i have the dutch excel and for some reason cannot find the corresponding dutch command, to try for myself)

thanks, JJ

JJ,

SlopesTest is not a standard Excel function. It is part of the Real Statistics Resource Pack. You need to download and install the resource pack to use this function. This is free.

The Slopes Test requires two samples of xy points. You only have one such sample. Here are a few possible options for how to conduct the test you want. I prefer choice 3. It is the easiest to implement.

1. You could try to create a second sample consisting of points whose x and y values are equal and then use the SlopesTest function. I’m not sure this approach is completely sound, though.

2. You can use the Testing significance of slope approach. This method tests whether the slope is equal zero based on testing the correlation coefficient. You want to test whether the slope equals 1 (the slope of y = x). You would need to modify this test probably using the Fisher transformation in some way (see testing correlation coefficient).

3. You take all the xy points in your sample and create a new sample consisting of the points xy’ where y’ = y-x. If the points xy in your original sample have slope which is not significantly different from 1 (the slope of y=x) then the points xy’ in the new sample should have slope which is not significantly different from zero. The converse is also true. Fortunately there is a test to see whether the slope of a regression line is significantly different from zero, namely the test described on the webpage Testing significance of slope.

In any case, since your sample is so small, the power of any of these tests will likely be low.

Charles

Quick question for a non-expert, how do you calculate Sb1-b2 (as in the subscript = (b1-b2)). This is different than Sb1-Sb2 yes?

Max,

Yes, the standard error of b1-b2 is different from the standard error of b1 minus the standard error of b2.

I give two formulas for how to calculate standard error of b1-b2 in the very beginning of the referenced webpage. The first is that the standard error of b1-b2 is the square root of the sum of the square of the standard error of b1 plus the square of the standard error of b2.

Charles

Hi Charles,

Can you give a little more information on the citation for this work? Meaning I see you said Statistical Methods for Psychology”, Wadsworth CENGAGE Learning, 2010 however what Chapter and/or pages where you using?

Thanks,

Greg

Greg,

This is a good suggestion. I’ll try to do this in the future, since it would quite difficult for me to do this for all the previous references.

Charles

Hi Dr. Zaiontz,

Thanks for the illumniating example.

What happens if the two functions are NOT linear and CANNOT be transformed easily into a linear function?

In my case, I am fitting two sets of time-dependent data to the function f(t), and f(t) is a1*cos(pi*a2*t)cos(pi*a3*t)*exp(-a4*t), where a1…a4 are the fitted parameters. I am interested in whether the a3 parameter obtained for two different fits is indeed significantly different. We have 18 measurements in each fit (so 14 degrees of freedom).

Happy to hear your opinion or get a link to a helpful textbook!

Jordan

Jordan,

You need to perform non-linear regression. Probably the easiest way to do this is with Excel’s Solver. I give some examples on the following webpages:

Exponential Regression

Logistic Regression

Charles

Hi,

I was just wondering why the degrees of freedom are n-4?

Thanks,

Rebecca

Rebecca,

As you can see from the webpage http://www.real-statistics.com/regression/hypothesis-testing-significance-regression-line-slope/ df = n-2 for a one slope test. With two slopes the n-2 becomes n-4 (minus 2 for each slope).

Charles

Thank you very much.

Also I was wondering what are the assumptions that are made about the data to conduct the t-test? That it was normally distributed for both groups?

I was a bit confused about whether to use the pooled or non-pooled standard error, could you explain what you meant by “if b = true”?

And finally, would you report these results in a lab report the same as you would report the results of any t-test, except reporting the values of b and standard deviations of b instead of means?

Sorry about all the questions, I’m very new to stats and using excel!

Best wishes,

Rebecca

Rebecca,

The assumptions are similar to those for the usual t test, including both samples are normally distributed (although such tests are usually pretty robust to violations of this assumption)

Use the pooled standard error if the variances are approximately equal; otherwise use the non-pooled standard errors.

b = True means that the fifth argument in the function takes the value True.

Yes, you should report the results in a manner similar to the usual t test.

Charles

Any chance of providing the t-test to compare two intercepts? Thanks.

MJ,

For this test, see Example 2 of the webpage http://www.real-statistics.com/regression/confidence-and-prediction-intervals/.

Alternatively you can use the Linear Regression data analysis tool.

Charles

Sir,

in Figure 2, cell V10 the code cites: “= Sres…” does that refer to the sqrt of cell V9? Because cell S9 refers to the parameter “Sres^2” and elsewhere small details such these are called out quite explicitly, I don’t know for certain which way to go [i.e., use the “Sres^2” or sqrt(Sres^2)].

Thank you in advance for your assistance.

Matt

Matt,

The formula in cell T10 (which corresponds to V10) is =SQRT(T9*(1/(N7^2*(N4-1))+1/(O7^2*(O4-1))))

The formula in cell T9 is =((N4-2)*N6^2+(O4-2)*O6^2)/(N4+O4-4)

Charles

thank you so much.

Hey,

I’ve got a question: Does this comparison also work if I have 3 samples and not only 2?

Gina,

No, you need to run ANCOVA. See Chapter 18 of J Zar, Biostatistical Analysis, 2nd edition, Prentice-Hall, 1984 for more details.

Charles

Thanks!

I used a Mediationmodel.

Is it right, that in ANCOVA I use “Group” as fixed, Outcome as dependent and Mediator as Covariate?

Greetings

Gina,

Sorry that it has taken me so long to respond to your question. I seemed to have missed your response. I am not very familiar with Mediation models and so I am reluctant to answer your question. I plan to look into these sorts of models later this year.

Charles

Charles

Never mind… I figured it out finally. I was entering the array data incorrectly.

Thanks

Patricia

Hi Charles

Your RealStatistics Resource Pack for Excel is great. Thank you for providing it. I have been using R but am still learning the language. Your tool is much more time saving for some statistical analyses than R. However, I am having some problems accessing some of the functions such as SlopesTest. I’m using Excel 7. I tried to access it through the example worksheet and still just get the #VALUE! message.

Thank you for your help on this.

Cheers

Patricia

Hi Charles,

Thank you very much for this great post!

I have a small question. What if each one of my data (y) is actually a mean over a lager data set, how can I account for it? should I expect a different result?

Thanks.

David,

I’m not sure how you would account for this (or if you could account for this). I would think that this would change things considerably.

I suggest that you try a few examples where you create some data (i.e. the larger data sets) and have the y values be the means over the larger data set that you have created. Then run the test using the means and run it again using the larger data set and see what sort of differences there are.

Charles

Thanks Charles for your quick reply.

I’ll try your suggestion.

David

Hi.

How can I do this on excel 2010? I was trying TDIST formula but this function is available only with Excel 2007 or earlier versions and I am unable to understand the 2010 version. Or post a picture using Excel 2010 please.

Cheers

Hi Hammad,

I am using Excel 2010 and have no problem using the Excel 2007 functions such as TDIST. In any case here are substitutions for Excel 2010:

Replace TDIST(x,df,2) by T.DIST.2T(x,df)

Replace TINV(p,df) by T.INV.2T(p,df)

Charles

Hi Charles,

I noticed that if there are holes in the data the result of SlopesTest is different. Belos are the numbers I tried, they are the same but some points are missing one or the other piece of data. Since only data with x and y should count, I thought the SlopesTest would give me the same result. Should I always remove missing data before doing the SlopesTest?

Thanks you,

Ramiro

This gave me p=0.131431

1 3 1 1

2 3 2 2

3 3 3 5

4 4 6

5 4 8

4 5 9

6 5 6

7 6 7 13

and this gave me p=0.14889

1 3 1 1

2 3 2 2

3 3 3 5

5 4 4 6

6 5 5 9

7 6 7 13

Hi Ramiro,

In the current implementation of the SlopesTest function the correct values are generated only if there is no missing data. You need to remove any missing data before using the function.

Charles

Hi, I tried testing your SlopesTest using your Example1 data. When I input it I only get the following “result”: std err. This appears to be only the label as in your Figure 3. When I repeat the formula by excluding the “false,true” part I get the result 0.23271.

Any ideas?

Carl,

SlopesTest is an array formula. Try entering the formula and then pressing Ctrl-Shift-Enter. The full results should be displayed. If you press Enter instead, then only the first cell in the output will appear.

Charles

I have the same problem as Carl, except I have tried ‘Ctrl-Shift-Enter’ and it makes no difference to the result. It’s either ‘std err’ or a number (in my case 28.16). Please let me know if you are aware of any other factors that might be stopping this formula from working.

Laura,

Since this is an array function, you need to first highlight a 4 x 1 column range, then enter a formula of form SlopesTest(R1, R2, R3, R4, b) where R1, R2. R3 and R4 are ranges and b is either TRUE or FALSE, and finally press Ctl-Shft-Enter. This will fill the highlighted range with the following values: std err, t, df, p-value.

Alternatively you can first highlight a 4 x 2 range, then enter a formula of form SlopesTest(R1, R2, R3, R4, b, TRUE) and finally press Ctrl-Shift-Enter. This will fill the second highlighted column with the same values as described above and fill the first column with the appropriate labels.

The key is that you must first highlight an output range of sufficient size to contain all the output. It can even be larger than necessary (the extra cells will be filled with #N/A.

Charles

Thank you for the advice Charles. The problem is now fixed thanks to your suggestion!

Cheers

Hi Dr. Zaiontz,

This is exactly the type of information that I was looking for to complete a study that I was working on. I was wondering two questions;

1st) can you explain more about about I would go about finding the X/Y values of the lines in order to perform these calculations? I’m using a trendline in time-series line graph and I can see that there is definitely statistical significance, but I need to express it mathematically.

2nd) Do you know if this method is possible using SPSS?

Hi Johnathan,

I am very pleased that the information is relevant for your needs. Regarding your questions:

1) I am not sure what you mean. The X/Y values are the data that you are testing.

2) I don’t use SPSS, but I believe that the answer is yes. E.g. the following webpage references doing this in SPSS: http://core.ecu.edu/psyc/wuenschk/MV/multReg/Potthoff.pdf

Charles

Sir

I am a little confusing about the “pool the estimates of the error variances” . The formula (S_res squre) you used in this website is different with the formula you used in Excel workbook.

Colin

Sir

Please ignore my question, you are right.

Colin

Thank you for this, your slopestest function saved me a lot of trouble!

Thanks for your quick reply, Charles. I actually caught the source of my confusion, and I’m now convinced that your approach is actually correct! Sorry about that.

Do you have a textbook or a paper you can cite to justify these equations? I’m fairly certain the test you present here is incorrect. The test statistic should be (b1 – b2) / sqrt(SE(b1)^2 + SE(b2)^2), where SE(b1) is given not by steyx (this is the standard error of the predicted y value) nor by the equation you give for s_b1. See, e.g., this link: (http://stats.stackexchange.com/questions/44838/how-are-the-standard-errors-of-coefficients-calculated-in-a-regression) on accurate calculation of these standard errors.

Andrew,

I used David Howell’s textbook entitled “Statistical Methods for Psychology”, Wadsworth CENGAGE Learning, 2010. Shortly I will recheck my test samples using your approach and the approach I used on the website.

Charles

Dear Dr. Zaiontz

thank you for your useful example. I have a question:

As I found in your example, this method will be useful if linear regression consider. If we have some data that power regression will fit, in this case what should we do? can we use directly with those data or we should change them to linear regression (by log transferred for example)? for example, if we want to compare the regression line between fish male and female height and weight (which is power regression), we can use directly from those data?

Dear Ahmad Noori,

I believe that what you have suggested should work since you are only using a transformation. The formulas for comparing the slopes need to be applied after the transformation so that you are comparing the slopes of two (straight) lines.

Charles

Thank you for your laconic comments. What about “a” (Y intercepts) between two lines? Is this factor important if we want to compare the slopes between two lines or only the “b” (slope) should be compared?

Hi,

You have a cell wrong in the excel sheet. Please fix it if you can. In Figure 2, cell M11 should be equal to (b1-b2)/(sb1-b2), NOT (b1-b2)/(sb1-sb2)

Thanks Aravindh,

That was a great catch. I have made the change that you suggested. Thanks for your help.

Charles