How would I get the linear combination of these coefficients for an ITS analysis in R?

Hi, for a project I'm doing an interrupted time series analysis using a segmented linear regression. I'm trying to show that the trend (or slope) change after the first intervention (the first dotted line) was counteracted by the trend (or slope) change after the second intervention, i.e. that the trend/slope in the post-2nd intervention period returned to what it was before the 1st intervention. In picture form my data and model results look similar to this (these are just toy examples from a lecture I went to), except my two _trend variables are something like 7.43 for the first and -7.55 for the second interruption:

Can anyone suggest how I should go about this, particularly in R? I think I can get the linear combination of the two trend coefficients and that should give me what I need (I would also like confidence intervals for this)? How do I operationalize this as R code?

Thank you.

You can use linearhypothesis() from the car package to test the hypothesis. Something like

regResult<- lm() # fill in regression here
linearhypothesis(regResult, "time = cda")

See 7.3 Joint Hypothesis Testing Using the F-Statistic | Introduction to Econometrics with R.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.