View source: R/tvslm.r View source: R/tvslm.R
1 | tvslm(y, X)
|
y |
response vector for the regression \itemX predictor values for the regression |
Just an average student nah
tvslm(mtcars$hp,mtcars[c("mpg","wt")])
## The function is currently defined as function (y, X) y <- matrix(y) X <- as.matrix(X) X <- cbind(intercept = rep(1, length(y)), X) pred <- (solve(t(X) %*% X)) %*% t(X) %*% y fit <- X %*% pred resid <- y - fit se_temp <- sqrt(diag(as.numeric((t(resid) %*% resid)/(nrow(X) - ncol(X))) * (solve(t(X) %*% X)))) tstattemp <- pred/se_temp me <- list(predictors = pred, SE = se_temp, fitted.values = fit, residuals = resid, t.stat = tstattemp, p = 2 * (1 - pt(abs(tstattemp), (nrow(X) - ncol(X))))) class(me) <- append(class(me), "tvslm") return(me) ~kwd1 ~kwd2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.