# Social Media Analytics

Social Media Analytics

## Resources

Resources

## Introduction

Introduction

Examining the information available through social media can tell you a lot about your online presence. This is a quick exploration of some social media analytics, with examples using a personal Twitter account.

## Getting Data

Getting Data

In order to do any meaningful analysis, we’ll need to pull data from a few different sources. The first step is to connect to a social network—in this case, Twitter. We’ll also pull in some geographic data from the Wolfram Knowledgebase, as well as some data collected through an email survey.

Import a follower network from Twitter:

network=ServiceExecute["Twitter","FollowerNetwork"]

In[1]:=

Out[1]=

Grab entities for the 30 nearest cities:

cities=GeoEntities,"City"

In[2]:=

,,,,,,,,,,,,,,,,,,,,,,,,,,

Out[2]=

Import local data from the survey:

data=SemanticImport["surveydata.csv"]

In[3]:=

Out[3]=

Data types are automatically interpreted during import, so the locations in this dataset match the previous knowledgebase entities. We can easily cross-reference this data for quick analysis.

A map showing how many followers live in nearby cities:

GeoBubbleChartdata@Select[MemberQ[cities,#Location&]//CountsBy[#Location&]],

In[4]:=

Out[4]=

## Age: How Old Are Followers in the Network?

Age: How Old Are Followers in the Network?

Looking at the age spread of a network can be a good starting point for understanding its makeup. The goal here is to compute an approximate numerical distribution of ages. Since the normal distribution has convenient analytic properties, we’ll try that first.

Find the closest normal distribution fit:

FindDistribution[data[All,"Age"],TargetFunctions{NormalDistribution},MaxItems1]

In[5]:=

NormalDistribution[38.9873,5.49519]

Out[5]=

Plot the actual distribution (red) compared with the estimate (yellow):

Histogram{ages,%},Length[ages],

In[6]:=

Out[6]=

The normal distribution doesn’t quite match; the original data looks heavier on the left side than on the right. For this asymmetric shape, the skew normal distribution might be a better approximation. It has an additional parameter α that measures the skewness (slant) of the distribution.

Compare the formulas for the two distributions:

- 2 (x-μ) 2 2 σ 2π σ | - 2 (x-μ) 2 2 σ α(x-μ) 2 σ2π σ |

Normal | Skew Normal |

Out[7]=

Find starting parameters for the skew normal distribution:

FindDistributionParameters[ages,SkewNormalDistribution[μ,σ,α]]

In[8]:=

{μ35.1378,σ9.66348,α2.72919}

Out[8]=

Adjust the sliders to verify the fit visually:

Out[9]=