Question
Load the UN11 data set from the alr4 package. The data set includes 237 observations related to national health, welfare, and education statistics for 210
Load the UN11 data set from the alr4 package. The data set includes 237 observations related to national health, welfare, and education statistics for 210 places, mostly UN members, but also other areas like Hong Kong that are not independent countries. More details can be found by running ?alr4::UN11 in the R Console. The variables in the data set include:
region: region of the world group: a factor with levels oecd for countries that are members of the OECD, the Organization for Economic Co-operation and Development, as of May 2012, africa for countries on the African continent, and other for all other countries. No OECD countries are located in Africa. fertility: number of children per woman ppgdp: per capita gross domestic product in US dollars lifeExpF: female life expectancy, in years pctUrban: percent urban
Load the data UN11 available in package 'alr4'.
data(UN11)
library(effects) ## Loading required package: carData ## lattice theme set by effectsTheme() ## See ?effectsTheme for details. data(UN11, package = "alr4").
We will consider the relationship between the response log(fertility) and several of the other variables in the data set.
or
install.packages("alr4")
library(alr4)
# Problem 1
Fit a linear model regressing `log(fertility)` on `pctUrban`. Print the estimated coefficients of the model.
Answer -
lmod <- lm(log(fertility) ~ pctUrban, data = UN11) sumary(lmod)
# Problem 2
Use the fitted model to construct an effect plot for `pctUrban` on `fertility` (on the original scale for `fertility`). Note you will need to modify the `axes` argument of the `plot` function. The **effects** package has a vignette that may be helpful, it may be accessed by running `vignette("predictor-effects-gallery", package = "effects")` in the R console.
# Problem 3
Interpret the effects plot from the previous problem.
# Problem 4
Fit the linear model regressing `log(fertility)` on both `log(ppgdp)` and `lifeExpF`. Print the results to the R Console.
Answer :
lmod2 <- lm(log(fertility) ~ log(ppgdp) + lifeExpF , data = UN11) sumary(lmod2)
# Problem 5
Construct an effect plot of `ppgdp` on `fertility` (both on their original scale) using the fitted model from Problem # 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started