0% found this document useful (0 votes)
78 views2 pages

BI Practical No.9

The document outlines a practical exercise in performing linear regression using a dataset in R. It explains the concept of regression analysis, specifically linear regression, and provides a step-by-step guide on applying the lm() function to create a regression model. Additionally, it includes code for predicting a weight based on height and visualizing the results with a plot.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views2 pages

BI Practical No.9

The document outlines a practical exercise in performing linear regression using a dataset in R. It explains the concept of regression analysis, specifically linear regression, and provides a step-by-step guide on applying the lm() function to create a regression model. Additionally, it includes code for predicting a weight based on height and visualizing the results with a plot.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

T.Y.BSc(I.

T) SEM-VI Business Intelligence

Practical No.9
Perform the Linear regression on the given data warehouse data.

Regression

 In statistical modeling, regression analysis is a set of statistical processes for estimating the
relationships between a dependent variable and one or more independent variables
Linear Regression

 In Linear Regression these two variables are related through an equation, where exponent
(power) of both these variables is 1.
 y = ax + b is an equation for linear regression.
 Where, y is the response variable, x is the predictor variable and a and b are constants which
are called the coefficients.

lm() Function
 In R, the lm(), or “linear model,” function can be used to create a simple regression model. The
lm() function accepts a number of arguments (“Fitting Linear Models,” n.d.).

x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
.
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)

# Apply the lm() function.


relation <- lm(y~x)

# Find weight of a person with height 170.


a <- data.frame(x = 170)
result <- predict(relation,a)
print(result)

# Give the chart file a name.


png(file = "linearregression.png")

# Plot the chart.


plot(y,x,col = "blue",main = "Height & Weight Regression",
abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Weight in Kg",ylab = "Height in cm")

# Save the file.


dev.off()

Compiled By. Prof. Ansari Mohd. Shahid & Prof.Farzin Qureshi


T.Y.BSc(I.T) SEM-VI Business Intelligence

Compiled By. Prof. Ansari Mohd. Shahid & Prof.Farzin Qureshi

You might also like