install.packages("remotes")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
remotes::install_github("brunoruas2/gujarati")
## Skipping install of 'gujarati' from a github remote, the SHA1 (a532f273) has not changed since last install.
## Use `force = TRUE` to force installation
library(gujarati)
gujarati::Table3_8
## Year NGDP RGDP
## 1 1959 506.6 2441.3
## 2 1960 526.4 2501.8
## 3 1961 544.7 2560
## 4 1962 585.6 2715.2
## 5 1963 617.7 2834
## 6 1964 663.6 2998.6
## 7 1965 719.1 3191.1
## 8 1966 787.8 3399.1
## 9 1967 832.6 3484.6
## 10 1968 910 3652.7
## 11 1969 984.6 3765.4
## 12 1970 1038.5 3771.9
## 13 1971 1127.1 3898.6
## 14 1972 1238.3 4105
## 15 1973 1382.7 4341.5
## 16 1974 1500 4319.6
## 17 1975 1638.3 4311.2
## 18 1976 1825.3 4540.9
## 19 1977 2030.9 4750.5
## 20 1978 2294.7 5015
## 21 1979 2563.3 5173.4
## 22 1980 2789.5 5161.7
## 23 1981 3128.4 5291.7
## 24 1982 3255 5189.3
## 25 1983 3536.7 5423.8
## 26 1984 3933.2 5813.6
## 27 1985 4220.3 6053.7
## 28 1986 4462.8 6263.6
## 29 1987 4739.5 6475.1
## 30 1988 5103.8 6742.7
## 31 1989 5484.4 6981.4
## 32 1990 5803.1 7112.5
## 33 1991 5995.9 7100.5
## 34 1992 6337.7 7336.6
## 35 1993 6657.4 7532.7
## 36 1994 7072.2 7835.5
## 37 1995 7397.7 8031.7
## 38 1996 7816.9 8328.9
## 39 1997 8304.3 8703.5
## 40 1998 8747 9066.9
## 41 1999 9268.4 9470.3
## 42 2000 9817 9817
## 43 2001 10128 9890.7
## 44 2002 10469.6 10048.8
## 45 2003 10960.8 10301
## 46 2004 11712.5 10703.5
## 47 2005 12455.8 11048.6
attach(Table3_8)
names(Table3_8)
## [1] "Year" "NGDP" "RGDP"
x=as.numeric(as.character(Table3_8$Year))
class(x)
## [1] "numeric"
y=as.numeric(as.character(Table3_8$NGDP))
b1=((nrow(Table3_8)*sum(x*y))-(sum(x)*sum(y)))/(nrow(Table3_8)*sum(x^2)-sum(x)^2)
mean(x)
## [1] 1982
mean(y)
## [1] 4338.632
b0=mean(y) - b1 * mean(x)
Imagen en la que se expone la fórmula para hallar Beta 1 y Beta 0
lm(y~x)
##
## Call:
## lm(formula = y ~ x)
##
## Coefficients:
## (Intercept) x
## -496267.5 252.6