com="G:/R studio/LinearRegressionModel datasets/Computer_Data.csv"
com=read.csv(com)
summary(com)
## X price speed hd
## Min. : 1 Min. : 949 Min. : 25.00 Min. : 80.0
## 1st Qu.:1566 1st Qu.:1794 1st Qu.: 33.00 1st Qu.: 214.0
## Median :3130 Median :2144 Median : 50.00 Median : 340.0
## Mean :3130 Mean :2220 Mean : 52.01 Mean : 416.6
## 3rd Qu.:4694 3rd Qu.:2595 3rd Qu.: 66.00 3rd Qu.: 528.0
## Max. :6259 Max. :5399 Max. :100.00 Max. :2100.0
## ram screen cd multi premium
## Min. : 2.000 Min. :14.00 no :3351 no :5386 no : 612
## 1st Qu.: 4.000 1st Qu.:14.00 yes:2908 yes: 873 yes:5647
## Median : 8.000 Median :14.00
## Mean : 8.287 Mean :14.61
## 3rd Qu.: 8.000 3rd Qu.:15.00
## Max. :32.000 Max. :17.00
## ads trend
## Min. : 39.0 Min. : 1.00
## 1st Qu.:162.5 1st Qu.:10.00
## Median :246.0 Median :16.00
## Mean :221.3 Mean :15.93
## 3rd Qu.:275.0 3rd Qu.:21.50
## Max. :339.0 Max. :35.00
comp=com[,-c(1,11)]
comp
attach(comp)
final<- cbind(comp,cd,multi,premium)
computer=final[,-c(6,7,8)]
#plot
windows()
plot(computer)

#linear Regression
m1=lm(price ~ log(speed)+log(hd)+log(ram)+log(screen)+log(ads)+as.numeric(cd)+as.numeric(multi)+as.numeric(premium),data=computer)
summary(m1)
##
## Call:
## lm(formula = price ~ log(speed) + log(hd) + log(ram) + log(screen) +
## log(ads) + as.numeric(cd) + as.numeric(multi) + as.numeric(premium),
## data = computer)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1103.30 -245.42 -33.04 208.52 2423.46
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3814.57 246.41 -15.481 <2e-16 ***
## log(speed) 347.33 13.52 25.689 <2e-16 ***
## log(hd) -161.35 14.93 -10.810 <2e-16 ***
## log(ram) 734.40 13.35 55.025 <2e-16 ***
## log(screen) 1394.22 86.71 16.080 <2e-16 ***
## log(ads) 252.23 11.56 21.812 <2e-16 ***
## as.numeric(cd) -136.34 13.01 -10.482 <2e-16 ***
## as.numeric(multi) 13.24 15.97 0.829 0.407
## as.numeric(premium) -348.13 17.18 -20.268 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 387.9 on 6250 degrees of freedom
## Multiple R-squared: 0.5544, Adjusted R-squared: 0.5539
## F-statistic: 972.2 on 8 and 6250 DF, p-value: < 2.2e-16
#significant
pv=as.data.frame(predict(m1,computer))
pv
final=cbind(computer,pv)
final