Testing1/.Rbuildignore
^.*\.Rproj$
^\.Rproj\.user$
Testing1/.Rproj.user/E408E4C2/build_options
auto_roxygenize_for_build_and_reload="1"
auto_roxygenize_for_build_package="1"
auto_roxygenize_for_check="1"
live_preview_website="1"
makefile_args=""
preview_website="1"
website_output_format="all"
Testing1/.Rproj.user/E408E4C2/cpp-definition-cache
[]
Testing1/.Rproj.user/E408E4C2/pcs/debug-breakpoints.pper
{
"debugBreakpointsState": {
"breakpoints": []
}
}
Testing1/.Rproj.user/E408E4C2/pcs/files-pane.pper
{
"sortOrder": [
{
"columnIndex": 2,
"ascending": true
}
],
"path": "F:/Projects/GreyNodes/69502/Testing1/R"
}
Testing1/.Rproj.user/E408E4C2/pcs/source-pane.pper
{
"activeTab": 0
}
Testing1/.Rproj.user/E408E4C2/pcs/windowlayoutstate.pper
{
"left": {
"splitterpos": 258,
"topwindowstate": "NORMAL",
"panelheight": 612,
"windowheight": 650 },
"right": {
"splitterpos": 522,
"topwindowstate": "NORMAL",
"panelheight": 612,
"windowheight": 650
}
}
Testing1/.Rproj.user/E408E4C2/pcs/workbench-pane.pper
{
"TabSet1": 3,
"TabSet2": 3,
"TabZoom": {}
}
Testing1/.Rproj.user/E408E4C2/persistent-state
build-last-errors="[]"
build-last-errors-base-dir="F:/Projects/GreyNodes/69502/Testing1/"
build-last-outputs="[{\"type\":0,\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\"},{\"type\":2,\"output\":\"Updating Testing1 documentation\\r\\n\"},{\"type\":2,\"output\":\"Loading Testing1\\r\\n\"},{\"type\":1,\"output\":\"Writing my_lm.Rd\\r\\nWriting my_qqplot.Rd\\r\\nWriting my_resid_fit.Rd\\r\\nWriting my_hist_resid.Rd\\r\\nWriting my_MSPE.Rd\\r\\nWriting my_F.Rd\\r\\n\"},{\"type\":2,\"output\":\"Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and will not be overwritten.\\r\\n\"},{\"type\":1,\"output\":\"Documentation completed\\n\\n\"},{\"type\":0,\"output\":\"==> Rcmd.exe INSTALL --no-multiarch --with-keep.source Testing1\\n\\n\"},{\"type\":1,\"output\":\"* installing to library 'C:/Users/dell/Documents/R/win-library/4.0'\\r\\n\"},{\"type\":1,\"output\":\"* installing *source* package 'Testing1' ...\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** using staged installation\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** R\\r\\n\"},{\"type\":1,\"output\":\"** byte-compile and prepare package for lazy loading\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** help\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** installing help indices\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\" converting help for package 'Testing1'\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\" finding HTML links ...\"},{\"type\":1,\"output\":\" my_F html \\r\\n\"},{\"type\":1,\"output\":\" my_MSPE html \"},{\"type\":1,\"output\":\" done\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"\\r\\n\"},{\"type\":1,\"output\":\" my_hist_resid html \\r\\n\"},{\"type\":1,\"output\":\" my_lm html \\r\\n\"},{\"type\":1,\"output\":\" my_qqplot html \\r\\n\"},{\"type\":1,\"output\":\" my_resid_fit \"},{\"type\":1,\"output\":\" html \"},{\"type\":1,\"output\":\"\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** building package indices\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from temporary location\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from final location\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package keeps a record of temporary installation path\\r\\n\"},{\"type\":1,\"output\":\"* DONE (Testing1)\\r\\n\"},{\"type\":1,\"output\":\"\"}]"
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
imageDirtyState="1"
saveActionState="-1"
Testing1/.Rproj.user/E408E4C2/rmd-outputs
Testing1/.Rproj.user/E408E4C2/saved_source_markers
{"active_set":"","sets":[]}
Testing1/.Rproj.user/E408E4C2/sources/prop/1381EF53
{
"cursorPosition": "153,1",
"scrollLine": "140"
}
Testing1/.Rproj.user/E408E4C2/sources/prop/8674A834
{}
Testing1/.Rproj.user/E408E4C2/sources/prop/A8436F53
{
"cursorPosition": "49,13",
"scrollLine": "44"
}
Testing1/.Rproj.user/E408E4C2/sources/prop/E11E1D39
{
"cursorPosition": "11,0",
"scrollLine": "0"
}
Testing1/.Rproj.user/E408E4C2/sources/prop/FA90EA93
{
"cursorPosition": "20,0",
"scrollLine": "9"
}
Testing1/.Rproj.user/E408E4C2/sources/prop/INDEX
F%3A%2FProjects%2FGreyNodes%2F69502%2FTesting1%2FDESCRIPTION="E11E1D39"
F%3A%2FProjects%2FGreyNodes%2F69502%2FTesting1%2FR%2FTesting1.R="1381EF53"
F%3A%2FProjects%2FGreyNodes%2F69502%2FTesting1%2FR%2Fhello.R="A8436F53"
F%3A%2FProjects%2FGreyNodes%2F69502%2FTesting1%2Fman%2Fhello.Rd="8674A834"
F%3A%2FR%20Package%2FSA%2FR%2FSA%20-%20Copy.R="FA90EA93"
Testing1/.Rproj.user/E408E4C2/sources/s-0DD8B8D6/1ECE7019-contents
#' Simple Linear Regression
#'
#' The function \code{my_lm()} is used to fit simple linear regression model.
#'
#' @param response A vector or matrix
#' @param covariates A vector or matrix
#' @param alpha level of significance, the default significance level is **0.05**.
#'
#' @return Returns \code{Residuals}, \code{beta hat},
#' \code{sigma hat}, \code{Variance of beta hat},
#' \code{Confidence Intervals of beta}, \code{fitted values},
#' \code{response} and \code{covariate} values
#'
#' @author Naveen Kumar M.Sc., \emph{Email}: \email{
[email protected]} OR \emph{WhatsApp}: \href{https://wa.me/918688896472}{Click Here}
#' @examples
#' y <- c(25,36,12,45,26,82,14,35,21,45,32)
#' x <- c(10,35,62,42,15,32,18,24,38,26,43)
#' lm_model <- my_lm(response, covariates, alpha = 0.1)
#' print(lm_model)
#'
#' @seealso \link{my_qqplot} for making \code{Normal Q-Q} plot, \link{my_resid_fit} getting missing percentage
#' \link{my_hist_resid} for missing count, \link{my_MSPE} getting missing percentage
#' \link{my_F} for missing count
#'
#' @export
my_lm = function(response, covariates, alpha = 0.05) {
# Make sure data formats are appropriate
response <- as.vector(response)
covariates <- as.matrix(covariates)
# Define parameters
n <- length(response)
p <- ncol(covariates)
df <- n - p
# Estimate beta through Eq. (6.1)
beta.hat <- solve(t(covariates)%*%covariates)%*%t(covariates)%*%response
# Estimate of the residual variance (sigma2) from Eq. (6.3)
# Compute residuals
fitted.val <- covariates%*%as.matrix(beta.hat)
resid <- response - fitted.val
sigma2.hat <- (1/df)*t(resid)%*%resid
# Estimate of the variance of the estimated beta from Eq. (6.2)
var.beta <- sigma2.hat*solve(t(covariates)%*%covariates)
# Estimate of the confidence interval based on alpha
quant <- 1 - alpha/2
ci.beta <- c(beta.hat - qnorm(p = quant)*sqrt(var.beta), beta.hat +
qnorm(p = quant)*sqrt(var.beta))
# Return all estimated values
return(list(residuals= resid, beta = beta.hat,
sigma2 = sigma2.hat, variance_beta = var.beta,
ci = ci.beta, fitted.values = fitted.val,
Response = response, Covariates = covariates))
}
Testing1/.Rproj.user/E408E4C2/sources/s-0DD8B8D6/29C2EAED
{
"id": "29C2EAED",
"path": "F:/Projects/GreyNodes/69502/Testing1/R/Testing1.R",
"project_path": "R/Testing1.R",
"type": "r_source",
"hash": "597828291",
"contents": "",
"dirty": false,
"created": 1604044128430.0,
"source_on_save": false,
"relative_order": 1,
"properties": {
"cursorPosition": "153,1",
"scrollLine": "140"
},
"folds": "",
"lastKnownWriteTime": 1604143560,
"encoding": "ISO8859-1",
"collab_server": "",
"source_window": "",
"last_content_update": 1604143560011,
"read_only": false,
"read_only_alternatives": []
}
Testing1/.Rproj.user/E408E4C2/sources/s-0DD8B8D6/29C2EAED-contents
#' Simple Linear Regression
#'
#' The function \code{my_lm()} is used to fit simple linear regression model.
#'
#' @param response A vector or matrix
#' @param covariates A vector or matrix
#' @param alpha level of significance, the default significance level is **0.05**.
#'
#' @return Returns \code{Residuals}, \code{beta hat},
#' \code{sigma hat}, \code{Variance of beta hat},
#' \code{Confidence Intervals of beta}, \code{fitted values},
#' \code{response} and \code{covariate} values
#'
#' @author Naveen Kumar M.Sc., \emph{Email}: \email{
[email protected]} OR \emph{WhatsApp}: \href{https://wa.me/918688896472}{Click Here}
#' @seealso \link{my_qqplot} for making \code{Normal Q-Q} plot, \link{my_resid_fit} residual vs fitted plot,
#' \link{my_hist_resid} for histogram of residuals, \link{my_MSPE} Calculating Mean Square Percentage Error
#' \link{my_F} for F cal, F cri & p values.
#'
#'
#' @examples
#' y <- c(25,36,12,45,26,82,14,35,21,45,32)
#' x <- c(10,35,62,42,15,32,18,24,38,26,43)
#' lm_model <- my_lm(response, covariates, alpha =...