How tov separate the given sample into 2 subsamples; positive and negative?

118 Views Asked by At

I am running a regression analysis on one dataset, the output consists of positive and negative residuals. I was asked to calculate the mean values of negative residuals and positive residuals.

c(Left.Mean = mean(Estimated.Residuals[Estimated.Residuals < 0]), Right.Mean = mean(Estimated.Residuals[Estimated.Residuals > 0]))

It worked well and I got output as below:

Left.Mean Right.Mean

-0.7241664 0.7013580

Now, I am asked to separate the given sample into 2 subsamples: one, for which the residuals are below zero, and another, for which they are above zero. In addition, I need to create the variable "Unscrambled.Selection.Sequence" estimating switching between the two subsamples (1 corresponds to the positive residual case and 0 corresponds to the negative residual case). Is there any ideas?

0

There are 0 best solutions below