Pages

Saturday 30 March 2013

BUSINESS APPLICATION LAB SESSION-10


 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)
Create 3 dimensional plot of the same (of all the 3 types as taught) 

Commands : 
> Random1<-rnorm(30,mean=0,sd=1)
> Random1
> x<-Random1[1:10]
> x
> y<-Random1[11:20]
> y
> z<-Random1[21:30]
> z
> T<-cbind(x,y,z)
> T
>
 plot3d(T[,1:3]


plot3d(T[,1:3],col=rainbow(1000
))
plot3d(T[,1:3],col=rainbow(64),type= 's')



Assignment 2

Read the documentation of rnorm and pnorm,
Create 2 random variables
Create 3 plots:
1. X-Y
2. X-Y|Z (introducing a variable z and cbind it to z and y with 5 diff categories) Hint: ?factor
3. Color code and draw the graph
4. Smooth and best fit line for the curve

Commands :
> x<-rnorm(200,mean=5,sd=1)
> y<-rnorm(200,mean=3,sd=1)
> z1<-sample(letters,5)
> z2<-sample(z1,200,replace=TRUE)
> z<-as.factor(z2)
> t<-cbind(x,y,z)

> qplot(x,y)
qplot(x,z,alpha=I(2/10))
qplot(x,y,geom=c("point","smooth"))
 qplot(x,z)



qplot(x,y,colour=z)




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

Saturday 23 March 2013

BUSINESS APPLICATION LAB SESSION-9


Data Visualization and Analysis Tools


Tool used : Infogr.am

Infogr.am's helps users to create publishable graphics in short duration. Along with infographics, there's also a "chart" button that offers templates for bar, column line, area, pie and bubble charts; and additional formats such as word clouds, tree maps and geographic maps.

Features:
  • Runs on any browser.
  • Users have to register to use it.
  • The graphics look professional and show data details when you mouse over portions of the chart.
  • A chart's width and color scheme can be customized.

Getting Started

Using Infogram is pretty simple and straight forward. To get started, one needs to signup. After registration, you will be redirected to Infogram dashboard. The service offers users with two options: you can either create charts or infographics. The service has handful of templates in its library which can be used to create an infographic.

Creating Charts and Infographics


Creating Infographics and charts using Infogram is really easy. From Infogram dashboard, just select how you want to display your information. I did an infographic. Once selected, you will be presented with a number of templates that you can use.


One useful feature of Infogram is that you can manually place the elements like additional charts, maps, pictures, text and even videos in the template and add your information. For example, if I want the chart to appear on top of the text, I can simply drag and drop the required element and place it. You can even add multiple charts and other elements to your infographic depending on the data you want to display. To add data all you have to do is double tap anywhere on the template and add the required information. Similarly, you can also add text, title, change chart colors, and more. There is a separate button for each option on the right side of the screen.


Data can be entered by importing excel tables. I imported following table and created an infographic as described below.

Histogram for height of VGSoM students between 140-150 cm



Histogram for height of VGSoM students between 150-160 cm

Histogram for height of VGSoM students between 160-170 cm

Histogram for height of VGSoM students between 170-180 cm

Histogram for height of VGSoM students between 180+ cm    

Sharing Infographics

Finally the infographic can be shared by clicking on the Publish button to share on Facebook, Twitter, and Pinterest. The app even gives a direct link which can be shared with anyone you want, say by email or on another network.
 

Friday 15 March 2013

BUSINESS APPLICATION LAB SESSION-8


Do a Panel data analysis of "produc" data from "plm"  package using three models
1.Pooled
2.Fixed
3.Random
And analyze which model is best suited:
       pFtest : for determining between fixed and pooled
       plmtest : for determining between pooled and random
       phtest: for determining between random and fixed

Commands:
Loading data:
> 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)




Comparison

The comparison between the models would be a Hypothesis testing based on the following concept:

H0: Null Hypothesis: the individual index and time based parameters are all zero
H1: Alternate Hypothesis: atleast one of the index and time based parameter 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:
Hence the Fixed model is most suited for panel data analysis of the data"Produc".