Data and variables Information
1978 Automobile Data provided in an excel file.
Variable
Obs
Label
make
price
mpg
rep78
headroom
trunk
weight
length
turn
displacement
gear_ratio
foreign
74
74
74
69
74
74
74
74
74
74
74
74
Make and Model
Price
Mileage (mpg)
Repair Record 1978
Headroom (in.)
Trunk space (cu. ft.)
Weight (lbs.)
Length (in.)
Turn Circle (ft.)
Displacement (cu. in.)
Gear Ratio
Car type
* Encoding: UTF-8.
*To get data into your SPSS.
*Step-1: Open the Auto excel data into SPSS.
*Step-2: Then open a new syntax file and run the following SPSS
codes to get your data.
DATASET COPY Auto_new.
DATASET ACTIVATE Auto_new.
FILTER OFF.
USE ALL.
*After SET SEED command, replace the number 0000000000 by your roll
number (e.g. 2022134004).
SET SEED 2022134004.
**Now draw your own data using following codes.
*Step-3: After SAMPLE command below, you must replace 000 by a
number like 100+last 3 digits of your roll number.
*For example, your roll no is 2018134010, so your sample size would
be 100+4=104 or your roll no is 2018134111, so your sample size
would be 100+111=110.
SAMPLE 104 from 370.
EXECUTE.
*Now save your new data file (yourname_new) for analysis.
SAVE OUTFILE='F:\Jamal\Statistical Computing I\yourdata_new.sav'
/COMPRESSED.
Questions:
Data Cleaning
1. Outlier Detection:
a. How can you detect outliers/extreme values in the price variable
and what criteria would you use to define them? (hint: think a
plot)
b. What methods can you use to handle outliers detected in the mpg
variable?
2. Data Modifications with Conditions
Conditional Modifications:
a. How would you create a new variable expensive that labels cars
with a price greater than $10,000 as "yes" and others as "no"?
b. How would you categorize the mpg variable into "low", "medium",
and "high" categories based on specific mpg thresholds? (consider
Q1,Q2 and Q3 as a thresholds)
Creating New Variables:
a. How can you create a new variable weight_kg that converts the
weight variable from pounds to kilograms?
b. How would you generate a new variable price_per_mpg that
calculates the price per mile per gallon for each car?
Recoding Variables:
c. How would you recode the rep78 variable to group values 1 and 2
as "poor", 3 as "average", and 4 and 5 as "good"?
d. How would you create a binary variable large_trunk that indicates
whether a car has trunk space greater than 15 cu. ft.?
3. Data Management
Sorting and Filtering:
a. How can you sort the dataset by the price variable in descending
order?
b. How would you filter the dataset to include only cars that are
foreign (foreign = 1)?
4. Data Transformation:
a. How would you log-transform the price variable to normalize its
distribution?
b. How would you standardize the turn variable to have a mean of 0
and a standard deviation of 1?
5. Merging and Joining:
a. How would you merge this dataset with another dataset containing
additional information on car models based on the make variable?
(create two data sets data1 includes first 6 variables & data2
includes the last 6 variables and then merge data1 and data2)
b. How can you append new data to this dataset if you have
additional records of cars with the same variables? (create two
data sets data3 includes first 30 observation & data4 includes
rest 44 observation and then append data3 and data4)
6.Summarizing Data:
a. How can you generate a summary table showing the mean price and
mpg for foreign and domestic cars separately?
b. How would you calculate the total number of cars with rep78
ratings of 4 and 5?
c. How would you calculate the total price for each group of car
type?
7. Basic Analysis
Descriptive Statistics:
a. What are the steps to calculate the mean, median, and standard
deviation of the displacement variable?
b. How would you find the range and interquartile range (IQR) of the
headroom variable?
Frequency Distribution:
a. How can you create a frequency distribution table for the rep78
variable?
b. How would you plot a histogram of the trunk variable to visualize
its distribution?
Correlation Analysis:
a. How would you compute the correlation between the weight and mpg
variables?
b. How can you visualize the relationship between price and
displacement using a scatter plot?
Regression Analysis:
a. How would you perform a simple linear regression to predict price
based on mpg?
b. How would you include multiple predictors such as weight, length,
and gear_ratio in a multiple regression model to predict price?
8.Creating Graphs
Bar Graphs:
a. How would you create a bar graph to display the frequency of cars
with different rep78 ratings?
b. How can you create a bar graph to compare the average price of
foreign and domestic cars?
Histograms:
a. How would you create a histogram to visualize the distribution of
the price variable?
b. How can you plot a histogram of the mpg variable with bins of
width 5?
Scatter Plots:
a. How would you create a scatter plot to show the relationship
between weight and mpg?
b. How can you create a scatter plot with price on the y-axis and
displacement on the x-axis, and add a trend line?
Box Plots:
a. How would you create a box plot to compare the mpg of foreign and
domestic cars?
b. How can you create a box plot to display the distribution of
price for different rep78 ratings?
Line Graphs:
a. How would you create a line graph to show the trend of price
against weight for each make?
b. How can you plot a line graph to visualize the relationship
between gear_ratio and displacement?
Pie Charts:
a. How would you create a pie chart to show the proportion of
foreign and domestic cars?
b. How can you create a pie chart to represent the distribution of
cars across different rep78 ratings?