Docsity
Trusted Seller

Appunti completi data analysis, Appunti di Analisi Dei Dati

Toggle sidebar
bg1
20/09/2021
INTRODUCTION TO THE COURSE
COURSE OVERVIEW
Data are empirical material organised in a form that can be analysed
Excel is very old but efficient and it can be considered an important basis for other platforms
Spreadsheet is an interactive computer app for organisation analysis and storage of data in tabular form, it consists of a
table of cells arranged into rows and columns and referred as X and Y locations
Cell -> box for holding data
Worksheet -> grid of vells with raw data (values) or formulas in the cells
Values -> raw data or a value that can be based on a formula (numbers, text, data)
Formulas -> say how to mechanically compute new values from existing values
Functions -> built-in functions
Charts -> graphical display of data
MICROSOFT EXCEL
Start screen
- Open a new file
- Select other templates
- Open recently opened files
Program window
- File button -> opens new options and important information about the file
- Ribbon -> contains tabs with the things you can do, a dialogue box launcher for other options
- Formula bar -> name box displays the address of the current cell, formula bar buttons, cell contents that shows
the contents of the cell
Excel limits
- Not infinite cells
- Not infinite rows and columns
- Date limits
Status bar
- Mode indicator (ready)
- Auto calculate indicator (if you select a certain number of cells)
Data entry
You can write
- Piece of text
- Value (quantities, date, time)
- Formula (start with =)
CELL REFERENCES
A cell reference identifies a cell’s location in the worksheet based on its column letter and row number
There are different types of cell references:
- Relative -> it changes ‘relative’ to the location of the cell where it is copied or moved (=A3)
- Absolute -> it refers to a specific cell or range of cells regardless of where the formula is located in a worksheet
(=$A$3)
- Mixed -> only a column or a row are fixed, the other is relative (=$A3) or (=A$3)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Anteprima parziale del testo

Scarica Appunti completi data analysis e più Appunti in PDF di Analisi Dei Dati solo su Docsity!

INTRODUCTION TO THE COURSE

COURSE OVERVIEW

Data are empirical material organised in a form that can be analysed Excel is very old but efficient and it can be considered an important basis for other platforms Spreadsheet is an interactive computer app for organisation analysis and storage of data in tabular form, it consists of a table of cells arranged into rows and columns and referred as X and Y locations Cell - > box for holding data Worksheet - > grid of vells with raw data (values) or formulas in the cells Values - > raw data or a value that can be based on a formula (numbers, text, data) Formulas - > say how to mechanically compute new values from existing values Functions - > built-in functions Charts - > graphical display of data

MICROSOFT EXCEL

Start screen

- Open a new file

- Select other templates

- Open recently opened files

Program window

- File button - > opens new options and important information about the file

- Ribbon - > contains tabs with the things you can do, a dialogue box launcher for other options

- Formula bar - > name box displays the address of the current cell, formula bar buttons, cell contents that shows

the contents of the cell

Excel limits

- Not infinite cells

- Not infinite rows and columns

- Date limits

Status bar

- Mode indicator (ready)

- Auto calculate indicator (if you select a certain number of cells)

Data entry

You can write

- Piece of text

- Value (quantities, date, time)

- Formula (start with =)

CELL REFERENCES

A cell reference identifies a cell’s location in the worksheet based on its column letter and row number There are different types of cell references:

- Relative - > it changes ‘relative’ to the location of the cell where it is copied or moved (=A3)

- Absolute - > it refers to a specific cell or range of cells regardless of where the formula is located in a worksheet

(=$A$3)

- Mixed - > only a column or a row are fixed, the other is relative (=$A3) or (=A$3)

A LITTLE BIT OF STATISTICS I

DATA ANALYSIS

Data analysis is a process of gathering, inspecting, transforming and modelling data with the goal of discovering useful information

- Primary data analysis - > you collect your own data

- Secondary data analysis - > you use data sets gathered from other people

Units of analysis are objects or subjects to which the properties investigated pertain

VARIABLES

A variable is an empirical measurement of a characteristic It has a name and at least two values A value is each of the different category of a property (variable) A variable can change:

- Over time

- Among cases

A constant is a variable that doesn’t change for all units of analysis

LEVELS OF MEASUREMENT

Variables can be classified according to the operations that can be carried out on them

- Continuous - > the intervals between the values of the variable can be determined

Highest level of information since it can be used for operations They have full numerical meaning ▪ Cardinal - > can be used for mathematical operations ▪ Ordinal

- Ordinal - > there is a clear ordering of the categories

It communicates relative differences between units of analysis ▪ Discrete ▪ Orderable - > it exists an order The distance between one category and the other is known

- Nominal - > it has at least two values, it doesn’t have an intrinsic ordering to the categories

It communicates differences between units of analysis on the characteristic being measured ▪ Discrete - > finite number of categories ▪ Non-orderable - > no order or hierarchy can be established Classification is the process of assigning categories to each unit of analysis (exhaustive and mutually exclusive) Categorical

A LITTLE BIT OF STATISTICS II

DESCRIPTIVE STATISTICS

Descriptive statistics summarise the information in a collection of data by graphs, tables, numbers…. Different types of descriptive statistics are:

- Frequency distribution

- Measures of central tendency

- Measures of variability

FREQUENCY DISTRIBUTION

FOR CATEGORICAL VARIABLES:

It is a list of possible values for a variable, together with the number of observations at each value 1 - List the categories 2 - How many of each category there are The total of all the categories should be equal to the number of observations =COUNTIF (RANGE;VALUE) Relative frequency distribution is shown through proportions or percentages FOR CONTINUOUS VARIABLES: It can’t always be used since usually there are a lot of different values that the variable can be Its useful to define bins which are consecutive, non-overlapping intervals of a variable, they should be exhaustive and mutually exclusive =FREQUENCY (RANGE;BINS) – then press CTRL + SHIFT + ENTER

MEASURES OF CENTRAL TENDENCY

Statistics that show what a typical observation is like

- Mode - > most frequently occurring value

We can have more than one mode =MODE (NUMBER1,NUMBER2…) There can also not be a mode (#NA) If we use it with nominal or ordinal values, we have to recall them with numbers =MODE.SNGL (NUMBER1,NUMBER2…)

- Median - > middle value, it has 50% of values above and 50% of values below

With odd number of observations it is the central value With even number of observations it is the average of the two middle observations It isn’t affected by outliers (data points that differs significantly from the other observations) =MEDIAN (NUMBER1,NUMBER2…)

- Mean - > sum of observations divided by the number of observations

It is highly sensitive to outliers It is pulled in the direction of the longer tail of the data =AVERAGE (NUMBER1;NUMBER2…) =SUM(…)/COUNT(…) If the median and the mean are very different it is better to use the median Each of the different type of variable can hold for different measures of central tendency:

  • CONTINUOUS - > mean, mode, median
  • ORDINAL - > mean (loosely interpretable), median and mode (more precision)
  • NOMINAL - > mean and median (no meaning), mode

MEASURES OF VARIABILITY

Measures of central tendency don’t really inform about distribution of the values Measures of variability specify the variability within a dataset Measures of variability are:

  • Range - > number of categories that the variable can take Used for categorical variables only For continuous variables it is the difference between the maximum and the minimum Manually computed for ordinal and nominal variables =MAX-MIN for continuous variables
  • Standard deviation - > it is meaningful for continuous variables It is the average distance from the mean, the larger it is, the larger is the variability of data =STDEV.S (RANGE) <- only for a sample =STDEV.P (RANGE) <- whole population
  • Interquartile range - > measures of position Tells us the point at which a given percentage of the data fall below or above that point Percentile is the point such that p% of the observations fall below that point and (100-p)% fall above it - Lower quartile - > 25% - Median - > 50% - Upper quartile - > 75% Interquartile range is the difference between the upper and the lower quartile =PERCENTILE (RANGE,PTH) =QUARTILE (RANGE;QUARTILE) - 0 - > minimum - 1 - > lower quartile - 2 - > median - 3 - > upper quartile - 4 - > maximum

EXPORTING TEXT FILES

To save an excel file as a comma-delimited file:

  • Go on ‘file’
  • Click on ‘save as’
  • Then ‘choose the format’

CREATING SUMMARY TABLES

DATA VALIDATION

Data validation is useful to ensure data integrity, to make sure that it respects some rules

- Go on ‘Data’ tab

- Select the range of the cells in which you want to restrict the rule

- Click on ‘Data validation’

- Specify the options

We can decide the type or style of data and also the input and error message We can also decide to include a drop-down menu in which we insert a list of possible options to choose There we can specify the range, linking a list that may be already present in the data worksheet)

FORMATTING

Formatting is useful to change the way in which data appears to make it easier to read The main tools can be found in the ‘home’ tab Conditional formatting is useful to find a formatting rule based on data criteria There are different types of conditional formatting the cells:

- Highlight cells rules - > highlights cells that contain certain values

- Top/bottom - > highlight the top or bottom values

- Data bars - > indicate the value of the cells relative to each other

- Colour scales - > two/three-colour scales

- Icon sets - > indicate the cells’ values relative to each other

You can also specify new rules by clicking on ‘New rule’

TABLES

Feature that expedites formatting, filtering and calculations

- Click on a cell

- Click the ‘insert’ tab

- Click ‘table’

- Decide the limits of the table and then create it

There is a new tab (‘Design’) in which there are more options for the table design Adding the ‘Total row’ is useful in order to have a row at the bottom of the table, in which you can specify the operation To return from a table to normal range click on ‘convert to range’ In the tables we can use structured reference, in the formulas, instead of writing the name of the cell, we can use the heading of the row/column

PIVOT TABLE

A pivot table is a table of statistics that summarises the data of a more extensive table It is called ‘pivot’ because we can easily move variables between rows and columns

- Click on a cell in the data set

- Go in the ‘Insert’ tab

- Select ‘pivot table’

- Select the range

EXCEL CHARTS

A chart is a graphical representation of numeric data in a worksheet They help conveying a message in an easier way We can use charts to:

- Compare groups

- Show the composition

- Show a distribution

- Show a relationship between variables

Since there are a lot of possible different charts, it’s always useful to choose the right one:

- Nominal variables

  • Column chart
  • Bar chart
  • Pie chart

- Ordinal variables

  • Column chart
  • Bar chart
  • Pie chart

- Interval/ratio variables

  • Histograms
  • Lines
  • Areas
  • Scatter When a chart is created, the ‘design’ tab opens up, which is useful to change how the chart is formatted In ‘Add chart element’ we can customize elements in the chart Its always important to add axes title and a legend (if there’s more then one variable) Using ‘create a chart sheet’ it’s possible to create a sheet in which there’s only the chart

COLUMN CHART

Compare values across categories or a time period, data points are vertical rectangles Useful for:

- Comparing different categories

- Plot nominal and ordinal data

BAR CHART

Illustrate comparisons among individual terms when axis labels are long, data is represented as horizontal rectangles Useful for:

- High number of categories

- Lot of categories for each variable

PIE CHART

Compare the size of the items in one data series and how each slice compares with the whole Data points are displayed as a percentage of a circular pie

Useful for:

  • Only one data series
  • No negative or null values
  • Few categories

HISTOGRAM CHART

Relative frequency distribution for a quantitative variable If we use it with a continuous variable we have to divide the values in mutually exclusive intervals Useful for:

  • Interval data
  • Showing frequency distribution

BOX PLOT

Displays the central tendency and spread Useful for:

  • Looking at the distribution of multiple groups for a descriptive value
  • Compare different groups

LINE CHART

Show trends in data at intervals, displays continuous data over time set against a common scale Data points are represented as points along a line Useful for:

  • Show a trend

AREA CHART

Emphasise the magnitude of change over time, shows relationships of parts to the whole Data points are represented as shaded areas Useful for:

  • Non fluctuating values (the areas would cross each other)
  • Trend of different groups
  • Show the composition during different years

SCATTERPLOT

Show relationships of one numeric set of data against another numeric set of data to look for a correlation The independent variable is usually on the horizontal axis, while the dependent is on the vertical axis Useful for:

  • Continuous variable
  • Relationship between X and Y
  • Compare large number of data points

BUBBLE

Three-way comparison based on a scatterplot Useful for:

  • Comparing the variables

BIVARIATE ANALYSIS

Bivariate analysis is the analysis of the association between two different variables It also describes the nature of this association An association exists if particular values of one variable are more likely to occur with certain values of the other variable Its always important to distinguish between:

- Independent variable - > (explanatory variable) the variable that influences the dependent variable

- Dependent variable - > (respondent variable) the variable that gets influenced by the independent variable

When the independent variable is categorical, it defines the groups to be compared with respect to the response variable When the independent variable is quantitative, we examine how different values of the explanatory variable relate to changes in the response variable

BOTH ARE CATEGORICAL VARIABLES - > Tabular analysis

1 - Define your research question (what we want to investigate) 2 - Define the dependent and independent variables 3 - Define how to measure the variables (EX. Survey data) 4 - Contingency tables (simple table that displays counts for two categorical variables): o Rows - > categories of the independent variable o Columns - > categories of the dependent variable Each entry in the table is the number of observations (joint frequency) in the sample at a particular combination of categories The process of cross-tabulation of the data consists in taking a data file and finding the frequencies for the cells of a contingency table (insert a pivot table with one variable in the rows and one in the columns, insert one of the two in the value and select ‘count’) 5 - Conditional proportion - > convert frequencies of one variable within each category of the other to proportion/percentage and compare them: o Find the total of the row (show the number and the 100%) o Calculate the % of the row total o Select to show results of the value as ‘% of row total’ We can represent the conditional distribution with a column chart (if we don’t have many categories) Two categorical variables are independent if the population conditional distributions for one of them are identical to each category of the other The variables are dependent (associated) if the conditional distributions are not identical Two events A and B are independent if P(A) (Probability of A) is the same as the conditional probability of A, given B, denoted by P(A/B) To formally test the association between two categorical variables:

1 - Define the hypothesis for the test: H 0 - > the two variables are independent Ha - > the two variables are dependent 2 - Compute the expected cell count (joint frequencies if the two variables were independent) It satisfies the null hypothesis of independence 3 - Chi-squared test statistic - > it measures how close the observed cell counts fall to the expected cell counts When the H 0 is true, the X^2 value tends to be smaller When the H 0 is false, the X^2 value tends to be higher 4 - To evaluate if the chi-squared is statistically significant we can use the P-value The P-value doesn’t tell the strength of an association but it measures the probability that the X^2 statistic for a random sample would be larger than the observed value if the variables are truly independent o P-value ≤ 0.05 - > reject the null hypothesis of independence (the variables are dependent) o P-value > 0.05 - > accept the null hypothesis of independence (the variables are independent) =CHISQ.TEST (actual_range, expected_range)

b is 0 - > it is a straight horizontal line We can also use the function: = LINEST (KNOWN_Y’S, [KNOWNX’S], [CONST], [STATS]) In which:

  • Known_y’s - > range of values of the dependent variable
  • Known_x’s - > range of values of the independent variable
  • Const - > (optional) value that specifies if to force the constant b to equal 0 (TRUE to calculate it normally)
  • Stats - > (optional) value that specifies if to return additional regression statistics (FALSE to not return additional statistics) 6 - In a scatterplot, the vertical distance between the point and the regression line is the residual, which measures the size of predicted errors (y – ŷ) It can be positive when the actual y is larger than its predicted value It can be negative when the actual y is smaller than its predicted value The sum of all the residuals found while considering the regression line must be 0 because the line passes through the centre of the data (the average)

PRESENTING YOUR WORK

MIXED ASSOCIATION

A mixed association is an association between a quantitative dependent variable and a categorical independent variable When a mixed association occurs we investigate how the outcome on the response variable tends to change between the categories of the explanatory variable 1 - Create a box-plot of the quantitative variable for each value of the categorical variable (to compare the distribution) 2 - Compute measures of variability and central tendency for the quantitative variable for each category of the categorical variable Use a pivot table to show descriptive statistics (average, standard deviation, count) by putting the independent variable in rows and the dependent variable in values 3 - Then compare these statistics and see whether there is a variation across the categories of the independent variable If the categorical variable has only two categories we can use the T-test:

- A statistical hypothesis test in which the test statistic follows a student’s t-distribution if the null hypothesis is

supported

- Determines whether two samples are likely to have come from the same two underlying populations that have

the same mean

- It has a P-value:

  • P-value ≥ 0.05 - > accept the null hypothesis (the two means are equal)
  • P-value < 0.05 - > reject the null hypothesis (the two means aren’t equal so there is an association) To compute the t-test we can use the t-test function (we always have to modify the data set in order to have the two different groups in different columns): =T.TEST (ARRAY1, ARRAY2, TAILS, TYPE) In which:

- Array 1 - > first data set (range of values of the quantitative variable for the first group of the independent

variable)

- Array 2 - > second data set (range of values of the quantitative variable for the second group of the

independent variable)

- Tails - > number of distribution tails (1, 2), always use 2 as we are searching for difference

- Type - > kind of t-test to perform, always use 3 as we want to investigate different subjects with unequal

variance) We can also perform the t-test using the data analysis tool pack (‘two-sample assuming unequal variance’) If the categorical variable has more than two categories we can:

- Use the box-plot for the different categories

- Create a pivot-table for descriptive statistics

Formally we can test it with ANOVA (One-Way Analysis Of Variance) present in the data analysis tool pack

CAUTIONS IN ANALYSING ASSOCIATIONS

When analysing associations between variables we need to be cautious about certain potential problems:

- Extrapolation - > refers to using a regression line t predict y values for x values outside the observed range of

data That is linked to the fact that not always the association in the future will behave as in the past

- Outliers - > influential outliers can change coefficients

An outlier can have a substantial effect on the correlation and regression (influential)

SUMMARY OF THE COURSE

PRESENTING YOUR WORK

It’s also useful to present your work in a way that is easy to understand Figures and tables can be used for presenting data and explain concepts

- Figures - > when using a figure we should ask ourselves if it really adds something to the analysis

It’s also important to reference at it in the text When using a figure we should consider:

  • Graph format
  • Colours
  • Labelling and titling
  • Source of the figure or of the data Don’t use colours in the graphs (for colourblinds) In order to add figures we can use different paste options:
  • Use destination theme and embed workbook - > updates the chart formatting to match the destination formatting
  • Keep source formatting and embed workbook - > keeps the chart formatting exactly as it is
  • Use destination theme and link data - > updates the chart formatting to match the destination formatting and keeps the chart linked to the original worksheet (they automatically update when changed)
  • Keep source formatting and link data - > keeps chart formatting exactly as it is and keeps the chart linked to the original worksheet (the data in the word document will update when the sourxe excel worksheet is updates)
  • Picture - > pastes the chart as a picture (the chart cannot be edited or updated)

- Tables - > in a table it’s always important to report also the 100% and the row/column total

Report always a title and a caption 2

COURSE SUMMARY

Data analysis is a process of inspecting, cleansing, transforming and modelling data with the goal of discovering useful information, informing conclusions and supporting decision-making Data are empirical material organized into a form that can be analysed

- Primary data analysis - > you collect and categories your own data

- Secondary data analysis - > you use datasets that have been gathered by others

Units of analysis are the objects to which the properties investigated pertain A variable is an empirical measurement of a characteristic, it has a name and at least two values, it can variate over time or among cases There can be different levels of measurement of the variables:

- Nominal variable - > non-orderable, discrete, it involves names and can be classified

- Ordinal variable - > orderable, discrete, it involves names with only ordinal properties and can be ordered

- Interval variable - > orderable, countable, discrete and continuous, it involves numbers with cardinal properties

and can be counted and measured A spreadsheet is an interactive application for organization, analysis and storage of data in tabular form, it is a table of cells arranged in rows and columns A cell is a box for holding data, it is referenced by its column and row A worksheet is a grid of cells with raw data, celled values or formulas in the cells Values are row data, it can also be the result of a formula or of a calculation A formula is an equation that performs calculations (it must be entered with =) Built-in functions are arithmetic operations, trigonometric functions, statistical functions… A chart is a graphical display of data A cell reference identifies a cell’s location in the worksheet based on its column letter and row number, there are three types of cell reference:

- Relative - > row and column references are relative (D4)

- Absolute - > row and column references are fixed with the $ sign ($D$4)

- Mixed - > either the row or the column reference is absolute ($D4 / D$4)

How to structure a dataset: 1 - Put variables in columns, observations in rows and data in cells 2 - Include a unique identifying number for each observation 3 - Put variable names in the first row 4 - Use a separate column for each piece of information 5 - When entering dates include a 4 digit year 6 - Decide on ‘missingness’ conventions 7 - Be consistent in the data entry 8 - Document the database with a codebook (variable names, data type, label or longer name and units of the variable, codes for any categorical variable, missingness conventions and notes) Different tools of data management are:

- Importing data from text files

- Autofill

- Data validation

- Removing duplicates

- Filter

- Sorting data

- Lookup function

Descriptive statistics summarise the information in a collection of data