You are on page 1of 9

Computer Applications in Public health

Section 714.1
Instructor: Dr. Nadira Sultana Kakoly

Name: Md.fakhrul abedin bhuiyan ID: 1915246080

Total: /20
1. What is the mean price of the sample of cars? (1 mark)

sum price

Variable | Obs Mean Std. Dev. Min Max

-------------+---------------------------------------------------------

price | 74 6165.257 2949.496 3291 15906

Ans: The mean price of the sample of car is 6165.257.

2. What is the price range of the sample (minimum and maximum values)? (1 mark)

sum price

Variable | Obs Mean Std. Dev. Min Max


-------------+---------------------------------------------------------
price | 74 6165.257 2949.496 3291 15906

Ans: The price range of the sample (minimum and maximum values) are 3291 and 15906

1
3. What proportions of the cars have poor, fair, average, good and excellent repair history in
the sample? Did any of the sample fail to indicate their repair history, if so how many? (2
marks)

tab rep78

Repair |
Record 1978 | Freq. Percent Cum.
------------+-----------------------------------
Poor | 2 2.90 2.90
Fair | 8 11.59 14.49
Average | 30 43.48 57.97
Good | 18 26.09 84.06
Excellent | 11 15.94 100.00
------------+-----------------------------------
Total | 69 100.00

Ans: The proportions of the cars have poor, fair, average, good and excellent repair history in the
sample are 2.90%, 11.59%, 43.48%, 26.09%, 15.94%

2
4. What percentage of the sample cars were foreign? (2 mark)

tab foreign

Car type | Freq. Percent Cum.


------------+-----------------------------------
Domestic | 52 70.27 70.27
Foreign | 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00

Ans: 29.73% percentage of the sample cars were foreign

5. Create/compute new variables called high_price_cars for the variable price


a. To calculate the high_price_cars variable, first find the average price of all cars
b. Then create the new variable with a “1” equal to price more than average price of
cars and “0” equal to less than or equal to average price of cars. Call this new
variable high_price_cars
c. Label the new variable high_price_cars. 1 “High priced cars”, 0 “Low priced
cars”

. gen high_price_cars=.
(74 missing values generated)

. replace high_price_cars=1 if price>6165.257


(22 real changes made)

. replace high_price_cars=0 if price<=6165.257


(52 real changes made)

. tab high_price_cars

high_price_ |
cars | Freq. Percent Cum.
------------+-----------------------------------
0| 52 70.27 70.27
1| 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00

. label define High_price_cars 1"High priced cars" 0"Low priced cars"

. label value high_price_cars High_price_cars

. tab high_price_cars

high_price_cars | Freq. Percent Cum.


-----------------+-----------------------------------
Low priced cars | 52 70.27 70.27
High priced cars | 22 29.73 100.00
-----------------+-----------------------------------
Total | 74 100.00

.
6. Write down the descriptive statistics (number and percentage) for your new variable
high_price_cars. (6 marks)

Characteristic Number Percentage


s
High priced cars 22 29.73%

Low priced cars 52 70.27%

7. Create a pie chart showing the proportions of the high and low priced cars using the
newly created variable.

Ans: graph pie, over(high_price_cars)

29.73%

70.27%

Low priced cars High priced cars


8. Create a new variable (repair_good) from the variable in the data file (rep78). The new
variable will only have two values, indicating whether a car has a good or bad repair
history

In the first group include cars who have very good repair history (good and excellent).
These will be coded 1.

In the second group include cars who have bad repair history (poor, fair and average).
These will be coded 2. (4 marks)

Ans:
gen repair_good= rep78
(5 missing values generated)

. recode repair_good 1/3=2


(repair_good: 32 changes made)

. recode repair_good 4/5=1


(repair_good: 29 changes made)

. label define Repair_good 1"good and excellent" 2"poor, fair and average"

. label value repair_good Repair_good

. tab repair_good

repair_good | Freq. Percent Cum.


-----------------------+-----------------------------------
good and excellent | 29 42.03 42.03
poor, fair and average | 40 57.97 100.00
-----------------------+-----------------------------------
Total | 69 100.00

Number of respondents in the variable rep78 = 69


Number of respondents in the variable repair_good =69
9. Conduct a test of significance to find out if there is a statistically significant difference in
the average weight of cars (weight) for foreign and domestic cars (foreign). Paste the
output of your analysis as evidence of your conclusion. In a line or 2 please interpret your
findings. (3 marks)

. ttest weight, by(foreign)

Two-sample t test with equal variances


------------------------------------------------------------------------------
Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---------+--------------------------------------------------------------------
Domestic | 52 3317.115 96.4296 695.3637 3123.525 3510.706
Foreign | 22 2315.909 92.31665 433.0035 2123.926 2507.892
---------+--------------------------------------------------------------------
combined | 74 3019.459 90.34692 777.1936 2839.398 3199.521
---------+--------------------------------------------------------------------
diff | 1001.206 160.2876 681.6788 1320.734
------------------------------------------------------------------------------
diff = mean(Domestic) - mean(Foreign) t = 6.2463
Ho: diff = 0 degrees of freedom = 72

Ha: diff < 0 Ha: diff != 0 Ha: diff > 0


Pr(T < t) = 1.0000 Pr(|T| > |t|) = 0.0000 Pr(T > t) = 0.0000

Here, the table shows that, the p value is less than .05 which reject the null hypothesis. The
result indicates that, there is statistically significant difference in the average weight of cars
(weight) for foreign and domestic cars (foreign).
10. Conduct a test of significance to find out if there is a statistically significant difference in
the percentage of cars with very good repair history (repair_good) between foreign and
domestic cars (foreign). Paste the output of your analysis as evidence of your conclusion.
In a line or 2 please interpret your findings. (3 marks)
tab repair_good foreign, row chi

+----------------+
| Key |
|----------------|
| frequency |
| row percentage |
+----------------+

| Car type
repair_good | Domestic Foreign | Total
----------------------+----------------------+----------
good and excellent | 11 18 | 29
| 37.93 62.07 | 100.00
----------------------+----------------------+----------
poor, fair and averag | 37 3| 40
| 92.50 7.50 | 100.00
----------------------+----------------------+----------
Total | 48 21 | 69
| 69.57 30.43 | 100.00
Pearson chi2(1) = 23.6449 Pr = 0.000

Here the table shows that, the p value is less than .05 which indicates that there is a
statistically significant difference in the percentage of cars with very good repair history
(repair_good) between foreign and domestic cars (foreign).

You might also like