Regression in Rats
Regression in Rats
Hello,
I have a program under R that I try to perform on ratz but I can't get the same result.
My R program:
x <- 1960:2014
ind <- function(x) ifelse (x<1980, TRUE, FALSE)
pibts2 <- pibts*pibts
regev <-lm(evts ~ pibts+(pibts+pibts2)*ind(x))
summary(regev)
res2<- residuals(regev)
plot(res2, type = "l")
My RATS program:
SET DUM1980 = T>=1960:1.AND.T<1980:1
SET DUM19802 = T>=1980:1
set trendq = pib2*DUM1980
print / trendq
linreg ev 1960:1 2014:1
# constant pib pib2
graph 1
# %resids[/color]
I don't understant why I don't have the same graph for the residuals.
I would also know how to make a graph of the regression (not the residuals):
linreg ev 1960:1 2014:1
# constant pib pib2
Thanks
I have a program under R that I try to perform on ratz but I can't get the same result.
My R program:
x <- 1960:2014
ind <- function(x) ifelse (x<1980, TRUE, FALSE)
pibts2 <- pibts*pibts
regev <-lm(evts ~ pibts+(pibts+pibts2)*ind(x))
summary(regev)
res2<- residuals(regev)
plot(res2, type = "l")
My RATS program:
SET DUM1980 = T>=1960:1.AND.T<1980:1
SET DUM19802 = T>=1980:1
set trendq = pib2*DUM1980
print / trendq
linreg ev 1960:1 2014:1
# constant pib pib2
graph 1
# %resids[/color]
I don't understant why I don't have the same graph for the residuals.
I would also know how to make a graph of the regression (not the residuals):
linreg ev 1960:1 2014:1
# constant pib pib2
Thanks
Re: Regression in Rats
First of all, I think you have your dummies mixed up. Your R dummy is 1 for <1980:1 and you're creating the RATS dummy to be >=1980:1. If I understand this correctly, you want something like:
set ind = t<1980:1
set pibd = pib*ind
set pidsqd = pib*pib*ind
linreg ev 1960:1 2014:1
# constant pib pibd pibsqd
You don't need to create a dummy for 1980:1 to 2014:1 (which is basically the full sample range)---by doing the CALENDAR instruction, you've already told RATS what the dates are. The R regression doesn't use the "undummied" square, just the linear term and dummied out versions of pib and its square.
You can use @RegActFit to graph the actual and fitted values.
set ind = t<1980:1
set pibd = pib*ind
set pidsqd = pib*pib*ind
linreg ev 1960:1 2014:1
# constant pib pibd pibsqd
You don't need to create a dummy for 1980:1 to 2014:1 (which is basically the full sample range)---by doing the CALENDAR instruction, you've already told RATS what the dates are. The R regression doesn't use the "undummied" square, just the linear term and dummied out versions of pib and its square.
You can use @RegActFit to graph the actual and fitted values.
Re: Regression in Rats
Thank you very much. I still have not exactly the same thing as with R but I will seek a solution thanks to your indications 
Re: Regression in Rats
Does the R regression include an intercept by default? What regression are you trying to run?
Re: Regression in Rats
Does the R regression include an intercept by default?
I don't know.
What regression are you trying to run?
In R, I'm doing:
regev <-lm(evts ~ pibts+(pibts+pibts2)*ind(x))
And for the residuals I have :
ANd for the CUSUM test:
But in RATS, when I'm using:
linreg ev 1960:1 2014:1
'# constant pib pibd pibsqd
I have for the residuals:
And for the CUSUM test:
I don't know.
What regression are you trying to run?
In R, I'm doing:
regev <-lm(evts ~ pibts+(pibts+pibts2)*ind(x))
And for the residuals I have :

ANd for the CUSUM test:

But in RATS, when I'm using:
linreg ev 1960:1 2014:1
'# constant pib pibd pibsqd
I have for the residuals:

And for the CUSUM test:

Re: Regression in Rats
Are you telling me that you want to run a regression, but you don't actually know what regression you're trying to run? That sounds like you need to find someone who works in R to explain what that lm command is doing. However, it looks like you may have more of a problem with getting the data in correctly. (Note that R has a negative outlier at entry 9, and there's nothing at all like that in the RATS output).
Re: Regression in Rats
I try to do a linear regression on ev with pib + pib² on the first part and pib on the second part. Sorry if I am not clear, I have some difficulty to explain myself, especially in English.
Note that R has a negative outlier at entry 9, and there's nothing at all like that in the RATS output.
→ That's the problem, I don't know why. I use exactly the same data.
Note that R has a negative outlier at entry 9, and there's nothing at all like that in the RATS output.
→ That's the problem, I don't know why. I use exactly the same data.
Re: Regression in Rats
I would certainly double check the data after it's read in. (Even the mean is usually enough to verify that you have the same data). Based upon your description, you probably wantc912 wrote:I try to do a linear regression on ev with pib + pib² on the first part and pib on the second part. Sorry if I am not clear, I have some difficulty to explain myself, especially in English.
Note that R has a negative outlier at entry 9, and there's nothing at all like that in the RATS output.
→ That's the problem, I don't know why. I use exactly the same data.
set ind = t<1980:1
set pibd = pib*ind
set pidsqd = pib*pib*ind
linreg ev 1960:1 2014:1
# constant pib ind pibd pibsqd
That will give separate intercepts in the two subsamples. (Regression output from both would be *much* more useful than graphs).
Re: Regression in Rats
Thank you again!
I have watch the regression output and I find what was diferent. I have exactly the same think that in R with:
set ind = t<1980:1
set pibd = pib*ind
set pibsqd = pib*pib*ind
set pibsqd2 = pib*pib
linreg ev 1960:1 2014:1 resmere2
# constant pib pibsqd2 ind pibd pibsqd
I have watch the regression output and I find what was diferent. I have exactly the same think that in R with:
set ind = t<1980:1
set pibd = pib*ind
set pibsqd = pib*pib*ind
set pibsqd2 = pib*pib
linreg ev 1960:1 2014:1 resmere2
# constant pib pibsqd2 ind pibd pibsqd