Sunday, October 2, 2016

Week 4 Assignment - Graphing the Variables

This week has been a challenge as the variables concerned are all categorical and don't fit well with the code given for graphing. Further, the Latitude and Longitude variables attempt to behave as quantities when they are really categories. It makes bi-variate graphing difficult as 50 % of the Lat and Long are negative. When the code attempts to sum for the graph, the results are nonsense.

To recap - My hypothesis is that Martian craters can be grouped by ejecta type and location (Latitude and Longitude) as well as size and depth. Those groupings may show similarities in the Martian subsurface composition.

This weeks code:
/* opens library containing data */
LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly;

/*pulls specific dataset from library */
data new;
    set mydata.marscrater_pds;
   
    /* Group ejecta variable by top layer */
    if index(MORPHOLOGY_EJECTA_1, '/')> 0 then
        Ejecta_1=substr(MORPHOLOGY_EJECTA_1, 1, index(MORPHOLOGY_EJECTA_1, '/')-1);
    else
        Ejecta_1=MORPHOLOGY_EJECTA_1;
    /* Recode top layer to roll up types.  */
    Ejecta = compress(substr(upcase(Ejecta_1),1,4));
    /*Convert depth from kilometrs to meters for clarity*/
    Depth_Meters = DEPTH_RIMFLOOR_TOPOG * 1000;
    /*Round latitude and Longitude to nearest quarter of a degree*/
    Long_Round = round(longitude_circle_image,.25) ;
    Lat_Round = round(latitude_circle_image,.25) ;

    /* Limit to craters 50 km or less in diameter. */
    if diam_circle_image le 50;
    /*Limit to craters described by MORPHOLOGY_EJECTA_1 variable. */
    if morphology_ejecta_1 ne ' ';

proc sort ;
    by crater_id;
/*Create univariate graphs*/
PROC GCHART; VBAR Ejecta/discrete Type=PCT;
PROC GCHART; VBAR DIAM_CIRCLE_IMAGE/ Type=PCT;
PROC GCHART; VBAR Depth_Meters/ Type=PCT;
PROC GCHART; VBAR LONGITUDE_CIRCLE_IMAGE/ Type=PCT;
PROC GCHART; VBAR LATITUDE_CIRCLE_IMAGE/ Type=PCT;
/*Create bivariate graphs*/
PROC GCHART; VBAR ejecta/discrete TYPE=mean SUMVAR=DIAM_CIRCLE_IMAGE;
title 'Diameter by Ejecta Type';
PROC GCHART; VBAR ejecta/discrete TYPE=mean SUMVAR=Depth_Meters;
Title 'Depth By Ejecta Type';
/*Create scatter plot*/
proc sgplot;
    scatter x=Long_Round y=Lat_Round ;
    Title 'Crater by Lat/Long';

The Graphs:
Ejecta Variable: Obviously the RD type is most prevalent at 60%. This may have impact on showing the relationship between Ejecta types and crater Latitude/Longitude as the RD, could overwhelm the other types.
 

Diameter Variable: The diameter variable shows a classic skewed right distribution with the peak at 3.5 kilometers.

Depth Variable: The depth variable is also a skewed right distribution with the highest percentage(15%) of craters at less than 60 meters deep.


Longitude Variable: Crater concentrations  are highest at 9 degrees north with many other peaks approximately 27 degrees, 123 degrees and 57 degrees.


Latitude Variable: Overall, crater concentration by latitude has a fairly classic single mode distribution with the peak at 23 degrees south.
 

Diameter by Ejecta Type: Because of the nature of the ejecta variable, it doesn't fall into easy distributions. Taking the peaks out you can find that distribution should start to become even at approximately 5km in diameter. This may be a key to getting a uniform population of crater types to prove my hypothesis.
 

Depth By Ejecta Type: This shows that it may become necessary to eliminate some of the ejecta types that have a small population in the first graph above in order to even this comparison of depth by ejecta type.


X/Y Plot of Latitude and longitude for a given Ejecta Variable: Latitude and Longitude were very hard to fit into any of the bi-variate graphing methods used as those methods tend to treat these variables as quantities and not categories. Oddly enough a simple x/y scatter plot lays out an interesting "map" of craters especially when filtered for type. (After all Latitude and Longitude are x and y coordinates.) The Graph below charts the crater ejecta type SLEP by latitude and longitude. The Lat/Long for each types were rounded to the nearest 1/4 degree to allow the craters to show more distinct groupings.


No comments: