Saturday, 30 March 2013

3D-Data Plotting In R


Assignment 1: Create 3 vectors, x, y, z and choose any random values for them, ensuring they are of equal length,T<- cbind(x,y,z) and Create 3 dimensional plot of the same

Solution:




plot3d(m)

plot3d(T,col=rainbow(1000),type='s')



Assignment no 2: Create 2 random variables and create 3 plots: 
 X-Y ,X-Y|Z (introducing a variable z and cbind it to x and y with 5 diff categories) 

> x<-rnorm(1500,100,10)
> y<-rnorm(1500,85,5)
> z1<-sample(letters,5)
> z2<-sample(z1,1500,replace=TRUE)
> z<-as.factor(z2)
> t<-cbind(x,y,z)

 qplot(x,y)



qplot(x,z)

qplot(x,y,geom=c("point","smooth"))




qplot(x,y,colour=z)

qplot(log(x),log(y),colour=z)


Sunday, 24 March 2013

Assignmet: Review of a tool


Gliffy: A Visio tool in your browser

The gliffy tool allows a user to draw online diagrams that can be used in one's business process and also in creating design documents.



The gliffy tool gives you everything required for the business. It helps one to create right from the business design to the business process diagram for one’s business requirement.

The beauty of the tool is such that it offers many predefined templates for the ease of creation and also provides an online document for this design which can be accessed and modified at any point of time.



The tool also allows you to create a new document allowing the custom designs to be created. The new design template can be made using the variety of design tools and symbols that are available in the package itself.



The tool also comes up with a library that contains predefined templates and other functions that are useful for creating various designs. 


 The tool also allows to do modification in the library to suit according to the user requirements.


The tool also allows multiple add in options like adding collaborators for the design and one can share the deign in their blog. The design can also be printed and modified several times.



A Simple user manual Video:




Conclusion: The tool is very useful in creating business requirement designs and it comes in handy for variety of purposes. The one disadvantage is that tool works in web browser with Macromedia flash player installed in  it. The tool can do wonders for one and it is indeed a valuable tool available online.

Friday, 15 March 2013

IT LAB: Assignment Session #8


Problem:

Perform Panel Data Analysis of "Produc" data

Solution:
There are three types of models:
      Pooled affect model
      Fixed affect model
      Random affect model

We will be determining which model is the best by using functions:
       pFtest : for determining between fixed and pooled
       plmtest : for determining between pooled and random
       phtest: for determining between random and fixed

The data can be loaded using the following command
data(Produc , package ="plm")
head(Produc)










Pooled Affect Model
 
pool <-plm( log(pcap) ~log(hwy)+ log(water)+ log(util) + log(pc) + log(gsp) + log(emp) + log(unemp), data=Produc,model=("pooling"),index =c("state","year"))
summary(pool)


  








Fixed Affect Model:

fixed<-plm( log(pcap) ~log(hwy)+ log(water)+ log(util) + log(pc) + log(gsp) + log(emp) + log(unemp), data=Produc,model=("within"),index =c("state","year"))
summary(fixed)











Random Affect Model:

random <-plm( log(pcap) ~log(hwy)+ log(water)+ log(util) + log(pc) + log(gsp) + log(emp) + log(unemp), data=Produc,model=("random"),index =c("state","year"))
> summary(random)


  

Testing of Model

This can be done through Hypothesis testing between the models as follows:

H0: Null Hypothesis: the individual index and time based params are all zero
H1: Alternate Hypothesis: atleast one of the index and time based params is non zero

Pooled vs Fixed

Null Hypothesis: Pooled Affect Model
Alternate Hypothesis : Fixed Affect Model

Command:

> pFtest(fixed,pool)


Result:

data:  log(pcap) ~ log(hwy) + log(water) + log(util) + log(pc) + log(gsp) + log(emp) + log(unemp)
F = 56.6361, df1 = 47, df2 = 761, p-value < 2.2e-16
alternative hypothesis: significant effects
Since the p value is negligible so we reject the Null Hypothesis and hence Alternate hypothesis is accepted which is to accept Fixed Affect Model.

Pooled vs Random

Null Hypothesis: Pooled Affect Model
Alternate Hypothesis: Random Affect Model

Command :
> plmtest(pool)

Result:

  Lagrange Multiplier Test - (Honda)
data:  log(pcap) ~ log(hwy) + log(water) + log(util) + log(pc) + log(gsp) + log(emp) + log(unemp)
normal = 57.1686, p-value < 2.2e-16
alternative hypothesis: significant effects

Since the p value is negligible so we reject the Null Hypothesis and hence Alternate hypothesis is accepted which is to accept Random Affect Model.

Random vs Fixed

Null Hypothesis: No Correlation . Random Affect Model
Alternate Hypothesis: Fixed Affect Model

Command:
 > phtest(fixed,random)

Result:

 Hausman Test
data:  log(pcap) ~ log(hwy) + log(water) + log(util) + log(pc) + log(gsp) + log(emp) + log(unemp)
chisq = 93.546, df = 7, p-value < 2.2e-16
alternative hypothesis: one model is inconsistent

Since the p value is negligible so we reject the Null Hypothesis and hence Alternate hypothesis is accepted which is to accept Fixed Affect Model.

Conclusion: 

So after making all the tests we come to the conclusion that Fixed Affect Model is best suited to do the panel data analysis for "Produc" data set.

Hence, we conclude that within the same id i.e. within same "state" there is no variation.