-->

Melihat Dunia Dengan Data Sebagai Sebuah Investasi

# SIMPLE LINEAR REGRESSION USING R

Good nigth....

Together again with jendela statistik .... ehheehehe
in order to save time, let's begin reviewing discussion today regarding simple linear regression.
following on from the previous my article LINEAR REGRESSION REVIEWS MATERIAL FOR APPLIED R APPLICATION.

as we know at this time that the R program has many facilities to analyse the various techniques of statistical analysis, one is a linear regression. On linear regression there are several techniques that can be used, as described in the article LINEAR REGRESSION REVIEWS MATERIAL FOR APPLIED R APPLICATION.
In this post Jendela statistik will discuss the case of a simple linear regression with one the dependent variable and one independent variable.
Then for example use the following illustration data:

where such data is the data of a production in a factory of mineral water bottles.
When we want to see if between the room temperature with the number of the defective product has a relationships, and so it is described by a simple linear regression model.

OK, now we move on to the next step.
Open application R and prepare the data to be used
After that, we can call a data format .xlsx into R by writing the code
Data.SLR=read_excel(file.choose(), sheet = 1,col_names = TRUE, col_types = NULL)
Data.SLR
Next step, look at the value of the correlation between dependent and independent variabels using correlation test and scatterplot, by way of writing the code correlation

cor(Data.SLR\$Jumlah.Cacat,Data.SLR\$Suhu.Ruangan)
and code scatterplot
plot(Data.SLR\$Jumlah.Cacat~Data.SLR\$Suhu.Ruangan, xlab="Suhu Ruangan", ylab="Jumlah Produk Cacat", main="Produksi Botol Air Mineral")
Skaterplot results from data

The graph suggests that between the room temperature variabel with variable number of defective products have a positive relationship and is seen also from the value of the correlation test. So we will fit a simple linear regression model to the data:

by way of writing the code for model regression the following
Model.SLR = lm(Data.SLR\$Jumlah.Cacat ~ Data.SLR\$Suhu.Ruangan)

The next step is the presentation of the results:
from the output of the model summary above, value of the Adjusted R-squared is 0.8397, This means that 83.97% variation of the defective product can be explained by room temperature variations. While the rest is explained by variables other than the model.

Residual standard error: 1.555. The smaller the Residual value of the standard error of  regression models would make more precise in predicting the dependent variable.

Ater that we will see a model of the overall test:
the value of f-test is 152.9 with the value of the probability (p-value: 7.321e-13)
The following is a hypothetical test of overall model:
H0  : β1 = 0 Versus H1  : β1 ≠ 0
The p-value to the model compared to a real extent (α=5%). If less than α, then reject H0.
The results above show that the output value of the p-value of 7.321e-13 < α, then it can be inferred that the hypothesis H0 is rejected. then the regression model can be used to predict product defects.

Then we proceed to test t
The room temperature variables have values that are significant at the 0.05. from here it can be concluded that the defective product variable is affected by the temperature of the room with the mathematical equations Defective product = -23.9072 + 1.4406 room temperature

1. Kostanta of 23.9072 States that if the independent variables are considered constant then the average product defects of 23.9072 or 24 pieces.

2. The regression coefficient of room temperature 1.4406 stated that any addition of a 1 degree temperature will increase the product defect of 1.4406 or 1.

Let's learn,
Thank you for visiting my blog.