Sunday, 31 March 2013

Assignment #10

3D PLOTTING


Assignment 1: 

Create 3 vectors, x, y, z and choose any random values for them, ensuring they are of equal length, bind them together.Create 3 dimensional plots of the same.

Data Set Creation Commands and DataSet :


Plotting 3D plot:

Normal Plot:   plot3d(T[, 1:3])


Colour Plot: plot3d(T[, 1:3], col = rainbow(1000))


Color Plot of spheres:  plot3d(T[, 1:3], col = rainbow(1000), type = 's')




Assignment 2:

Choose 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)
3. Color code and draw the graph 
4. Smooth and best fit line for the curve


Data set creation for two random variables and then introducing third variable z



Plots:

>qplot(x,y)


>qplot(x,z)


Semi-transparent plot

> qplot(x,z, alpha=I(2/10))


Colour plot

> qplot(x,y, color=z)

Logarithmic colour plot

> qplot(log(x),log(y), color=z)




Best Fit and Smooth curve using "geom"

> qplot(x,y,geom=c("path","smooth"))




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




> qplot(x,y,geom=c("boxplot","jitter"))









Saturday, 23 March 2013

Assignment #9 19 March 2013

Analysis of a tool 

QGIS


Q Geographic information system -A substitute of ARC view used in the field of geomatics engineering.
It is used to analyse and prepare maps of any place and are extremely useful to find out data such as minerals
as well as land cover, vegetation and innumerable other things.

What it does: This is full-fledged GIS software, designed for creating maps that offer sophisticated, detailed data-based analysis of a geographic regions.

The best-known desktop GIS software is probably Esri’s ArcView, a robust, well-supported application that costs quite a bit of money. The open-source QGIS is an alternative to ArcView.

As OpenOffice is to Microsoft Office, QGIS is to ArcView. ArcView enthusiasts argue that Esri’s offering is a couple of years ahead of open-source alternatives, has a better-developed interface, enjoys commercial support and is better suited for print output. But QGIS users say the open-source alternative is an excellent program that does a great deal of useful GIS work — and may even be better than ArcView when it comes to generating maps for the Web, thanks to a plug-in dedicated to generating HTML image maps.

Unique feature: QGIS has an enormous amount of GIS functionality, including the ability to create maps, overlay various types of data, do spatial analysis, publish to the Web and more. It can also be enhanced with plug-ins that add support for numerous undertakings, including geocoding, managing underlying table data, exporting to MySQL and generating HTML image maps.

Drawbacks: As with any sophisticated GIS application, learning to use this software entails a serious commitment of time and training. Even in hour-long hands-on sessions with first ArcView and then QGIS, I noticed things that were easier to do in the commercial option. For example, ArcView had a one-click “normalize” function to immediately calculate, say, the percentage of people 65 and over versus the total population from a data table with both columns; in QGIS, I needed to pull up a “field calculator” and create a new column with the formula to do that calculation myself.

Runs on: Linux, Unix, Mac OS X, Windows. (This is one case where installation is more complicated on OS X, since it requires manual installation of several dependencies. There’s a one-click installer for Windows.)

Skill level: Intermediate to expert.

Learn more: Timothy Barmann of The Providence Journal posted two very useful tutorials for the CAR conference that are still available: Introduction to QGIS and The Latest in Mapping With JavaScript and jQuery. Barmann also offers a sample: Rhode Island’s Ethnic Mosaic. Another resource to help you get started: QGIS Tutorial Labs from Richard E. Plant, professor emeritus at the University of California, Davis.

Note:
If you’re interested in GIS and want to consider other free software options, download this PDF listing of Open Source/Non-Commercial GIS Products. And if you’re looking for a free open-source desktop GIS program that might be fairly easy to use, Jacob Fenton, director of computer-assisted reporting at American University’s Investigative Reporting Workshop, recommends taking a look at the System for Automated Geoscientific Analyses (SAGA) site. Finally, if analyzing geographic data in a conventional database sounds interesting, PostGIS “spatially enables” the PostgreSQL relational database, according to the site.

Web-based GIS/mapping

Most of us are familiar with mapping tools from major companies like Google(which has a number of third-party front ends such as Map A List, an add-on that adds info to a Google Map from a spreadsheet). There’s also Yahoo Maps Web Services and Bing Maps — all with APIs. But there are numerous other options from smaller organizations or lone open-source enthusiasts that were designed from the ground up to map geographic data.

Screenshot:




Friday, 15 March 2013

Assignment no 8

Assignment #8


Assignment no:-1
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:
      1) pFtest : for determining between fixed and pooled
      2) plmtest : for determining between pooled and random
      3) phtest: for determining between random and fixed
The data can be loaded using the following commands:-
data(Produc , package =”plm”)
head(Produc)
Screenshot:-
Image

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)
Screenshot:-
Image

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)
Screenshot:-
Image
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)
Screenshot:-
Image
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.