# Introduction To install this package you can use the code below:
devtools::install_github('shihs/LiUAdRLab4',build_vignettes = TRUE)
This package can handle multiple linear regression. To make this package, the RC object orientation has been used and the output is an object with the class named linreg. The object will be created by giving a formula for implementing the relationship between dependent variable and all of the independent variables and also by giving the dataset containing the values of the variables. Here for showing the details about the package, we have used of one of the famous datasets in R, named iris4. The object that will be create in this package contains different methods; The details about these methods will be presented in the following sessions of this document. The regression modeling and related calculations have been used as the initialize method in this package and in this method the QR decomposition has been used. To show the usage and outputs of each method we will use of bellow regression model for iris dataset:
#Here we can create our new object that contained the multiple regression model and other methods testobject <- linreg$new(formula = Petal.Length ~ Species, data = iris4)
In this method we can print the coefficients of the solution. Here you can see the way that you can use of the method and the output:
testobject$print() #output: #Call: #linreg(formula = Petal.Length ~ Species, data = iris4) #Coefficients: #(Intercept) Speciesversicolor Speciesvirginica # 1.462 2.798 4.09
By using this method in a way that has shown here, you can see 2 plots. Residuals vs fitted values and the plot of scaled residuals vs fitted values.
The plots for the testobject can be seen here.
testobject$plot()
This method returns the vector of residuals
testobject$resid()
This method returns the predicted values for dependent variable
testobject$pred()
This method returns the coeficients as a named vector
testobject$coef() #output: #(Intercept) Speciesversicolor Speciesvirginica # 1.462 2.798 4.090
This method returns the coeficients with their standard error, t-value and p-value as well as the estimate of residual variance and the degrees of freedom in the model.
testobject$summary() #output: #Call: #linreg(formula = Petal.Length ~ Species, data = iris4) #Residuals: # Min 1Q Median 3Q Max # -1.260 -0.258 0.038 0.240 1.348 #Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 1.462 0.061 24.023 0 *** # Speciesversicolor 2.798 0.086 32.51 0 *** # Speciesvirginica 4.09 0.086 47.521 0 *** #Residual standard error: 0.43 on 147 degrees of freedom
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.