Question: a ) . Explain how the function myplot ( ) works ( this is not buit - in R function. You can also Learn how

a). Explain how the function myplot() works (this is not buit-in R function. You
can also Learn how to write your own function)
b). Compare this two models and write a summary of the findings.
Problem 2
Read the following R codes and the corresponding output then answer the questions.
Model 1 without interaction
11 brary(HSAUR3)
data("womensrole")
womensrole cbind (agree, disagree)- gender + education
womensrole_glm_1- glm(fm, data = vomensrole, family = binomial())
#role. fitted - predict(womensig_glm
Plot function
myplot - function(role.fitted){
f - womensrolesgender == "Female"
plot(womensrole$education, role.fitted, type ="n",
ylab = "Probability of agreeing",
Iines(womensroleseducation[|f], role.fitted[|f], lty =1)
lines(womensrole$education[f], role.fitted[f],1ty =2)
legend("topright", lgtxt, lty =(Females)")
y - vomensrolesagree ; (vomensrole$agree +"\)
size - womensroleagree+womensroledisagree
size - size - min(size)
text (womensre) max(size))*3+
family = "HersheySerif", y[f],"\VE",
text(womensrole$education[If], y[lf]"ex = size, col="red")
family = "HersheySerif", y[lf],"\MA"
}
Model 2 with interaction
fm2- cbind(agree, di sagree)- gendor * education
vomensrole_glm 2-g1(fm 2, data = romensrole, family = binomial ())
role.fitted2- fitted(womensrole_glm_2)
Call myplot fuction
par(mfrowec(2,1))
myplot(role.fitted1)
myplot(role.fitted2)
a ) . Explain how the function myplot ( ) works (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!