#' Summary linreg.
#'
#' Prints a summary of the linear regression model linreg.
#'
#' @param object An object of the class "linreg" from "linreg" regression function.
#' @param ... other arguments.
#'
#' @return printed infomation of the linear regression model.
#'
#'
#' @export
summary.linreg<-function(object,...){
f_test<-(object$r_squared/(length(object$p_value)-1))/((1-object$r_squared)/(object$df))
f_pvalue<-stats::pf(f_test,(length(object$p_value)-1),object$df,lower.tail = F)
sig<-vector()
for (i in 1:length(object$p_value)){
p<-object$p_value[i]
if(p>0.1){
sig[i]<-" "
}else if(p<=0.1 & p>0.05){
sig[i]<-" "
}else if(p<=0.05 & p>0.01){
sig[i]<-"."
}else if(p<=0.01 & p>0.001){
sig[i]<-"*"
}else if(p<=0.01 & p>=0.001){
sig[i]<-"**"
}else if(p<0.001){
sig[i]<-"***"
}
}
x= base::round(as.vector(object$Coefficients),5)
y= base::round((object$Std.Error),5)
z= base::round((object$t_values),5)
q= base::round(object$p_value,3)
r= sig
cat(length(x),length(y),length(z),length(q),length(r))
mat<-data.frame(x,y,z,q,r)
base::cat("Call:\n")
base::print(object$call[[1]])
base::cat("\nResiduals:\n")
base::print(summary(object$Residuals))
base::cat("\n")
rownames(mat)<-names(object$Coefficients)
colnames(mat)<-c("Estimate","Std.Error","t value","Pr(>|t|)","")
base::print(mat)
base::cat("---\n")
base::cat("Signif. codes: 0 '***', 0.001 '**', 0.01 '*', 0.05 '.', 0.1 ''\n\n")
base::cat(paste("Residual standard error:", round(object$Residuals_variance^.5,3),"on", object$df, "degrees of freedom"))
base::cat("\nR-squared:", round(object$r_squared,3),", Adjusted R-squared:", round(object$adj_r_squared,3),",")
base::cat("\nF-statistics:",f_test," on ",(length(object$p_value)-1)," and ", object$df," df, p-value : ",round(f_pvalue,3))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.