Codi

library(readr)
venecia <- read_csv("C:/Users/Pere/Downloads/Datos_Sesion3/venecia.txt")
names(venecia) <- c("nivell", "any")
plot(venecia[2:1])
summary(lm(nivell~any, data=venecia))
plot(nivell~any, data=venecia)
abline(lm(nivell~any, data=venecia), col="red")

reg <- read_delim("C:/Users/Pere/Downloads/Datos_Sesion3/reg.txt",
";", escape_double = FALSE, trim_ws = TRUE)

plot(y1~x1, data=reg)
abline(lm(y1~x1, data=reg), col="red")
summary(lm(y1~x1, data=reg))

plot(y2~x2, data=reg)
abline(lm(y2~x2, data=reg), col="red")
summary(lm(y2~x2, data=reg))

plot(y3~x3, data=reg)
abline(lm(y3~x3, data=reg), col="red")
summary(lm(y3~x3, data=reg))

plot(y4~x4, data=reg)
abline(lm(y4~x4, data=reg), col="red")
summary(lm(y4~x4, data=reg))

summary(lm(nivell~any, data=venecia[-c(36,49),]))
plot(nivell~any, data=venecia[-c(36,49),])
abline(lm(nivell~any, data=venecia[-c(36,49),]), col="red")

petroli <- read.table("~/petroleo.txt",
                      sep=",",
                      header=TRUE)
plot(petroli)

petroli$lMbbl <- log(petroli$Mbbl)
model <- lm(lMbbl~Year, data=petroli)
summary(model)
predict(model, newdata=data.frame(Year=2000))
exp(predict(model, newdata=data.frame(Year=2000)))

1880:1990
exp(predict(model, newdata=data.frame(Year=1880:1990)))
lines(1880:1990, 
      exp(predict(model, newdata=data.frame(Year=1880:1990))),
      col="red")

cemento <- read_delim("C:/Users/Pere/Downloads/Datos_Sesion3/cemento.txt",
                      ";", escape_double = FALSE, col_names = FALSE,
                      locale = locale(decimal_mark = ","),
                      trim_ws = TRUE)
names(cemento) <- c("dies", "MPa")
plot(cemento)
summary(lm(MPa~dies, data=cemento))
plot(MPa~dies, data=cemento)
abline(lm(MPa~dies, data=cemento), col="red")

summary(lm(MPa~I(sqrt(1/dies)), data=cemento))
plot(MPa~I(sqrt(1/dies)), data=cemento)
abline(lm(MPa~I(sqrt(1/dies)), data=cemento), col="red")

summary(lm(log10(MPa)~I(sqrt(1/dies)), data=cemento))
plot(log10(MPa)~I(sqrt(1/dies)), data=cemento)
abline(lm(log10(MPa)~I(sqrt(1/dies)), data=cemento), col="red")

Codi i resultats

library(readr)
venecia <- read_csv("C:/Users/Pere/Downloads/Datos_Sesion3/venecia.txt")
## Parsed with column specification:
## cols(
##   nivel = col_double(),
##   `a<f1>o` = col_double()
## )
names(venecia) <- c("nivell", "any")
plot(venecia[2:1])

summary(lm(nivell~any, data=venecia))
## 
## Call:
## lm(formula = nivell ~ any, data = venecia)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -33.813 -11.211  -3.309   9.515  68.722 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -989.3822   346.4770  -2.856  0.00628 **
## any            0.5670     0.1771   3.201  0.00241 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 18.62 on 49 degrees of freedom
## Multiple R-squared:  0.1729, Adjusted R-squared:  0.1561 
## F-statistic: 10.25 on 1 and 49 DF,  p-value: 0.002406
plot(nivell~any, data=venecia)
abline(lm(nivell~any, data=venecia), col="red")

reg <- read_delim("C:/Users/Pere/Downloads/Datos_Sesion3/reg.txt",
";", escape_double = FALSE, trim_ws = TRUE)
## Parsed with column specification:
## cols(
##   x1 = col_double(),
##   y1 = col_number(),
##   x2 = col_double(),
##   y2 = col_number(),
##   x3 = col_double(),
##   y3 = col_number(),
##   x4 = col_double(),
##   y4 = col_number()
## )
plot(y1~x1, data=reg)
abline(lm(y1~x1, data=reg), col="red")

summary(lm(y1~x1, data=reg))
## 
## Call:
## lm(formula = y1 ~ x1, data = reg)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -192.127  -45.577   -4.136   70.941  183.882 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   300.01     112.47   2.667  0.02573 * 
## x1             50.01      11.79   4.241  0.00217 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 123.7 on 9 degrees of freedom
## Multiple R-squared:  0.6665, Adjusted R-squared:  0.6295 
## F-statistic: 17.99 on 1 and 9 DF,  p-value: 0.00217
plot(y2~x2, data=reg)
abline(lm(y2~x2, data=reg), col="red")

summary(lm(y2~x2, data=reg))
## 
## Call:
## lm(formula = y2 ~ x2, data = reg)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -190.09  -76.09   12.91   94.91  126.91 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)    300.1      112.5   2.667  0.02576 * 
## x2              50.0       11.8   4.239  0.00218 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 123.7 on 9 degrees of freedom
## Multiple R-squared:  0.6662, Adjusted R-squared:  0.6292 
## F-statistic: 17.97 on 1 and 9 DF,  p-value: 0.002179
plot(y3~x3, data=reg)
abline(lm(y3~x3, data=reg), col="red")

summary(lm(y3~x3, data=reg))
## 
## Call:
## lm(formula = y3 ~ x3, data = reg)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -115.86  -61.46  -23.03   15.40  324.11 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   300.25     112.45   2.670  0.02562 * 
## x3             49.97      11.79   4.239  0.00218 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 123.6 on 9 degrees of freedom
## Multiple R-squared:  0.6663, Adjusted R-squared:  0.6292 
## F-statistic: 17.97 on 1 and 9 DF,  p-value: 0.002176
plot(y4~x4, data=reg)
abline(lm(y4~x4, data=reg), col="red")

summary(lm(y4~x4, data=reg))
## 
## Call:
## lm(formula = y4 ~ x4, data = reg)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -175.1  -83.1    0.0   80.9  183.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   300.17     112.39   2.671  0.02559 * 
## x4             49.99      11.78   4.243  0.00216 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 123.6 on 9 degrees of freedom
## Multiple R-squared:  0.6667, Adjusted R-squared:  0.6297 
## F-statistic:    18 on 1 and 9 DF,  p-value: 0.002165
summary(lm(nivell~any, data=venecia[-c(36,49),]))
## 
## Call:
## lm(formula = nivell ~ any, data = venecia[-c(36, 49), ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -29.334  -9.165  -0.688   7.825  37.984 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -705.0774   289.5564  -2.435  0.01874 * 
## any            0.4205     0.1481   2.840  0.00665 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.1 on 47 degrees of freedom
## Multiple R-squared:  0.1464, Adjusted R-squared:  0.1283 
## F-statistic: 8.064 on 1 and 47 DF,  p-value: 0.006653
plot(nivell~any, data=venecia[-c(36,49),])
abline(lm(nivell~any, data=venecia[-c(36,49),]), col="red")

petroli <- read.table("C:/Users/Pere/Downloads/Datos_Sesion3/petroleo.txt",
                      sep=",",
                      header=TRUE)
plot(petroli)

petroli$lMbbl <- log(petroli$Mbbl)
model <- lm(lMbbl~Year, data=petroli)
summary(model)
## 
## Call:
## lm(formula = lMbbl ~ Year, data = petroli)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.53738 -0.06588  0.04655  0.12515  0.29507 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.154e+02  2.533e+00  -45.55   <2e-16 ***
## Year         6.342e-02  1.302e-03   48.71   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2046 on 25 degrees of freedom
## Multiple R-squared:  0.9896, Adjusted R-squared:  0.9892 
## F-statistic:  2373 on 1 and 25 DF,  p-value: < 2.2e-16
predict(model, newdata=data.frame(Year=2000))
##        1 
## 11.43577
exp(predict(model, newdata=data.frame(Year=2000)))
##       1 
## 92574.2
1880:1990
##   [1] 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893
##  [15] 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907
##  [29] 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921
##  [43] 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935
##  [57] 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949
##  [71] 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963
##  [85] 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977
##  [99] 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
exp(predict(model, newdata=data.frame(Year=1880:1990)))
##           1           2           3           4           5           6 
##    45.86034    48.86291    52.06207    55.47069    59.10247    62.97204 
##           7           8           9          10          11          12 
##    67.09496    71.48781    76.16827    81.15517    86.46857    92.12986 
##          13          14          15          16          17          18 
##    98.16180   104.58866   111.43631   118.73229   126.50595   134.78856 
##          19          20          21          22          23          24 
##   143.61346   153.01614   163.03444   173.70866   185.08174   197.19944 
##          25          26          27          28          29          30 
##   210.11051   223.86690   238.52395   254.14063   270.77977   288.50830 
##          31          32          33          34          35          36 
##   307.39757   327.52355   348.96722   371.81486   396.15838   422.09573 
##          37          38          39          40          41          42 
##   449.73124   479.17612   510.54882   543.97555   579.59080   617.53786 
##          43          44          45          46          47          48 
##   657.96940   701.04808   746.94721   795.85146   847.95757   903.47519 
##          49          50          51          52          53          54 
##   962.62766  1025.65297  1092.80468  1164.35297  1240.58567  1321.80949 
##          55          56          57          58          59          60 
##  1408.35122  1500.55901  1598.80385  1703.48099  1815.01157  1933.84430 
##          61          62          63          64          65          66 
##  2060.45726  2195.35985  2339.09480  2492.24038  2655.41274  2829.26835 
##          67          68          69          70          71          72 
##  3014.50666  3211.87292  3422.16118  3646.21746  3884.94319  4139.29881 
##          73          74          75          76          77          78 
##  4410.30765  4699.06001  5006.71762  5334.51823  5683.78066  6055.91006 
##          79          80          81          82          83          84 
##  6452.40357  6874.85636  7324.96806  7804.54953  8315.53025  8859.96597 
##          85          86          87          88          89          90 
##  9440.04708 10058.10735 10716.63335 11418.27448 12165.85357 12962.37828 
##          91          92          93          94          95          96 
## 13811.05318 14715.29266 15678.73465 16705.25526 17798.98440 18964.32235 
##          97          98          99         100         101         102 
## 20205.95749 21528.88516 22938.42777 24440.25617 26040.41253 27745.33457 
##         103         104         105         106         107         108 
## 29561.88155 31497.36177 33559.56207 35756.77907 38097.85262 40592.20131 
##         109         110         111 
## 43249.86039 46081.52215 49098.57892
lines(1880:1990, 
      exp(predict(model, newdata=data.frame(Year=1880:1990))),
      col="red")

cemento <- read_delim("C:/Users/Pere/Downloads/Datos_Sesion3/cemento.txt",
                      ";", escape_double = FALSE, col_names = FALSE,
                      locale = locale(decimal_mark = ","),
                      trim_ws = TRUE)
## Parsed with column specification:
## cols(
##   X1 = col_double(),
##   X2 = col_double()
## )
names(cemento) <- c("dies", "MPa")
plot(cemento)

summary(lm(MPa~dies, data=cemento))
## 
## Call:
## lm(formula = MPa ~ dies, data = cemento)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.4452  -2.0034   0.7848   3.4385   8.5059 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  22.5871     1.6831  13.420 3.84e-11 ***
## dies          0.6581     0.1187   5.546 2.38e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.739 on 19 degrees of freedom
## Multiple R-squared:  0.6182, Adjusted R-squared:  0.5981 
## F-statistic: 30.76 on 1 and 19 DF,  p-value: 2.382e-05
plot(MPa~dies, data=cemento)
abline(lm(MPa~dies, data=cemento), col="red")

summary(lm(MPa~I(sqrt(1/dies)), data=cemento))
## 
## Call:
## lm(formula = MPa ~ I(sqrt(1/dies)), data = cemento)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7947 -1.2567 -0.0567  1.8954  3.1053 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       45.655      1.023   44.63  < 2e-16 ***
## I(sqrt(1/dies))  -32.599      1.764  -18.48 1.34e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.133 on 19 degrees of freedom
## Multiple R-squared:  0.9473, Adjusted R-squared:  0.9445 
## F-statistic: 341.4 on 1 and 19 DF,  p-value: 1.337e-13
plot(MPa~I(sqrt(1/dies)), data=cemento)
abline(lm(MPa~I(sqrt(1/dies)), data=cemento), col="red")

summary(lm(log10(MPa)~I(sqrt(1/dies)), data=cemento))
## 
## Call:
## lm(formula = log10(MPa) ~ I(sqrt(1/dies)), data = cemento)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.083275 -0.031305 -0.002137  0.023595  0.075087 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      1.73240    0.02165   80.02  < 2e-16 ***
## I(sqrt(1/dies)) -0.57725    0.03734  -15.46 3.23e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.04513 on 19 degrees of freedom
## Multiple R-squared:  0.9264, Adjusted R-squared:  0.9225 
## F-statistic:   239 on 1 and 19 DF,  p-value: 3.232e-12
plot(log10(MPa)~I(sqrt(1/dies)), data=cemento)
abline(lm(log10(MPa)~I(sqrt(1/dies)), data=cemento), col="red")

Formigó

Evolució de la resistència del formigó segons el codi model:

\[\frac{f_{ck}(t)}{f_{ck}(28)}=exp(s(1-\sqrt{\frac{28}{t}}))\]