I know its possible to extract r-squared values to quantify the 'goodness-of-fit' of regressions in R, with something to the effect of:
fit <- lm(y ~ x1 + x2 + x3, data=mydata) # Not actual data r-sq <- summary(fit)$r.squared # or $adj.r.squared
I've recently been using the
cumSeg package for step-function regressions, but it doesn't appear to offer this functionality, though it does provide residuals as a vector.
Is there some way to extract an r-squared (or adj. r squared) that I don't know about? Or can it be calculated 'de novo' with something that
cumSeg does actually provide?
This is the output of
summary() for my stepfunction created via
cumSeg. Perhaps someone more mathematically versed with stepfunctions knows if the nomenclature for an r-squared (or whatever the equivalent is) is just different and the data I'm looking for is actually there (or if it is even a legitimate question to ask for an R-squared for stepfunctions?! I'm assuming it should be calculable from any fitted model really.
> summary(stepfunc) Length Class Mode coefficients 3 -none- numeric residuals 16 -none- numeric effects 16 -none- numeric rank 1 -none- numeric fitted.values 16 -none- numeric assign 0 -none- NULL qr 5 qr list df.residual 1 -none- numeric epsilon 1 -none- numeric it 1 -none- numeric psi 1 -none- numeric beta.c 1 -none- numeric gamma.c 1 -none- numeric V 16 -none- numeric y 16 -none- numeric id.group 16 -none- numeric est.means 2 -none- numeric n.psi 1 -none- numeric