── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.1 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.2 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
Code
library(dplyr)library(ggplot2)library(alr4)
Loading required package: car
Loading required package: carData
Attaching package: 'car'
The following object is masked from 'package:dplyr':
recode
The following object is masked from 'package:purrr':
some
Loading required package: effects
lattice theme set by effectsTheme()
See ?effectsTheme for details.
Code
library(smss)library(stargazer)
Please cite as:
Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
Q.1)
A
Predictor variable :- ppgdp
Response variable :- fertility, birth rate
B
Code
ggplot(UN11, aes(ppgdp, fertility, color ="red")) +geom_point()
C
Code
ggplot(data = UN11, aes(x =log(ppgdp), y =log(fertility))) +geom_point()
we can imagine negatively sloped straight line and a plausible linear regression.
Q.2)
A)
the conversion from USD to British pound the numerical value will be divided by 1.23 to mitigate the effect slope will be divided by 1.23 as well.
B)
correlation will not change as it does not affect by measuring unit.
There is a strong correlation among quality, clarity, and helpfulness . easiness is correlated with the other three. raterInterest is also fairly correlated, but raters almost always say they are at least somewhat interested in the subject. Overall, the results might show that people do not differentiate all these dimensions very well in their minds—or that professors that do one in one dimension tend to do well on the others too.
Q.5)
A)
Code
data("student.survey")ggplot(student.survey, aes(x = re, fill = pi)) +geom_bar()
data("student.survey")model_1 <-lm(as.numeric(pi) ~as.numeric(re), data = student.survey)model_2 <-lm(hi ~ tv, data = student.survey)summary(model_1)
Call:
lm(formula = as.numeric(pi) ~ as.numeric(re), data = student.survey)
Residuals:
Min 1Q Median 3Q Max
-2.81243 -0.87160 0.09882 1.12840 3.09882
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.9308 0.4252 2.189 0.0327 *
as.numeric(re) 0.9704 0.1792 5.416 1.22e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.345 on 58 degrees of freedom
Multiple R-squared: 0.3359, Adjusted R-squared: 0.3244
F-statistic: 29.34 on 1 and 58 DF, p-value: 1.221e-06
Code
summary(model_2)
Call:
lm(formula = hi ~ tv, data = student.survey)
Residuals:
Min 1Q Median 3Q Max
-1.2583 -0.2456 0.0417 0.3368 0.7051
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.441353 0.085345 40.323 <2e-16 ***
tv -0.018305 0.008658 -2.114 0.0388 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4467 on 58 degrees of freedom
Multiple R-squared: 0.07156, Adjusted R-squared: 0.05555
F-statistic: 4.471 on 1 and 58 DF, p-value: 0.03879
There is a Positive and statistically significant relation between Religiosity and conservatism.
Watching TV for one more hour will decline the GPA by 0.018
Source Code
---title: "Homework_3"author: "Paritosh G"desription: "HW_3"date: "05/26/2023"format: html: toc: true code-fold: true code-copy: true code-tools: truecategories: - hw1 - challenge1 - my name - dataset - ggplot2---## Library```{r}library(tidyverse)library(dplyr)library(ggplot2)library(alr4)library(smss)library(stargazer)```## Q.1)## A- Predictor variable :- ppgdp- Response variable :- fertility, birth rate## B```{r}ggplot(UN11, aes(ppgdp, fertility, color ="red")) +geom_point()```## C```{r}ggplot(data = UN11, aes(x =log(ppgdp), y =log(fertility))) +geom_point()```we can imagine negatively sloped straight line and a plausible linear regression.## Q.2)## A)the conversion from USD to British pound the numerical value will be divided by 1.23 to mitigate the effect slope will be divided by 1.23 as well.## B)correlation will not change as it does not affect by measuring unit.## Q.3)```{r}data(water)pairs(water)```## Q.4)```{r}#data(Rateprof)pairs(Rateprof[,c('quality', 'clarity', 'helpfulness','easiness', 'raterInterest')])```There is a strong correlation among quality, clarity, and helpfulness . easiness is correlated with the other three. raterInterest is also fairly correlated, but raters almost always say they are at least somewhat interested in the subject. Overall, the results might show that people do not differentiate all these dimensions very well in their minds---or that professors that do one in one dimension tend to do well on the others too.## Q.5)## A)```{r}data("student.survey")ggplot(student.survey, aes(x = re, fill = pi)) +geom_bar()``````{r}ggplot(data = student.survey, aes(x = tv, y = hi)) +geom_point() +theme_bw()```## B)```{r}data("student.survey")model_1 <-lm(as.numeric(pi) ~as.numeric(re), data = student.survey)model_2 <-lm(hi ~ tv, data = student.survey)summary(model_1)summary(model_2)```There is a Positive and statistically significant relation between Religiosity and conservatism.Watching TV for one more hour will decline the GPA by 0.018