task-3-R111111
.docx
keyboard_arrow_up
School
Centro Escolar University *
*We aren’t endorsed by this school
Course
AUDITING
Subject
Statistics
Date
Nov 24, 2024
Type
docx
Pages
12
Uploaded by aly_george
R studio questions from 16 to 23
2023-11-27
R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com
.
When you click the Knit
button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
hw4_data <-
read.csv
(
"C:/Users/user/Desktop/attique/asad work/1547941853 需要用
R/hw4_data.csv"
)
data <-
hw4_data
# Count the number of people in each treatment group
n_total <-
nrow
(data)
n_employment <-
sum
(data
$
employment_group ==
1
)
n_cash <-
sum
(data
$
cash_group ==
1
)
n_control <-
sum
(data
$
control_group ==
1
)
# Calculate the share in each treatment group
share_employment <-
n_employment /
n_total
share_cash <-
n_cash /
n_total
share_control <-
n_control /
n_total
# Print the results
cat
(
"Total number of people:"
, n_total, "
\n
"
)
## Total number of people: 726
cat
(
"Share in the employment group:"
, share_employment, "
\n
"
)
## Share in the employment group: 0.5550964
cat
(
"Share in the cash group:"
, share_cash, "
\n
"
)
## Share in the cash group: 0.2217631
cat
(
"Share in the control group:"
, share_control, "
\n
"
)
## Share in the control group: 0.2231405
# question16
# Calculate mean and standard deviation for age
mean_age <-
tapply
(data
$
age, data
$
employment_group, mean)
sd_age <-
tapply
(data
$
age, data
$
employment_group, sd)
# Calculate mean and standard deviation for being married
marital_stats <-
aggregate
(marry_dum ~
employment_group, data, function
(x) c
(
mean =
mean
(x), sd =
sd
(x)))
# Extract mean and standard deviation values
mean_married <-
marital_stats
$
marry_dum[, "mean"
]
sd_married <-
marital_stats
$
marry_dum[, "sd"
]
# Print the results
cat
(
"Age: \n
"
)
## Age:
cat
(
" Employment group - Mean:"
, mean_age[
1
], "SD:"
, sd_age[
1
], "
\n
"
)
## Employment group - Mean: 28.66873 SD: 6.975902
cat
(
" Cash group - Mean:"
, mean_age[
2
], "SD:"
, sd_age[
2
], "
\n
"
)
## Cash group - Mean: 28.01985 SD: 6.895424
cat
(
" Control group - Mean:"
, mean_age[
3
], "SD:"
, sd_age[
3
], "
\n
"
)
## Control group - Mean: NA SD: NA
cat
(
"
\n
Married: \n
"
)
## ## Married:
cat
(
" Employment group - Mean:"
, mean_married[
1
], "SD:"
, sd_married[
1
], "
\n
"
)
## Employment group - Mean: 0.8142415 SD: 0.3895151
cat
(
" Cash group - Mean:"
, mean_married[
2
], "SD:"
, sd_married[
2
], "
\n
"
)
## Cash group - Mean: 0.7617866 SD: 0.4265199
cat
(
" Control group - Mean:"
, mean_married[
3
], "SD:"
, sd_married[
3
], "
\n
"
)
## Control group - Mean: NA SD: NA
# question 17
# Age comparison between employment and control groups
t_age <-
t.test
(data
$
age[data
$
employment_group ==
1
], data
$
age[data
$
control_group ==
1
])
# Print the t-test result for age
print
(
"Age Comparison:"
)
## [1] "Age Comparison:"
print
(t_age)
## ## Welch Two Sample t-test
## ## data: data$age[data$employment_group == 1] and data$age[data$control_group == 1]
## t = -0.70767, df = 295.98, p-value = 0.4797
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.722064 0.811149
## sample estimates:
## mean of x mean of y ## 28.01985 28.47531
# Married comparison between employment and control groups
# Assuming you want to compare "marry_dum_own" for employment_group ==
1 and control_group == 1
t_marry <-
t.test
(data
$
marry_dum[data
$
employment_group ==
1
],
data
$
marry_dum[data
$
control_group ==
1
])
# Print the t-test result for marital status
print
(
"
\n
Marital Status Comparison:"
)
## [1] "\nMarital Status Comparison:"
print
(t_marry)
## ## Welch Two Sample t-test
## ## data: data$marry_dum[data$employment_group == 1] and data$marry_dum[data$control_group == 1]
## t = -1.7863, df = 331.94, p-value = 0.07497
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.137366784 0.006618997
## sample estimates:
## mean of x mean of y ## 0.7617866 0.8271605
# question 18
# Baseline mental health index comparisons
t_baseline_emp_ctrl <-
t.test
(data
$
b_mental_health_index[data
$
employment_group ==
1
],
data
$
b_mental_health_index[data
$
control_group ==
1
])
t_baseline_cash_ctrl <-
t.test
(data
$
b_mental_health_index[data
$
cash_group ==
1
], data
$
b_mental_health_index[data
$
control_group ==
1
])
t_baseline_emp_cash <-
t.test
(data
$
b_mental_health_index[data
$
employment_group ==
1
], data
$
b_mental_health_index[data
$
cash_group ==
1
])
# Print the results
cat
(
"Baseline Mental Health Index T-Test (Employment vs. Control):
\n
"
)
## Baseline Mental Health Index T-Test (Employment vs. Control):
print
(t_baseline_emp_ctrl)
## ## Welch Two Sample t-test
## ## data: data$b_mental_health_index[data$employment_group == 1] and data$b_mental_health_index[data$control_group == 1]
## t = 1.4146, df = 308.03, p-value = 0.1582
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.02516152 0.15386896
## sample estimates:
## mean of x mean of y ## 0.059110301 -0.005243423
cat
(
"
\n
Baseline Mental Health Index T-Test (Cash vs. Control): \n
"
)
## ## Baseline Mental Health Index T-Test (Cash vs. Control):
print
(t_baseline_cash_ctrl)
## ## Welch Two Sample t-test
## ## data: data$b_mental_health_index[data$cash_group == 1] and data$b_mental_health_index[data$control_group == 1]
## t = 0.27537, df = 319.98, p-value = 0.7832
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.09340705 0.12381071
## sample estimates:
## mean of x mean of y ## 0.009958406 -0.005243423
cat
(
"
\n
Baseline Mental Health Index T-Test (Employment vs. Cash): \n
"
)
## ## Baseline Mental Health Index T-Test (Employment vs. Cash):
print
(t_baseline_emp_cash)
## ## Welch Two Sample t-test
## ## data: data$b_mental_health_index[data$employment_group == 1] and data$b_mental_health_index[data$cash_group == 1]
## t = 1.0405, df = 291.7, p-value = 0.299
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.04382451 0.14212829
## sample estimates:
## mean of x mean of y ## 0.059110301 0.009958406
#question 19
# 19. Multiple Regression
model <-
lm
(e_mental_health_index ~
employment_group
+
cash_group
+
b_mental_health_index
, data =
hw4_data)
# Print coefficients
summary
(model)
## ## Call:
## lm(formula = e_mental_health_index ~ employment_group + cash_group + ## b_mental_health_index, data = hw4_data)
## ## Residuals:
## Min 1Q Median 3Q Max ## -1.6602 -0.3103 0.0121 0.3027 1.8688 ## ## Coefficients:
## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 0.002387 0.036165 0.066 0.947 ## employment_group 0.188364 0.042878 4.393 1.29e-05 ***
## cash_group 0.031125 0.051227 0.608 0.544 ## b_mental_health_index 0.455204 0.034259 13.287 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## ## Residual standard error: 0.4603 on 722 degrees of freedom
## Multiple R-squared: 0.2257, Adjusted R-squared: 0.2225 ## F-statistic: 70.17 on 3 and 722 DF, p-value: < 2.2e-16
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
In spreadsheet of variables view we
can define the
font
variables
data
O format
Which command is required to
change the existing value of
variables
transform
expression
none of these
compute
arrow_forward
Here are the numbers of times 8 people ate out last month.
4
,
3
,
6
,
5
,
6
,
3
,
7
,
5
Send data to calculator
Find the modes of this data set.
If there is more than one mode, write them separated by commas.If there is no mode, click on "No mode."
arrow_forward
Please show work
arrow_forward
3:22
Status
Recovery
Number Patterns
Find the next two numbers in this
number pattern.
36, 30, 24, [?],
Enter the number
that belongs in
the green box.
Copyright © 2003 - 2022 International Academy
of Science. All Rights Reserved.
Enter
7
Help Resources
Skip
arrow_forward
h MAT-154 Class Resources
X
P Do Homework - Topic 2 Homew X
My Questions | bartleby
8 https://mylab.pearson.com/Student/PlayerHom My Questions | bartleby d=6214477958questionld=5&flushed=false&cld=68906418&back=DoAssignments.aspx
Sign in
b bartleby.com
MAT-154-0500
Laura Phillips 03/22/22 9:46 AM
Question 5, 2.1.55
= Homework: Topic 2 Homework
HW Score: 13.33%, 6 of 45 points
O Points: 0 of 1
Save
Part 1 of 2
Write an equation for the line perpendicular to the line y = 14 and passing through (2, - 4). If possible, write a formula for a linear function whose graph is the given line.
...
The equation of the line perpendicular to the line y = 14 and passing through (2, - 4) is
(Simplify your answer. Type an equation.)
Help me solve this
View an example
Get more help -
Clear all
Check answer
11:46 AM
O Type here to search
59°F Partly cloudy
3/22/2022
arrow_forward
help
arrow_forward
Stuck need help!
The class I'm taking is computer science discrete structures.
Problem is attached. please view attachment before answering.
Really struggling with this concept. Thank you so much.
arrow_forward
Describe the reciprocal relationship between leaderships decision making (both implicit and xplicit) and the creation of culture. What limitations are placed upon leaderships decision making abilities by the organizations culture? Are there decisions a leader is blocked culturally from considering? Write it in apa format
arrow_forward
Give the meanings of CD, CD, CD, and CD.
arrow_forward
Please answer the subparts d and e. thank you!
arrow_forward
What is source
arrow_forward
I did page 1
I decided to skip this page
edHelper
The first English dictionary, prepared
in 1604 by Robert Cawdrey, defined
3,000 English words. In 1720, Nathan
Bailey published the first English
dictionary that tried to include most
English words instead of just the hard
ones. His dictionary contained about
60,000 words. How many more
words did Bailey's dictionary contain
than Cawdrey's dictionary?
es below
ning. By
P, N, O, M, N, L, M.
arrow_forward
Computer Variable Names A common computer programming rule is that names of variables must be between one and eight characters long. The first character can be any of the 26 letters, while successive characters can be any of the 26 letters or any of the 10 digits. For example, allowable variable names include A, BBB, and M3477K. How many different variable names are possible? (Ignore the difference between uppercase and lowercase letters.)
arrow_forward
Here are the numbers of times 9 people ate out last month.
4
,
3
,
5
,
4
,
5
,
6
,
6
,
4
,
5
Send data to calculator
Find the modes of this data set.
If there is more than one mode, write them separated by commas.If there is no mode, click on "No mode."
No mode
Check
Save For Later
Submit Assignment
Terms of Use
arrow_forward
Here are the numbers of children in 12 elementary school classes.
20
,
20
,
17
,
17
,
19
,
18
,
20
,
19
,
19
,
18
,
18
,
16
Send data to calculator
Find the modes of this data set.
If there is more than one mode, write them separated by commas.If there is no mode, click on "No mode."
arrow_forward
Fall 2021 MA-109-HYBO2: Principles of Math (1)
Homework: Section 2.2 Homework
Decide if the given statement is true or false. If it is false, give the reason.
{}C {track, hockey, tennis}
Choose the correct answer below.
O A. The statement is false; { } is not a subset of the set.
B. The statement is true; {} is a subset of the set.
C. The statement is false; { } is not an element of the ser.
D. The statement is true; { } is an element of the set.
arrow_forward
Assume you help to oversee your company's computer network. As such, it is important for you to understand and
be able to apply number representation and number theory, as well as other IT concepts.
Part 1: Number Representation (application to binary encoding) and Combinatorics (application
to IP network addressing)
Note: For each of the following, you must show your work for credit.
Given your responsibilities, you decide to refresh your memory with respect to number representation conversions:
decimal to binary and hexadecimal (and vice versa). In the following questions, the base is denoted as a subscript.
For example, 1510 is 15 in decimal (base 10), 00112 is 3 in binary (base 2), and 1A16 is 26 in hexadecimal (base 16).
1. What is the decimal representation of 100011012?
2.
What is the decimal representation of FFC616?
3. What is the binary representation of 17C616?
4. What is the hexadecimal representation of 111110002?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Algebra: Structure And Method, Book 1
Algebra
ISBN:9780395977224
Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:McDougal Littell
Big Ideas Math A Bridge To Success Algebra 1: Stu...
Algebra
ISBN:9781680331141
Author:HOUGHTON MIFFLIN HARCOURT
Publisher:Houghton Mifflin Harcourt
Holt Mcdougal Larson Pre-algebra: Student Edition...
Algebra
ISBN:9780547587776
Author:HOLT MCDOUGAL
Publisher:HOLT MCDOUGAL
Related Questions
- In spreadsheet of variables view we can define the font variables data O format Which command is required to change the existing value of variables transform expression none of these computearrow_forwardHere are the numbers of times 8 people ate out last month. 4 , 3 , 6 , 5 , 6 , 3 , 7 , 5 Send data to calculator Find the modes of this data set. If there is more than one mode, write them separated by commas.If there is no mode, click on "No mode."arrow_forwardPlease show workarrow_forward
- 3:22 Status Recovery Number Patterns Find the next two numbers in this number pattern. 36, 30, 24, [?], Enter the number that belongs in the green box. Copyright © 2003 - 2022 International Academy of Science. All Rights Reserved. Enter 7 Help Resources Skiparrow_forwardh MAT-154 Class Resources X P Do Homework - Topic 2 Homew X My Questions | bartleby 8 https://mylab.pearson.com/Student/PlayerHom My Questions | bartleby d=6214477958questionld=5&flushed=false&cld=68906418&back=DoAssignments.aspx Sign in b bartleby.com MAT-154-0500 Laura Phillips 03/22/22 9:46 AM Question 5, 2.1.55 = Homework: Topic 2 Homework HW Score: 13.33%, 6 of 45 points O Points: 0 of 1 Save Part 1 of 2 Write an equation for the line perpendicular to the line y = 14 and passing through (2, - 4). If possible, write a formula for a linear function whose graph is the given line. ... The equation of the line perpendicular to the line y = 14 and passing through (2, - 4) is (Simplify your answer. Type an equation.) Help me solve this View an example Get more help - Clear all Check answer 11:46 AM O Type here to search 59°F Partly cloudy 3/22/2022arrow_forwardhelparrow_forward
- Stuck need help! The class I'm taking is computer science discrete structures. Problem is attached. please view attachment before answering. Really struggling with this concept. Thank you so much.arrow_forwardDescribe the reciprocal relationship between leaderships decision making (both implicit and xplicit) and the creation of culture. What limitations are placed upon leaderships decision making abilities by the organizations culture? Are there decisions a leader is blocked culturally from considering? Write it in apa formatarrow_forwardGive the meanings of CD, CD, CD, and CD.arrow_forward
- Please answer the subparts d and e. thank you!arrow_forwardWhat is sourcearrow_forwardI did page 1 I decided to skip this page edHelper The first English dictionary, prepared in 1604 by Robert Cawdrey, defined 3,000 English words. In 1720, Nathan Bailey published the first English dictionary that tried to include most English words instead of just the hard ones. His dictionary contained about 60,000 words. How many more words did Bailey's dictionary contain than Cawdrey's dictionary? es below ning. By P, N, O, M, N, L, M.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Algebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal LittellBig Ideas Math A Bridge To Success Algebra 1: Stu...AlgebraISBN:9781680331141Author:HOUGHTON MIFFLIN HARCOURTPublisher:Houghton Mifflin Harcourt
- Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGAL
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Algebra: Structure And Method, Book 1
Algebra
ISBN:9780395977224
Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:McDougal Littell
Big Ideas Math A Bridge To Success Algebra 1: Stu...
Algebra
ISBN:9781680331141
Author:HOUGHTON MIFFLIN HARCOURT
Publisher:Houghton Mifflin Harcourt
Holt Mcdougal Larson Pre-algebra: Student Edition...
Algebra
ISBN:9780547587776
Author:HOLT MCDOUGAL
Publisher:HOLT MCDOUGAL