Demo1

Data Set 1

Data Discription

Naturalgas is a panel data set from the “ARE” package, originating from 6 U.S. States from 1967-1989. The source of data is from Baltagi(2002).

It contains 138 observations on 10 variables.Variables includes: (a) state. It’s state abbreviation. (b) state code. (c) year. It denotes coding year. (d) consumption. It denotes consumption of natural gas by the residential sector. (e) Price. It denotes the price of natural gas. (f) eprice. It denotes the price of electricity. (g) oprice. It denotes the price of distillate fuel oil. (h) lprice. It denotes the price of liquefied petroleum gas. (i) heating. It denotes the heating degree days. (j) income. It denotes the real per-capita personal income.

People can use this dataset to analyze the factors affecting the price of natural gas.

Data Setting

library(AER)
Loading required package: car
Loading required package: carData
Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'
The following objects are masked from 'package:base':

    as.Date, as.Date.numeric
Loading required package: sandwich
Loading required package: survival
library(foreign)
data("NaturalGas")
Panel <- NaturalGas

Data

head(x = Panel, n = 15L)
   state statecode year consumption price eprice oprice lprice heating   income
1     NY        35 1967      313656  1.42   2.98   7.40   1.47    6262 10903.75
2     NY        35 1968      319282  1.38   2.91   7.77   1.42    6125 11370.02
3     NY        35 1969      331326  1.37   2.84   7.96   1.38    6040 11578.68
4     NY        35 1970      346533  1.40   2.87   8.33   1.37    6085 11586.77
5     NY        35 1971      352085  1.50   3.07   8.80   1.40    5907 11657.42
6     NY        35 1972      363412  1.62   3.26   8.85   1.50    6248 11860.80
7     NY        35 1973      342608  1.74   3.51  10.08   1.62    5450 11943.15
8     NY        35 1974      341032  2.00   4.66  15.49   1.74    5858 11951.04
9     NY        35 1975      327384  2.54   5.13  16.37   2.00    5583 11653.49
10    NY        35 1976      339949  2.87   5.37  17.30   2.54    6238 11689.96
11    NY        35 1977      325603  3.28   5.88  19.63   2.87    6022 11806.46
12    NY        35 1978      330968  3.68   6.07  21.03   3.28    6444 12001.86
13    NY        35 1979      313027  4.12   6.67  29.88   3.68    5951 12134.59
14    NY        35 1980      333902  4.95   7.54  41.24   4.12    6272 12466.71
15    NY        35 1981      336813  5.50   9.34  51.73   4.95    6046 12664.78
table(Panel$year, Panel$state)
      
       CA FL MI NY TX UT
  1967  1  1  1  1  1  1
  1968  1  1  1  1  1  1
  1969  1  1  1  1  1  1
  1970  1  1  1  1  1  1
  1971  1  1  1  1  1  1
  1972  1  1  1  1  1  1
  1973  1  1  1  1  1  1
  1974  1  1  1  1  1  1
  1975  1  1  1  1  1  1
  1976  1  1  1  1  1  1
  1977  1  1  1  1  1  1
  1978  1  1  1  1  1  1
  1979  1  1  1  1  1  1
  1980  1  1  1  1  1  1
  1981  1  1  1  1  1  1
  1982  1  1  1  1  1  1
  1983  1  1  1  1  1  1
  1984  1  1  1  1  1  1
  1985  1  1  1  1  1  1
  1986  1  1  1  1  1  1
  1987  1  1  1  1  1  1
  1988  1  1  1  1  1  1
  1989  1  1  1  1  1  1
summary(Panel)
 state   statecode      year      consumption         price      
 CA:23   5 :23     1967   :  6   Min.   :  9430   Min.   :0.680  
 FL:23   10:23     1968   :  6   1st Qu.: 49104   1st Qu.:1.380  
 MI:23   23:23     1969   :  6   Median :300836   Median :2.775  
 NY:23   35:23     1970   :  6   Mean   :252902   Mean   :3.422  
 TX:23   44:23     1971   :  6   3rd Qu.:346429   3rd Qu.:5.310  
 UT:23   45:23     1972   :  6   Max.   :637289   Max.   :8.060  
                   (Other):102                                   
     eprice           oprice          lprice         heating    
 Min.   : 1.980   Min.   : 5.01   Min.   :0.680   Min.   : 481  
 1st Qu.: 2.433   1st Qu.: 8.24   1st Qu.:1.258   1st Qu.:2082  
 Median : 4.520   Median :19.86   Median :2.615   Median :4272  
 Mean   : 5.054   Mean   :24.64   Mean   :3.208   Mean   :4155  
 3rd Qu.: 7.282   3rd Qu.:40.10   3rd Qu.:5.192   3rd Qu.:6498  
 Max.   :10.860   Max.   :51.73   Max.   :7.870   Max.   :7440  
                                                                
     income     
 Min.   : 7465  
 1st Qu.: 9637  
 Median :11367  
 Mean   :11193  
 3rd Qu.:12125  
 Max.   :16425  
                
coplot(data     =  Panel,
       formula  = price ~ year | state)

 library(ggplot2)
 ggplot(Panel, aes(x=year,y= price,color= state))+
  geom_point()