[R] Variable name as string
Jan private
jrheinlaender at gmx.de
Sun Oct 17 11:25:22 CEST 2010
So here is the next version.
Why does the intercept needs lower.tail=TRUE to give the same result as
summary() for value=0?
# See Verzani, simpleR (pdf), p. 80
coeff.test <- function(lm.result, idx, value) {
# idx = 1 is the intercept, idx>1 the other coefficients
# null hypothesis: coeff = value
# alternative hypothesis: coeff != value
coeff <- coefficients(lm.result)[idx]
SE <- coefficients(summary(lm.result))[idx,"Std. Error"]
n <- df.residual(lm.result)
t <- (coeff - value )/SE
if (idx == 1) {
2 * pt(t,n,lower.tail=TRUE) # times two because problem is two-sided
} else {
2 * pt(t,n,lower.tail=FALSE)
}
}
More information about the R-help
mailing list