Pregunta

I want to implement the Simple Regression model from the apache commons math libary.

I have implemented:

//estimate alpha and beta parameters
regression = new SimpleRegression();
for (int l = 0; l < xList.size(); l++) {
    regression.addData(Double.parseDouble(xList.get(l).replace(',', '.')), yList.get(l));
}

//add alpha
regression.getIntercept();

//add beta
regression.getSlope();

//add R^2
regression.getRSquare();

Compared to a simple google spreadsheet to verify my results:

I get completely different results. Here you can also see a picture:

enter image description here

I would appreciate any recommendations how to fix this problem?

UPDATE

I know that statistically these data is not valuable.(for example see R^2) However I want to find out whats wrong with the computation instead of some statistical properties!

I am using:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-math3</artifactId>
    <version>3.0</version>
</dependency>

I appreciate every idea!

¿Fue útil?

Solución

The correlation coefficient is very small: 0.85% is 0.0085. You can't really trust the slope and intercept you get from anywhere because there is practically no correlation between X and Y.

Otros consejos

The value of R^2 doesn't determine the accuracy of alfa and beta coefficients as suggested in other question. It only contains information about linear relationship between variables. If the information about this relationship obtained via regression in terms of equation coefficients is still meaningful to you depends on your particular needs. R^2 can be only 0.5% and you might still want to use your model because for example you claim that this is some long run relationship. Incorrect results that you get are only effect of computation. Excel treats dots as thousands separator (though it can be changed).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top