a<-read.csv("E:\\Data science\\Practies\\expenditure.csv")
View(a)
attach(a)
mean(ship)
## [1] 1.17966
mean(exp)
## [1] 2.70074
median(ship)
## [1] 1.1655
median(exp)
## [1] 2.7235
sd(exp)
## [1] 0.1969706
sd(ship)
## [1] 0.05311274
var(exp)
## [1] 0.03879742
var(ship)
## [1] 0.002820964
library(moments)
skewness(a)
##       ship        exp 
##  0.2936755 -0.2234026
kurtosis(a)
##     ship      exp 
## 2.773710 1.593454
hist(ship)

hist(exp)

barplot(exp)

barplot(ship)

boxplot(exp)

boxplot(ship)

cor(ship,exp)
## [1] 0.7582614
plot(ship,exp)

m1<-lm(exp~ship,data=a)
summary(m1)
## 
## Call:
## lm(formula = exp ~ ship, data = a)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.216952 -0.101899 -0.002395  0.090965  0.308161 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -0.6165     0.4121  -1.496    0.141    
## ship          2.8120     0.3490   8.058  1.8e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1297 on 48 degrees of freedom
## Multiple R-squared:  0.575,  Adjusted R-squared:  0.5661 
## F-statistic: 64.93 on 1 and 48 DF,  p-value: 1.8e-10
m2<-lm(exp~log(ship),data=a)
summary(m2)
## 
## Call:
## lm(formula = exp ~ log(ship), data = a)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.219732 -0.100972 -0.004189  0.088629  0.307779 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.14983    0.06969  30.848  < 2e-16 ***
## log(ship)    3.35429    0.40964   8.188 1.14e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1285 on 48 degrees of freedom
## Multiple R-squared:  0.5828, Adjusted R-squared:  0.5741 
## F-statistic: 67.05 on 1 and 48 DF,  p-value: 1.145e-10
m3<-lm(exp~sqrt(ship),data=a)
summary(m3)
## 
## Call:
## lm(formula = exp ~ sqrt(ship), data = a)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.218321 -0.102346 -0.003258  0.089748  0.308015 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -3.9721     0.8215  -4.835 1.41e-05 ***
## sqrt(ship)    6.1453     0.7563   8.125 1.43e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1291 on 48 degrees of freedom
## Multiple R-squared:  0.579,  Adjusted R-squared:  0.5702 
## F-statistic: 66.02 on 1 and 48 DF,  p-value: 1.425e-10
m4<-lm(log(exp)~ship,data=a)
summary(m4)
## 
## Call:
## lm(formula = log(exp) ~ ship, data = a)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.08208 -0.03732  0.00068  0.03260  0.11462 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -0.2543     0.1538  -1.653    0.105    
## ship          1.0555     0.1302   8.104 1.53e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.04842 on 48 degrees of freedom
## Multiple R-squared:  0.5777, Adjusted R-squared:  0.5689 
## F-statistic: 65.68 on 1 and 48 DF,  p-value: 1.534e-10
pv<-predict(m2)
pv
##        1        2        3        4        5        6        7        8 
## 2.679337 2.707860 2.838762 2.744581 2.752998 2.685061 2.553846 2.595221 
##        9       10       11       12       13       14       15       16 
## 2.653457 2.653457 2.827818 2.827818 2.874085 2.874085 2.836029 2.836029 
##       17       18       19       20       21       22       23       24 
## 2.884879 2.884879 2.890263 2.890263 3.047894 3.047894 2.855111 2.855111 
##       25       26       27       28       29       30       31       32 
## 2.786458 2.786458 2.755799 2.562755 2.562755 2.621553 2.621553 2.633189 
##       33       34       35       36       37       38       39       40 
## 2.633189 2.627376 2.627376 2.609875 2.609875 2.641890 2.641890 2.547894 
##       41       42       43       44       45       46       47       48 
## 2.547894 2.656342 2.656342 2.670732 2.670732 2.529972 2.529972 2.407985 
##       49       50 
## 2.407985 2.392419
pv1<-as.data.frame(pv)
pv1
##          pv
## 1  2.679337
## 2  2.707860
## 3  2.838762
## 4  2.744581
## 5  2.752998
## 6  2.685061
## 7  2.553846
## 8  2.595221
## 9  2.653457
## 10 2.653457
## 11 2.827818
## 12 2.827818
## 13 2.874085
## 14 2.874085
## 15 2.836029
## 16 2.836029
## 17 2.884879
## 18 2.884879
## 19 2.890263
## 20 2.890263
## 21 3.047894
## 22 3.047894
## 23 2.855111
## 24 2.855111
## 25 2.786458
## 26 2.786458
## 27 2.755799
## 28 2.562755
## 29 2.562755
## 30 2.621553
## 31 2.621553
## 32 2.633189
## 33 2.633189
## 34 2.627376
## 35 2.627376
## 36 2.609875
## 37 2.609875
## 38 2.641890
## 39 2.641890
## 40 2.547894
## 41 2.547894
## 42 2.656342
## 43 2.656342
## 44 2.670732
## 45 2.670732
## 46 2.529972
## 47 2.529972
## 48 2.407985
## 49 2.407985
## 50 2.392419