HOW TO PERFORM REGRESSION ANALYSIS USING R

First Thing we need to know is: –What Regression Is: Regression is the art of finding the relationship between independent variable and dependent variable(s) or the effect of the dependent variable on the independent variable(s).

First Thing we need to know is: –What Regression Is: Regression is the art of finding the relationship between independent variable and dependent variable(s) or the effect of the dependent variable on the independent variable(s). E.g.The highest sales a particular shop made in a day is #200, it then decided to increase it awareness through advertisement either through mouth, van or radio for a month and found out that his sales increase from #200 to #500. We can then conclude that the advertisement has effect on the sales right! Yes. It does. But to what extend and how effective is the advertisement on the sales. This is what regression measure the relationship between them and the extend of the relationship. Let begin

We have collected data on sales and advertisement of the shop. Save it and import it in to R environment.

 

How To Import File Into R Environment

 

To import file into R has been a major problem many people are facing and due to not adequate orientation or not enough explanation. Stay with me and read it to the end after you are through with this you won’t have problem of such again.

FIRST STEP: Save the file you collect in “csv format” in excel. Open excel put the data in, click on save as, at “save as type” choose csv format.

SECOND STEP: Go to where the file is, right click on it, and go to property copy the location of the file.

THIRD STEP: Open R environment, type your desire name ( where the data will be stored in). then follow by read.csv (“paste the location copy here/the name used to save the file”). E.g

Ka<-read.csv(“c:/users/kabir yahya/Desktop/kaybe.csv”) while kaybe is the assume name used to save the file.

Then press enter at this point if you follow me very strictly you wont have a problem but if R bring up error, go over it again. Then finally for you to see your data that is already in R memory, press Ka, where it was store then enter. woow!! Your data shows on R environment.

To Perform Regression On Data Imported Into R Environment

 

After the data has succesfully appear in R environment you are half successful because you can use the data as you like in as much you give R correct code it execute it and give you the result.

To perform regression in R, use lm() function, the dependent variable comes first, follows by the independent variable(s) then the (data=the name we stored the data into in R environment “Ka”) E.g

By<-lm(p~q+t+r, data=Ka).

P,q,t,r are variable names in the data, Ka is the variable name where the data is stored in R memory, as shows above.

Use summary in other to display all the essential parameters you needed in the model

Parameters display are:

  • Estimate: That shows the contribution of each dependent variable (q,r,t) to the independent variable (p) which can be anything depend on what your data is on.
  • Error: Show the standard error in each estimated parameters.
  • T value: This shows the t-test for each parameters used in the model.
  • Pr(>|t|): This shows the probability of the t-test in each parameter estimated.
  • Multiple R-squared: This shows the proportion of dependent variable that is explained by the independnt variable.
  • F-statistics: This shows if jointly all the parameters are significantly contributing toward the independent varaible “P”

 

According to the graph of each independent variable(s) it show that none of the independent variables contribute toward the dependent variable.

Hope you enjoy it. Leave a comment in the comment box and will attend to it. Stay tuned***

 

Leave a Reply

Your email address will not be published. Required fields are marked *