-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegressin.R
More file actions
40 lines (29 loc) · 901 Bytes
/
Regressin.R
File metadata and controls
40 lines (29 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#Regression :
#1. Linear Regression
#2. Multiple Regression
#1. Linear Regression :
#Only one predicator variable is used in linear regressin
#Formula for Linear Regression :
# Y = B1 + B2X+E
#lm command is used to calculate Linear Regression
demo <- data.frame(age = 1:10 , height = c(10.2,10.4,10.7,11.7,111.1,101,102,100.17,170,15.1))
demo
predictHeight = lm( height ~ age , data = demo)
predictHeight
x <- data.frame(age = c(11,12,13))
x
print(predict(predictHeight,x))
#output:
#1 2 3
#126.552 137.882 149.212
#Multiple Regression :
#Here more than one predicator variables are available
dataframe <- data.frame(x = c(10,20,30,40),y = c(10,20,30,40),sum = c(20,40,60,80))
dataframe
sum <- lm(sum ~ x+y,data = dataframe)
sum
z <- data.frame(x = c(50,60,70),y=c(50,60,70))ddd
print(predict(sum,z))
#output :
#1 2 3
#100 120 140