Skip to main content
Edited description of variables
Source Link

A nice objective method to determine the break point is described in Crawley (2007: 427).

The steps involved are:

First, define a vector breaks for a range of potential break points (V_depV_expl, and further below, V_indepV_respstand stand for dependentexplanatory variable and independentresponse variable respectively):

breaks <- V_dep[V_depV_expl[V_expl >= ... & V_depV_expl <= ...]

Then run a for loop for piecewise regressions for all potential break points and yank out the minimal residual standard error (mse) for each model:

mse <- numeric(length(breaks))
for(i in 1:length(breaks)){
  piecewise <- lm(V_indepV_resp ~ V_dep*V_expl*(V_depV_expl < breaks[i]) + V_dep*V_expl*(V_depV_expl >=breaks[i]))
  mse[i] <- summary(piecewise)[6]
}
mse <- as.numeric(mse)

Finally, identify the break point with the least mse:

breaks[which(mse==min(mse))] 

Hope this helps.

A nice objective method to determine the break point is described in Crawley (2007: 427).

The steps involved are:

First, define a vector breaks for a range of potential break points (V_dep, and further below, V_indepstand for dependent variable and independent variable respectively):

breaks <- V_dep[V_dep >= ... & V_dep <= ...]

Then run a for loop for piecewise regressions for all potential break points and yank out the minimal residual standard error (mse) for each model:

mse <- numeric(length(breaks))
for(i in 1:length(breaks)){
  piecewise <- lm(V_indep ~ V_dep*(V_dep < breaks[i]) + V_dep*(V_dep >=breaks[i]))
  mse[i] <- summary(piecewise)[6]
}
mse <- as.numeric(mse)

Finally, identify the break point with the least mse:

breaks[which(mse==min(mse))] 

Hope this helps.

A nice objective method to determine the break point is described in Crawley (2007: 427).

The steps involved are:

First, define a vector breaks for a range of potential break points (V_expl, and further below, V_resp stand for explanatory variable and response variable respectively):

breaks <- V_expl[V_expl >= ... & V_expl <= ...]

Then run a for loop for piecewise regressions for all potential break points and yank out the minimal residual standard error (mse) for each model:

mse <- numeric(length(breaks))
for(i in 1:length(breaks)){
  piecewise <- lm(V_resp ~ V_expl*(V_expl < breaks[i]) + V_expl*(V_expl >=breaks[i]))
  mse[i] <- summary(piecewise)[6]
}
mse <- as.numeric(mse)

Finally, identify the break point with the least mse:

breaks[which(mse==min(mse))] 

Hope this helps.

Post Migrated Here from stackoverflow.com (revisions)
Source Link

A nice objective method to determine the break point is described in Crawley (2007: 427).

The steps involved are:

First, define a vector breaks for a range of potential break points (V_dep, and further below, V_indepstand for dependent variable and independent variable respectively):

breaks <- V_dep[V_dep >= ... & V_dep <= ...]

Then run a for loop for piecewise regressions for all potential break points and yank out the minimal residual standard error (mse) for each model:

mse <- numeric(length(breaks))
for(i in 1:length(breaks)){
  piecewise <- lm(V_indep ~ V_dep*(V_dep < breaks[i]) + V_dep*(V_dep >=breaks[i]))
  mse[i] <- summary(piecewise)[6]
}
mse <- as.numeric(mse)

Finally, identify the break point with the least mse:

breaks[which(mse==min(mse))] 

Hope this helps.