diff --git a/.DS_Store b/.DS_Store index feeea16..2d2c514 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 229bded..ac36cd2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ tutorials/.DS_Store problemSets/example/.Rhistory problemSets/.DS_Store .DS_Store +.Rproj.user diff --git a/problemSets/.DS_Store b/problemSets/.DS_Store new file mode 100644 index 0000000..d70e607 Binary files /dev/null and b/problemSets/.DS_Store differ diff --git a/problemSets/PS01/my_answers/.Rapp.history b/problemSets/PS01/my_answers/.Rapp.history new file mode 100644 index 0000000..e69de29 diff --git a/problemSets/PS01/my_answers/PS01_DP.R b/problemSets/PS01/my_answers/PS01_DP.R new file mode 100644 index 0000000..d93d95e --- /dev/null +++ b/problemSets/PS01/my_answers/PS01_DP.R @@ -0,0 +1,200 @@ +##################### +# load libraries +# set wd +# clear global .envir +##################### + +# remove objects +rm(list=ls()) +# detach all libraries +detachAllPackages <- function() { + basic.packages <- c("package:stats", "package:graphics", "package:grDevices", "package:utils", "package:datasets", "package:methods", "package:base") + package.list <- search()[ifelse(unlist(gregexpr("package:", search()))==1, TRUE, FALSE)] + package.list <- setdiff(package.list, basic.packages) + if (length(package.list)>0) for (package in package.list) detach(package, character.only=TRUE) +} +detachAllPackages() + +# load libraries +pkgTest <- function(pkg){ + new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] + if (length(new.pkg)) + install.packages(new.pkg, dependencies = TRUE) + sapply(pkg, require, character.only = TRUE) +} + +# here is where you load any necessary packages +# ex: stringr +# lapply(c("stringr"), pkgTest) + +lapply(c(), pkgTest, "ggplot2") + +##################### +# Problem 1 +##################### + +y <- c(105, 69, 86, 100, 82, 111, 104, 110, 87, 108, 87, 90, 94, 113, 112, 98, 80, 97, 95, 111, 114, 89, 95, 126, 98) + +# calculate the mean +mean_y = mean(y) +mean_y + +# calculate the standard deviation +demeanedSum <- y - mean_y +squaredError <- demeanedSum ^ 2 +variance <- sum(squaredError)/(length(y)-1) +stdev = sqrt(variance) +stdev + +# calculate the standard error +sterror = stdev/sqrt(length(y)) +sterror + +# find the t-score for the desired confidence level +t = qt(p = (1 - 0.9)/2 , df = 24, lower.tail = FALSE) +t + +# construct the confidence interval +lowerlimit = mean_y - t * sterror +upperlimit = mean_y + t * sterror +lowerlimit +upperlimit + +# hypothesis testing +# step 1 - assumptions: data is quantitative, sampling method is random, sample size is smaller than 30 -> t-score instead of z-score + +# step 2- null hypothesis: mean is lower or equal to 100 +# alternative hypothesis: mean is higher than 100 + +# step 3 - calculate a test statistic +ts = (mean_y - 100)/sterror +ts + +# step 4 - calculate the p-value +p = pt(ts, df = 24, lower.tail = FALSE) +p + +# step 5 - conclusion +# p-value is higher than alpha -> cannot reject the null hypothesis that the mean is lower or equal to 100 + + +##################### +# Problem 2 +##################### +lapply(c("ggplot2"), pkgTest) +install.packages("ggpubr") +library(ggpubr) + +expenditure <- read.table("https://raw.githubusercontent.com/ASDS-TCD/StatsI_2025/main/datasets/expenditure.txt", header=T) +head(expenditure) + +# plot the relationships between all the variables +# add the correlation coefficient and hide the p-value +# save the plots as a png to add to the latex file + +png(file = "scatter_x1_y.pdf") +ggplot(expenditure, aes(x = X1, y = Y)) + + geom_point() + + labs(title = "Relationship between personal income + and housing assistance expenditure", + x = "personal income (USD per capita)", + y = "expenditure on housing assistance (USD per capita)") + + stat_cor(aes(label = ..r.label..)) + + theme_minimal() +dev.off() + +png(file = "scatter_x2_y.png") +ggplot(expenditure, aes(x = X2, y = Y)) + + geom_point() + + labs(title = "Relationship between financial insecurity + and housing assistance expenditure", + x = "number of financially insecure residents (per 100,000)", + y = "expenditure on housing assistance (USD per capita)") + + stat_cor(aes(label = ..r.label..)) + + theme_minimal() +dev.off() + +png(file = "scatter_x3_y.png") +ggplot(expenditure, aes(x = X3, y = Y)) + + geom_point() + + labs(title = "Relationship between urban residency and + expenditure on housing assistance (in state)", + x = "number of urban residents (per 1000)", + y = "expenditure on housing assistance (USD per capita)") + + stat_cor(aes(label = ..r.label..)) + + theme_minimal() +dev.off() + +png(file = "scatter_x1_x2.png") +ggplot(expenditure, aes(x = X1, y = X2)) + + geom_point() + + labs(title = "Relationship between personal income + and financial insecurity", + x = "personal income (USD per capita)", + y = "number of financially insecure residents (per 100,000)")+ + stat_cor(aes(label = ..r.label..)) + + theme_minimal() +dev.off() + +png(file = "scatter_x1_x3.png") +ggplot(expenditure, aes(x = X1, y = X3)) + + geom_point() + + labs(title = "Relationship between personal income + and urban residency", + x = "personal income (USD per capita)", + y = "number of urban residents (per 1000)") + + stat_cor(aes(label = ..r.label..)) + + theme_minimal() +dev.off() + +png(file = "scatter_x2_x3.png") +ggplot(expenditure, aes(x = X2, y = X3)) + + geom_point() + + labs(title = "Relationship between financial insecurity + and urban residency", + x = "number of financially insecure residents (per 100,000)", + y = "number of urban residents (per 1000)") + + stat_cor(aes(label = ..r.label..)) + + theme_minimal() +dev.off() + + +# turn the Region into a factor to make the plot more readable +# now it shows the name of the region instead of 1,2,3,4 +expenditure$Region <- factor(expenditure$Region, + levels = c(1, 2, 3, 4), + labels = c("Northeast", "North Central", "South", "West")) + +# make a boxplot to compare the per capita housing expenditure in different regions +png(file = "boxplot_reg_y.png") +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + + geom_boxplot() + + theme( + legend.position="none", + plot.title = element_text(size=11)) + + labs(title = "Boxplot for housing assistance expenditure for each region", + x = "Region", + y = "expenditure on housing assistance (USD per capita)") + + theme_minimal() +dev.off() + +# plot the relationship between x1, y and region +# each region is represented by a different shape and colour +png(file = "scatter_x1_y_reg.png") +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + + geom_point(size = 3) + # increase size to distinguish between the shapes + scale_color_manual(values = c("black", "red", "green", "purple")) + + scale_shape_manual(values = c(21, 17, 18, 19)) + # each value corresponds to a shape + labs(title = "Relationship between personal income and + \n house assistance expenditure per region", + x = "personal income (USD per capita)", + y = "expenditure on housing assistance (USD per capita)", + shape = "Region", + color = "Region") + + theme_minimal() + + theme(plot.title = element_text(hjust = 0.5)) # center title +dev.off() + + + + diff --git a/problemSets/PS01/my_answers/PS01_DP.aux b/problemSets/PS01/my_answers/PS01_DP.aux new file mode 100644 index 0000000..e888aa0 --- /dev/null +++ b/problemSets/PS01/my_answers/PS01_DP.aux @@ -0,0 +1,38 @@ +\relax +\providecommand\hyper@newdestlabel[2]{} +\providecommand\HyField@AuxAddToFields[1]{} +\providecommand\HyField@AuxAddToCoFields[2]{} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{1}{lstlisting.-1}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{2}{lstlisting.-2}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{2}{lstlisting.-3}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{2}{lstlisting.-4}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{2}{lstlisting.-5}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{3}{lstlisting.-6}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{3}{lstlisting.-7}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{4}{lstlisting.-8}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{5}{lstlisting.-9}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{6}{lstlisting.-10}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces \footnotesize Scatterplot of X1 and Y}}{6}{figure.1}\protected@file@percent } +\newlabel{fig:plot_1}{{1}{6}{\footnotesize Scatterplot of X1 and Y}{figure.1}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{7}{lstlisting.-11}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces \footnotesize Scatterplot of X2 and Y}}{7}{figure.2}\protected@file@percent } +\newlabel{fig:plot_2}{{2}{7}{\footnotesize Scatterplot of X2 and Y}{figure.2}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{8}{lstlisting.-12}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces \footnotesize Scatterplot of X3 and Y}}{8}{figure.3}\protected@file@percent } +\newlabel{fig:plot_3}{{3}{8}{\footnotesize Scatterplot of X3 and Y}{figure.3}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{9}{lstlisting.-13}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces \footnotesize Scatterplot of X1 and X2}}{9}{figure.4}\protected@file@percent } +\newlabel{fig:plot_4}{{4}{9}{\footnotesize Scatterplot of X1 and X2}{figure.4}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{10}{lstlisting.-14}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces \footnotesize Scatterplot of X1 and X3}}{10}{figure.5}\protected@file@percent } +\newlabel{fig:plot_5}{{5}{10}{\footnotesize Scatterplot of X1 and X3}{figure.5}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{11}{lstlisting.-15}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {6}{\ignorespaces \footnotesize Scatterplot of X2 and X3}}{11}{figure.6}\protected@file@percent } +\newlabel{fig:plot_6}{{6}{11}{\footnotesize Scatterplot of X2 and X3}{figure.6}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{12}{lstlisting.-16}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {7}{\ignorespaces \footnotesize Boxplot of Y and Region}}{12}{figure.7}\protected@file@percent } +\newlabel{fig:plot_7}{{7}{12}{\footnotesize Boxplot of Y and Region}{figure.7}{}} +\@writefile{lol}{\contentsline {lstlisting}{PS01\textunderscore DP.R}{13}{lstlisting.-17}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {8}{\ignorespaces \footnotesize Scatterplot of X1, Y and Region}}{13}{figure.8}\protected@file@percent } +\newlabel{fig:plot_8}{{8}{13}{\footnotesize Scatterplot of X1, Y and Region}{figure.8}{}} +\gdef \@abspage@last{14} diff --git a/problemSets/PS01/my_answers/PS01_DP.log b/problemSets/PS01/my_answers/PS01_DP.log new file mode 100644 index 0000000..2e21c02 --- /dev/null +++ b/problemSets/PS01/my_answers/PS01_DP.log @@ -0,0 +1,863 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.28 (TeX Live 2025) (preloaded format=pdflatex 2025.10.7) 9 OCT 2025 20:32 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**PS01_DP.tex +(./PS01_DP.tex +LaTeX2e <2025-06-01> patch level 1 +L3 programming layer <2025-08-13> +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/article.cls +Document Class: article 2025/01/22 v1.4n Standard LaTeX document class +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/size12.clo +File: size12.clo 2025/01/22 v1.4n Standard LaTeX file (size option) +) +\c@part=\count275 +\c@section=\count276 +\c@subsection=\count277 +\c@subsubsection=\count278 +\c@paragraph=\count279 +\c@subparagraph=\count280 +\c@figure=\count281 +\c@table=\count282 +\abovecaptionskip=\skip49 +\belowcaptionskip=\skip50 +\bibindent=\dimen148 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2024/12/31 v1.2e Enhanced LaTeX Graphics (DPC,SPQR) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2022/05/29 v1.15 key=value parser (DPC) +\KV@toks@=\toks17 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2024/08/06 v1.4g Standard LaTeX Graphics (DPC,SPQR) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2023/12/02 v1.11 sin cos tan (DPC) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 106. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2024/04/13 v1.2c Graphics/color driver for pdftex +)) +\Gin@req@height=\dimen149 +\Gin@req@width=\dimen150 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/textcomp.sty +Package: textcomp 2024/04/24 v2.1b Standard LaTeX package +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/natbib/natbib.sty +Package: natbib 2010/09/13 8.31b (PWD, AO) +\bibhang=\skip51 +\bibsep=\skip52 +LaTeX Info: Redefining \cite on input line 694. +\c@NAT@ctr=\count283 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/setspace/setspace.sty +Package: setspace 2022/12/04 v6.7b set line spacing +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2020/01/02 v5.9 Page Geometry + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/iftex/ifvtex.sty +Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/iftex/iftex.sty +Package: iftex 2024/12/12 v1.0g TeX engine tests +)) +\Gm@cnth=\count284 +\Gm@cntv=\count285 +\c@Gm@tempcnt=\count286 +\Gm@bindingoffset=\dimen151 +\Gm@wd@mp=\dimen152 +\Gm@odd@mp=\dimen153 +\Gm@even@mp=\dimen154 +\Gm@layoutwidth=\dimen155 +\Gm@layoutheight=\dimen156 +\Gm@layouthoffset=\dimen157 +\Gm@layoutvoffset=\dimen158 +\Gm@dimlist=\toks18 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/color.sty +Package: color 2025/01/14 v1.3e Standard LaTeX Color (DPC) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package color Info: Driver file: pdftex.def on input line 149. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/mathcolor.ltx)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsmath.sty +Package: amsmath 2025/06/16 v2.17y AMS math features +\@mathmargin=\skip53 + +For additional information on amsmath, use the `?' option. +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amstext.sty +Package: amstext 2024/11/17 v2.01 AMS text + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsgen.sty +File: amsgen.sty 1999/11/30 v2.0 generic functions +\@emptytoks=\toks19 +\ex@=\dimen159 +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsbsy.sty +Package: amsbsy 1999/11/29 v1.2d Bold Symbols +\pmbraise@=\dimen160 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsopn.sty +Package: amsopn 2022/04/08 v2.04 operator names +) +\inf@bad=\count287 +LaTeX Info: Redefining \frac on input line 233. +\uproot@=\count288 +\leftroot@=\count289 +LaTeX Info: Redefining \overline on input line 398. +LaTeX Info: Redefining \colon on input line 409. +\classnum@=\count290 +\DOTSCASE@=\count291 +LaTeX Info: Redefining \ldots on input line 495. +LaTeX Info: Redefining \dots on input line 498. +LaTeX Info: Redefining \cdots on input line 619. +\Mathstrutbox@=\box53 +\strutbox@=\box54 +LaTeX Info: Redefining \big on input line 721. +LaTeX Info: Redefining \Big on input line 722. +LaTeX Info: Redefining \bigg on input line 723. +LaTeX Info: Redefining \Bigg on input line 724. +\big@size=\dimen161 +LaTeX Font Info: Redeclaring font encoding OML on input line 742. +LaTeX Font Info: Redeclaring font encoding OMS on input line 743. +\macc@depth=\count292 +LaTeX Info: Redefining \bmod on input line 904. +LaTeX Info: Redefining \pmod on input line 909. +LaTeX Info: Redefining \smash on input line 939. +LaTeX Info: Redefining \relbar on input line 969. +LaTeX Info: Redefining \Relbar on input line 970. +\c@MaxMatrixCols=\count293 +\dotsspace@=\muskip17 +\c@parentequation=\count294 +\dspbrk@lvl=\count295 +\tag@help=\toks20 +\row@=\count296 +\column@=\count297 +\maxfields@=\count298 +\andhelp@=\toks21 +\eqnshift@=\dimen162 +\alignsep@=\dimen163 +\tagshift@=\dimen164 +\tagwidth@=\dimen165 +\totwidth@=\dimen166 +\lineht@=\dimen167 +\@envbody=\toks22 +\multlinegap=\skip54 +\multlinetaggap=\skip55 +\mathdisplay@stack=\toks23 +LaTeX Info: Redefining \[ on input line 2949. +LaTeX Info: Redefining \] on input line 2950. +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amscls/amsthm.sty +Package: amsthm 2020/05/29 v2.20.6 +\thm@style=\toks24 +\thm@bodyfont=\toks25 +\thm@headfont=\toks26 +\thm@notefont=\toks27 +\thm@headpunct=\toks28 +\thm@preskip=\skip56 +\thm@postskip=\skip57 +\thm@headsep=\skip58 +\dth@everypar=\toks29 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty +Package: fancyvrb 2025/07/28 4.6 verbatim text (tvz,hv) +\FV@CodeLineNo=\count299 +\FV@InFile=\read2 +\FV@TabBox=\box55 +\c@FancyVerbLine=\count300 +\FV@StepNumber=\count301 +\FV@OutFile=\write3 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amssymb.sty +Package: amssymb 2013/01/14 v3.01 AMS font symbols + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amsfonts.sty +Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support +\symAMSa=\mathgroup4 +\symAMSb=\mathgroup5 +LaTeX Font Info: Redeclaring math symbol \hbar on input line 98. +LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold' +(Font) U/euf/m/n --> U/euf/b/n on input line 106. +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/tools/enumerate.sty +Package: enumerate 2023/07/04 v3.00 enumerate extensions (DPC) +\@enLab=\toks30 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xy.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xy.tex Bootstrap'ing: catcodes, docmode, (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyrecat.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyidioms.tex) + + Xy-pic version 3.8.9 <2013/10/06> + Copyright (c) 1991-2013 by Kristoffer H. Rose and others + Xy-pic is free software: see the User's Guide for details. + +Loading kernel: messages; fonts; allocations: state, +\X@c=\dimen168 +\Y@c=\dimen169 +\U@c=\dimen170 +\D@c=\dimen171 +\L@c=\dimen172 +\R@c=\dimen173 +\Edge@c=\toks31 +\X@p=\dimen174 +\Y@p=\dimen175 +\U@p=\dimen176 +\D@p=\dimen177 +\L@p=\dimen178 +\R@p=\dimen179 +\Edge@p=\toks32 +\X@origin=\dimen180 +\Y@origin=\dimen181 +\X@xbase=\dimen182 +\Y@xbase=\dimen183 +\X@ybase=\dimen184 +\Y@ybase=\dimen185 +\X@min=\dimen186 +\Y@min=\dimen187 +\X@max=\dimen188 +\Y@max=\dimen189 +\lastobjectbox@=\box56 +\zerodotbox@=\box57 +\almostz@=\dimen190 + direction, +\d@X=\dimen191 +\d@Y=\dimen192 +\K@=\count302 +\KK@=\count303 +\Direction=\count304 +\K@dXdY=\dimen193 +\K@dYdX=\dimen194 +\xyread@=\read3 +\xywrite@=\write4 +\csp@=\count305 +\quotPTK@=\dimen195 + utility macros; pictures: \xy, positions, +\swaptoks@@=\toks33 +\connectobjectbox@@=\box58 + objects, +\styletoks@=\toks34 + decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/iftex/ifpdf.sty +Package: ifpdf 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead. +) +Package: xy 2013/10/06 Xy-pic version 3.8.9 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyall.tex Xy-pic option: All features v.3.8 (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xycurve.tex Xy-pic option: Curve and Spline extension v.3.12 curve, +\crv@cnt@=\count306 +\crvpts@=\toks35 +\splinebox@=\box59 +\splineval@=\dimen196 +\splinedepth@=\dimen197 +\splinetol@=\dimen198 +\splinelength@=\dimen199 + circles, +\L@=\dimen256 + loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyframe.tex Xy-pic option: Frame and Bracket extension v.3.14 loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xycmtip.tex Xy-pic option: Computer Modern tip extension v.3.7 (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xytips.tex Xy-pic option: More Tips extension v.3.11 loaded) loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyline.tex Xy-pic option: Line styles extension v.3.10 +\xylinethick@=\dimen257 + loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyrotate.tex Xy-pic option: Rotate and Scale extension v.3.8 loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xycolor.tex Xy-pic option: Colour extension v.3.11 loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xymatrix.tex Xy-pic option: Matrix feature v.3.14 +\Row=\count307 +\Col=\count308 +\queue@=\toks36 +\queue@@=\toks37 +\qcount@=\count309 +\qcount@@=\count310 +\matrixsize@=\count311 + loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xyarrow.tex Xy-pic option: Arrow and Path feature v.3.9 path, \ar, loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xygraph.tex Xy-pic option: Graph feature v.3.11 loaded) loaded) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xypdf.tex Xy-pic option: PDF driver v.1.7 Xy-pic pdf driver: `color' extension support (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xypdf-co.tex loaded) Xy-pic pdf driver: `curve' extension support (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xypdf-cu.tex loaded) Xy-pic pdf driver: `frame' extension support (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xypdf-fr.tex loaded) Xy-pic pdf driver: `line' extension support (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xypdf-li.tex loaded) Xy-pic pdf driver: `rotate' extension support (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/xypic/xypdf-ro.tex loaded) loaded)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/endnotes/endnotes.sty +Package: endnotes 2020-01-02 endnotes package +\c@endnote=\count312 +\endnotesep=\dimen258 +\@enotes=\write5 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/lscape.sty +Package: lscape 2020/05/28 v3.02 Landscape Pages (DPC) +) +\c@com=\count313 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/float/float.sty +Package: float 2001/11/08 v1.3d Float enhancements (AL) +\c@float@type=\count314 +\float@exts=\toks38 +\float@box=\box60 +\@float@everytoks=\toks39 +\@floatcapt=\box61 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/hyperref/hyperref.sty +Package: hyperref 2025-07-12 v7.01o Hypertext links for LaTeX + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty +Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty +Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pdfescape/pdfescape.sty +Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty +Package: ltxcmds 2023-12-04 v1.26 LaTeX kernel commands for general use (HO) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty +Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/infwarerr/infwarerr.sty +Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO) +) +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/hycolor/hycolor.sty +Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/hyperref/nameref.sty +Package: nameref 2025-06-21 v2.57 Cross-referencing by name of section + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/refcount/refcount.sty +Package: refcount 2019/12/15 v3.6 Data extraction from label references (HO) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty +Package: gettitlestring 2019/12/15 v1.6 Cleanup title references (HO) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/kvoptions/kvoptions.sty +Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO) +)) +\c@section@level=\count315 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/etoolbox/etoolbox.sty +Package: etoolbox 2025/02/11 v2.5l e-TeX tools for LaTeX (JAW) +\etb@tempcnta=\count316 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/stringenc/stringenc.sty +Package: stringenc 2019/11/29 v1.12 Convert strings between diff. encodings (HO) +) +\@linkdim=\dimen259 +\Hy@linkcounter=\count317 +\Hy@pagecounter=\count318 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/hyperref/pd1enc.def +File: pd1enc.def 2025-07-12 v7.01o Hyperref: PDFDocEncoding definition (HO) +Now handling font encoding PD1 ... +... no UTF-8 mapping file for font encoding PD1 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/intcalc/intcalc.sty +Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO) +) +\Hy@SavedSpaceFactor=\count319 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/hyperref/puenc.def +File: puenc.def 2025-07-12 v7.01o Hyperref: PDF Unicode definition (HO) +Now handling font encoding PU ... +... no UTF-8 mapping file for font encoding PU +) +Package hyperref Info: Hyper figures OFF on input line 4195. +Package hyperref Info: Link nesting OFF on input line 4200. +Package hyperref Info: Hyper index ON on input line 4203. +Package hyperref Info: Plain pages OFF on input line 4210. +Package hyperref Info: Backreferencing OFF on input line 4215. +Package hyperref Info: Implicit mode ON; LaTeX internals redefined. +Package hyperref Info: Bookmarks ON on input line 4462. +\c@Hy@tempcnt=\count320 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/url/url.sty +\Urlmuskip=\muskip18 +Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc. +) +LaTeX Info: Redefining \url on input line 4801. +\XeTeXLinkMargin=\dimen260 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/bitset/bitset.sty +Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty +Package: bigintcalc 2019/12/15 v1.5 Expandable calculations on big integers (HO) +)) +\Fld@menulength=\count321 +\Field@Width=\dimen261 +\Fld@charsize=\dimen262 +Package hyperref Info: Hyper figures OFF on input line 6078. +Package hyperref Info: Link nesting OFF on input line 6083. +Package hyperref Info: Hyper index ON on input line 6086. +Package hyperref Info: backreferencing OFF on input line 6093. +Package hyperref Info: Link coloring OFF on input line 6098. +Package hyperref Info: Link coloring with OCG OFF on input line 6103. +Package hyperref Info: PDF/A mode OFF on input line 6108. +\Hy@abspage=\count322 +\c@Item=\count323 +\c@Hfootnote=\count324 +) +Package hyperref Info: Driver (autodetected): hpdftex. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/hyperref/hpdftex.def +File: hpdftex.def 2025-07-12 v7.01o Hyperref driver for pdfTeX +\Fld@listcount=\count325 +\c@bookmark@seq@number=\count326 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty +Package: rerunfilecheck 2025-06-21 v1.11 Rerun checks for auxiliary files (HO) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty +Package: uniquecounter 2019/12/15 v1.4 Provide unlimited unique counter (HO) +) +Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 284. +) +\Hy@SectionHShift=\skip59 +) +\c@lem=\count327 +\c@prop=\count328 +\c@thm=\count329 +\c@defn=\count330 +\c@cor=\count331 +\c@obs=\count332 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/titlesec/titlesec.sty +Package: titlesec 2025/01/04 v2.17 Sectioning titles +\ttl@box=\box62 +\beforetitleunit=\skip60 +\aftertitleunit=\skip61 +\ttl@plus=\dimen263 +\ttl@minus=\dimen264 +\ttl@toksa=\toks40 +\titlewidth=\dimen265 +\titlewidthlast=\dimen266 +\titlewidthfirst=\dimen267 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/tools/dcolumn.sty +Package: dcolumn 2023/07/08 v1.06 decimal alignment package (DPC) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/tools/array.sty +Package: array 2025/06/08 v2.6j Tabular extension package (FMi) +\col@sep=\dimen268 +\ar@mcellbox=\box63 +\extrarowheight=\dimen269 +\NC@list=\toks41 +\extratabsurround=\skip62 +\backup@length=\skip63 +\ar@cellbox=\box64 +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex +\pgfutil@everybye=\toks42 +\pgfutil@tempdima=\dimen270 +\pgfutil@tempdimb=\dimen271 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def +\pgfutil@abb=\box65 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/pgf.revision.tex) +Package: pgfrcs 2025-08-29 v3.1.11a (3.1.11a) +)) +Package: pgf 2025-08-29 v3.1.11a (3.1.11a) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex +Package: pgfsys 2025-08-29 v3.1.11a (3.1.11a) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex +\pgfkeys@pathtoks=\toks43 +\pgfkeys@temptoks=\toks44 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgfkeyslibraryfiltered.code.tex +\pgfkeys@tmptoks=\toks45 +)) +\pgf@x=\dimen272 +\pgf@y=\dimen273 +\pgf@xa=\dimen274 +\pgf@ya=\dimen275 +\pgf@xb=\dimen276 +\pgf@yb=\dimen277 +\pgf@xc=\dimen278 +\pgf@yc=\dimen279 +\pgf@xd=\dimen280 +\pgf@yd=\dimen281 +\w@pgf@writea=\write6 +\r@pgf@reada=\read4 +\c@pgf@counta=\count333 +\c@pgf@countb=\count334 +\c@pgf@countc=\count335 +\c@pgf@countd=\count336 +\t@pgf@toka=\toks46 +\t@pgf@tokb=\toks47 +\t@pgf@tokc=\toks48 +\pgf@sys@id@count=\count337 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg +File: pgf.cfg 2025-08-29 v3.1.11a (3.1.11a) +) +Driver file for pgf: pgfsys-pdftex.def + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.def +File: pgfsys-pdftex.def 2025-08-29 v3.1.11a (3.1.11a) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-pdf.def +File: pgfsys-common-pdf.def 2025-08-29 v3.1.11a (3.1.11a) +))) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.code.tex +File: pgfsyssoftpath.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgfsyssoftpath@smallbuffer@items=\count338 +\pgfsyssoftpath@bigbuffer@items=\count339 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.code.tex +File: pgfsysprotocol.code.tex 2025-08-29 v3.1.11a (3.1.11a) +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2024/09/29 v3.02 LaTeX color extensions (UK) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 274. +LaTeX Info: Redefining \color on input line 762. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/mathcolor.ltx) +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1349. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1353. +Package xcolor Info: Model `RGB' extended on input line 1365. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1367. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1370. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1371. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1372. +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex +Package: pgfcore 2025-08-29 v3.1.11a (3.1.11a) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex +\pgfmath@dimen=\dimen282 +\pgfmath@count=\count340 +\pgfmath@box=\box66 +\pgfmath@toks=\toks49 +\pgfmath@stack@operand=\toks50 +\pgfmath@stack@operation=\toks51 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithmetics.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex +\c@pgfmathroundto@lastzeros=\count341 +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfint.code.tex) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex +File: pgfcorepoints.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgf@picminx=\dimen283 +\pgf@picmaxx=\dimen284 +\pgf@picminy=\dimen285 +\pgf@picmaxy=\dimen286 +\pgf@pathminx=\dimen287 +\pgf@pathmaxx=\dimen288 +\pgf@pathminy=\dimen289 +\pgf@pathmaxy=\dimen290 +\pgf@xx=\dimen291 +\pgf@xy=\dimen292 +\pgf@yx=\dimen293 +\pgf@yy=\dimen294 +\pgf@zx=\dimen295 +\pgf@zy=\dimen296 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.code.tex +File: pgfcorepathconstruct.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgf@path@lastx=\dimen297 +\pgf@path@lasty=\dimen298 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.tex +File: pgfcorepathusage.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgf@shorten@end@additional=\dimen299 +\pgf@shorten@start@additional=\dimen300 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex +File: pgfcorescopes.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgfpic=\box67 +\pgf@hbox=\box68 +\pgf@layerbox@main=\box69 +\pgf@picture@serial@count=\count342 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code.tex +File: pgfcoregraphicstate.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgflinewidth=\dimen301 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.code.tex +File: pgfcoretransformations.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgf@pt@x=\dimen302 +\pgf@pt@y=\dimen303 +\pgf@pt@temp=\dimen304 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex +File: pgfcorequick.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex +File: pgfcoreobjects.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.code.tex +File: pgfcorepathprocessing.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex +File: pgfcorearrows.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgfarrowsep=\dimen305 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex +File: pgfcoreshade.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgf@max=\dimen306 +\pgf@sys@shading@range@num=\count343 +\pgf@shadingcount=\count344 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.code.tex +File: pgfcoreimage.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex +File: pgfcoreexternal.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgfexternal@startupbox=\box70 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.code.tex +File: pgfcorelayers.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransparency.code.tex +File: pgfcoretransparency.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex +File: pgfcorepatterns.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.tex +File: pgfcorerdf.code.tex 2025-08-29 v3.1.11a (3.1.11a) +))) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.code.tex +File: pgfmoduleshapes.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgfnodeparttextbox=\box71 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.tex +File: pgfmoduleplot.code.tex 2025-08-29 v3.1.11a (3.1.11a) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version-0-65.sty +Package: pgfcomp-version-0-65 2025-08-29 v3.1.11a (3.1.11a) +\pgf@nodesepstart=\dimen307 +\pgf@nodesepend=\dimen308 +) +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version-1-18.sty +Package: pgfcomp-version-1-18 2025-08-29 v3.1.11a (3.1.11a) +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/utilities/pgffor.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/pgf/math/pgfmath.sty (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex +Package: pgffor 2025-08-29 v3.1.11a (3.1.11a) +\pgffor@iter=\dimen309 +\pgffor@skip=\dimen310 +\pgffor@stack=\toks52 +\pgffor@toks=\toks53 +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +Package: tikz 2025-08-29 v3.1.11a (3.1.11a) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.code.tex +File: pgflibraryplothandlers.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgf@plot@mark@count=\count345 +\pgfplotmarksize=\dimen311 +) +\tikz@lastx=\dimen312 +\tikz@lasty=\dimen313 +\tikz@lastxsaved=\dimen314 +\tikz@lastysaved=\dimen315 +\tikz@lastmovetox=\dimen316 +\tikz@lastmovetoy=\dimen317 +\tikzleveldistance=\dimen318 +\tikzsiblingdistance=\dimen319 +\tikz@figbox=\box72 +\tikz@figbox@bg=\box73 +\tikz@tempbox=\box74 +\tikz@tempbox@bg=\box75 +\tikztreelevel=\count346 +\tikznumberofchildren=\count347 +\tikznumberofcurrentchild=\count348 +\tikz@fig@count=\count349 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.code.tex +File: pgfmodulematrix.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\pgfmatrixcurrentrow=\count350 +\pgfmatrixcurrentcolumn=\count351 +\pgf@matrix@numberofcolumns=\count352 +) +\tikz@expandcount=\count353 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex +File: tikzlibrarytopaths.code.tex 2025-08-29 v3.1.11a (3.1.11a) +))) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryarrows.code.tex +File: tikzlibraryarrows.code.tex 2025-08-29 v3.1.11a (3.1.11a) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/generic/pgf/libraries/pgflibraryarrows.code.tex +File: pgflibraryarrows.code.tex 2025-08-29 v3.1.11a (3.1.11a) +\arrowsize=\dimen320 +)) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/multirow/multirow.sty +Package: multirow 2024/11/12 v2.9 Span multiple rows of a table +\multirow@colwidth=\skip64 +\multirow@cntb=\count354 +\multirow@dima=\skip65 +\bigstrutjot=\dimen321 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/listings.sty +\lst@mode=\count355 +\lst@gtempboxa=\box76 +\lst@token=\toks54 +\lst@length=\count356 +\lst@currlwidth=\dimen322 +\lst@column=\count357 +\lst@pos=\count358 +\lst@lostspace=\dimen323 +\lst@width=\dimen324 +\lst@newlines=\count359 +\lst@lineno=\count360 +\lst@maxwidth=\dimen325 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/lstpatch.sty +File: lstpatch.sty 2024/09/23 1.10c (Carsten Heinz) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/lstmisc.sty +File: lstmisc.sty 2024/09/23 1.10c (Carsten Heinz) +\c@lstnumber=\count361 +\lst@skipnumbers=\count362 +\lst@framebox=\box77 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/listings.cfg +File: listings.cfg 2024/09/23 1.10c listings configuration +)) +Package: listings 2024/09/23 1.10c (Carsten Heinz) +\c@hyp=\count363 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def +File: l3backend-pdftex.def 2025-06-09 L3 backend support: PDF output (pdfTeX) +\l__color_backend_stack_int=\count364 +) (./PS01_DP.aux) +\openout1 = `PS01_DP.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. +LaTeX Font Info: Checking defaults for PU/pdf/m/n on input line 67. +LaTeX Font Info: ... okay on input line 67. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty +Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 485. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live +)) +*geometry* driver: auto-detecting +*geometry* detected driver: pdftex +*geometry* verbose mode - [ preamble ] result: +* driver: pdftex +* paper: a4paper +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* modes: +* h-part:(L,W,R)=(72.26999pt, 452.9679pt, 72.26999pt) +* v-part:(T,H,B)=(72.26999pt, 700.50687pt, 72.26999pt) +* \paperwidth=597.50787pt +* \paperheight=845.04684pt +* \textwidth=452.9679pt +* \textheight=700.50687pt +* \oddsidemargin=0.0pt +* \evensidemargin=0.0pt +* \topmargin=-37.0pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=12.0pt +* \footskip=30.0pt +* \marginparwidth=44.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.8pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +LaTeX Font Info: Trying to load font information for U+msa on input line 67. +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/umsa.fd +File: umsa.fd 2013/01/14 v3.01 AMS symbols A +) +LaTeX Font Info: Trying to load font information for U+msb on input line 67. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/umsb.fd +File: umsb.fd 2013/01/14 v3.01 AMS symbols B +) +Package xypdf Info: Line width: 0.47998pt on input line 67. +Package hyperref Info: Link coloring OFF on input line 67. + (./PS01_DP.out) (./PS01_DP.out) +\@outlinefile=\write7 +\openout7 = `PS01_DP.out'. + +\c@lstlisting=\count365 + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/lstlang1.sty +File: lstlang1.sty 2024/09/23 1.10c listings language file +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/lstlang2.sty +File: lstlang2.sty 2024/09/23 1.10c listings language file +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/listings/lstlang3.sty +File: lstlang3.sty 2024/09/23 1.10c listings language file +) +Package hyperref Info: bookmark level for unknown lstlisting defaults to 0 on input line 83. + (./PS01_DP.R +LaTeX Font Info: Trying to load font information for OML+cmr on input line 36. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/omlcmr.fd +File: omlcmr.fd 2024/11/19 v2.5n Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OML/cmr/m/n' in size <10> not available +(Font) Font shape `OML/cmm/m/it' tried instead on input line 36. +) +Underfull \hbox (badness 10000) in paragraph at lines 88--89 + + [] + + +Underfull \hbox (badness 10000) in paragraph at lines 90--91 + + [] + + + +[1 + +{/Users/damirish/Library/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./PS01_DP.R) (./PS01_DP.R) (./PS01_DP.R) (./PS01_DP.R) + +[2] (./PS01_DP.R) + +! LaTeX Error: There's no line here to end. + +See the LaTeX manual or LaTeX Companion for explanation. +Type H for immediate help. + ... + +l.143 \vspace + {.5cm} +Your command was ignored. +Type I to replace it with another command, +or to continue without it. + + +Underfull \hbox (badness 10000) in paragraph at lines 145--146 + + [] + + +Underfull \hbox (badness 10000) in paragraph at lines 151--152 + + [] + + +Underfull \hbox (badness 10000) in paragraph at lines 156--157 + + [] + +(./PS01_DP.R) + +[3] (./PS01_DP.R) + +[4] (./PS01_DP.R) + +[5] (./PS01_DP.R) + +File: scatter_x1_y.png Graphic file (type png) + +Package pdftex.def Info: scatter_x1_y.png used on input line 212. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[6 <./scatter_x1_y.png>] (./PS01_DP.R) + +File: scatter_x2_y.png Graphic file (type png) + +Package pdftex.def Info: scatter_x2_y.png used on input line 222. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[7 <./scatter_x2_y.png>] (./PS01_DP.R) + +File: scatter_x3_y.png Graphic file (type png) + +Package pdftex.def Info: scatter_x3_y.png used on input line 232. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[8 <./scatter_x3_y.png>] (./PS01_DP.R) + +File: scatter_x1_x2.png Graphic file (type png) + +Package pdftex.def Info: scatter_x1_x2.png used on input line 242. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[9 <./scatter_x1_x2.png>] (./PS01_DP.R) + +File: scatter_x1_x3.png Graphic file (type png) + +Package pdftex.def Info: scatter_x1_x3.png used on input line 252. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[10 <./scatter_x1_x3.png>] (./PS01_DP.R) + +File: scatter_x2_x3.png Graphic file (type png) + +Package pdftex.def Info: scatter_x2_x3.png used on input line 262. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[11 <./scatter_x2_x3.png>] (./PS01_DP.R) + +File: boxplot_reg_y.png Graphic file (type png) + +Package pdftex.def Info: boxplot_reg_y.png used on input line 273. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[12 <./boxplot_reg_y.png>] (./PS01_DP.R +LaTeX Font Info: Trying to load font information for OMS+cmr on input line 189. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 2024/11/19 v2.5n Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 189. +) + +File: scatter_x1_y_reg.png Graphic file (type png) + +Package pdftex.def Info: scatter_x1_y_reg.png used on input line 284. +(pdftex.def) Requested size: 317.07614pt x 317.08472pt. + + +[13 <./scatter_x1_y_reg.png>] + +[14] (./PS01_DP.aux) + *********** +LaTeX2e <2025-06-01> patch level 1 +L3 programming layer <2025-08-13> + *********** +Package rerunfilecheck Info: File `PS01_DP.out' has not changed. +(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0. + ) +Here is how much of TeX's memory you used: + 27661 strings out of 469781 + 483466 string characters out of 5481231 + 1217607 words of memory out of 5000000 + 55411 multiletter control sequences out of 15000+600000 + 638225 words of font info for 87 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 84i,6n,91p,3239b,2131s stack positions out of 10000i,1000n,20000p,200000b,200000s + +Output written on PS01_DP.pdf (14 pages, 326082 bytes). +PDF statistics: + 293 PDF objects out of 1000 (max. 8388607) + 235 compressed objects within 3 object streams + 131 named destinations out of 1000 (max. 500000) + 53 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/problemSets/PS01/my_answers/PS01_DP.out b/problemSets/PS01/my_answers/PS01_DP.out new file mode 100644 index 0000000..e69de29 diff --git a/problemSets/PS01/my_answers/PS01_DP.pdf b/problemSets/PS01/my_answers/PS01_DP.pdf new file mode 100644 index 0000000..8c0ebca Binary files /dev/null and b/problemSets/PS01/my_answers/PS01_DP.pdf differ diff --git a/problemSets/PS01/my_answers/PS01_DP.synctex.gz b/problemSets/PS01/my_answers/PS01_DP.synctex.gz new file mode 100644 index 0000000..04567fb Binary files /dev/null and b/problemSets/PS01/my_answers/PS01_DP.synctex.gz differ diff --git a/problemSets/PS01/my_answers/PS01_DP.tex b/problemSets/PS01/my_answers/PS01_DP.tex new file mode 100644 index 0000000..e627ce5 --- /dev/null +++ b/problemSets/PS01/my_answers/PS01_DP.tex @@ -0,0 +1,289 @@ +\documentclass[12pt,letterpaper]{article} +\usepackage{graphicx,textcomp} +\usepackage{natbib} +\usepackage{setspace} +\usepackage[a4paper,margin=1in]{geometry} +\usepackage{color} +\usepackage[reqno]{amsmath} +\usepackage{amsthm} +\usepackage{fancyvrb} +\usepackage{amssymb,enumerate} +\usepackage[all]{xy} +\usepackage{endnotes} +\usepackage{lscape} +\newtheorem{com}{Comment} +\usepackage{float} +\usepackage{hyperref} +\newtheorem{lem} {Lemma} +\newtheorem{prop}{Proposition} +\newtheorem{thm}{Theorem} +\newtheorem{defn}{Definition} +\newtheorem{cor}{Corollary} +\newtheorem{obs}{Observation} +\usepackage[compact]{titlesec} +\usepackage{dcolumn} +\usepackage{tikz} +\usetikzlibrary{arrows} +\usepackage{multirow} +\usepackage{xcolor} +\newcolumntype{.}{D{.}{.}{-1}} +\newcolumntype{d}[1]{D{.}{.}{#1}} +\definecolor{light-gray}{gray}{0.65} +\usepackage{url} +\usepackage{listings} +\usepackage{color} + +\definecolor{codegreen}{rgb}{0,0.6,0} +\definecolor{codegray}{rgb}{0.5,0.5,0.5} +\definecolor{codepurple}{rgb}{0.58,0,0.82} +\definecolor{backcolour}{rgb}{0.95,0.95,0.92} + +\lstdefinestyle{mystyle}{ + backgroundcolor=\color{backcolour}, + commentstyle=\color{codegreen}, + keywordstyle=\color{magenta}, + numberstyle=\tiny\color{codegray}, + stringstyle=\color{codepurple}, + basicstyle=\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + keepspaces=true, + numbers=left, + numbersep=5pt, + showspaces=false, + showstringspaces=false, + showtabs=false, + tabsize=2 +} +\lstset{style=mystyle} +\newcommand{\Sref}[1]{Section~\ref{#1}} +\newtheorem{hyp}{Hypothesis} + +\title{Problem Set 1} +\date{Due: October 9, 2025} +\author{Applied Stats/Quant Methods 1} + +\begin{document} + \maketitle + + \section*{Instructions} + \begin{itemize} + \item Please show your work! You may lose points by simply writing in the answer. If the problem requires you to execute commands in \texttt{R}, please include the code you used to get your answers. Please also include the \texttt{.R} file that contains your code. If you are not sure if work needs to be shown for a particular problem, please ask. +\item Your homework should be submitted electronically on GitHub. +\item This problem set is due before 23:59 on Thursday October 9, 2025. No late assignments will be accepted. + \end{itemize} + + \vspace{1cm} + \section*{Question 1: Education} + +A school counselor was curious about the average of IQ of the students in her school and took a random sample of 25 students' IQ scores. The following is the data set:\\ +\vspace{.5cm} + +\lstinputlisting[language=R, firstline=36, lastline=36]{PS01_DP.R} + +\vspace{1cm} + +\begin{enumerate} + \item Find a 90\% confidence interval for the average student IQ in the school.\\ + + \item Next, the school counselor was curious whether the average student IQ in her school is higher than the average IQ score (100) among all the schools in the country.\\ + + \noindent Using the same sample, conduct the appropriate hypothesis test with $\alpha=0.05$. +\end{enumerate} + +\newpage + \section*{Solution - Question 1: Education} +\vspace{.5cm} +\subsection*{1. Confidence Interval for the Average Student IQ in the School} +\vspace{.5cm} +Since the sampling size is smaller than 30, we cannot assume that there is a normal sampling distribution. Instead, we will assume a t-distribution with 25-1 = 24 degrees of freedom (because the sample has n = 25 observations). \\[0.5cm] +The process for determining the confidence interval is outlined below: +\begin{itemize} + \item + Calculate the mean + \lstinputlisting[language=R, firstline=39, lastline=40]{PS01_DP.R} + \begin{verbatim} + [1] 98.44 + \end{verbatim} + \item + Calculate the sum of the squared errors to get the variance, and then the standard deviation (the square root of the variance) + \lstinputlisting[language=R, firstline=43, lastline=47]{PS01_DP.R} + \begin{verbatim} + [1] 13.09287 + \end{verbatim} + \item + Calculate the standard error + \lstinputlisting[language=R, firstline=50, lastline=51]{PS01_DP.R} + \begin{verbatim} + [1] 2.618575 + \end{verbatim} + \item + Find the t-score for the desired confidence level, with 24 degrees of freedom \\ + I calculated the t-score instead of a Z-score because the assumed sampling distribution is a t-distribution with 24 degrees of freedom. + \lstinputlisting[language=R, firstline=54, lastline=55]{PS01_DP.R} + \begin{verbatim} + [1] 1.710882 + \end{verbatim} + \newpage + \item + Construct the confidence interval by calculating its lower and upper limits + \lstinputlisting[language=R, firstline=58, lastline=61]{PS01_DP.R} + \begin{verbatim} + > lowerlimit + [1] 93.95993 + > upperlimit + [1] 102.9201 + \end{verbatim} + \item + \textbf{Conclusion:} The interval [93.96, 102.92] contains the true average of student IQs at the school (the true population mean) at least 90\% of the time, with repeated random sampling. + \end{itemize} +\vspace{1cm} +\subsection*{2. Hypothesis Testing}\\ +\vspace{.5cm} +\begin{itemize} + \item \underline{\textbf{Step 1:} assumptions}\\ + \begin{itemize} + \item the data is quantitative and continuous + \item the sampling method is random + \item the sample size is smaller than 30, so we assume it follows a t-distribution with 24 degrees of freedom and not a normal distribution; the test statistic that was calculated is a t-score + \end{itemize} + \item \underline{\textbf{Step 2:} formulate hypotheses}\\ + \begin{itemize} + \item \textbf{Null hypothesis:} the average student IQ in the school (the mean) is lower than or equal to 100 + \item \textbf{Alternative hypothesis:} the average student IQ in the school (the mean) is higher than 100 + \end{itemize} + \item \underline{\textbf{Step 3: } calculate the test statistic : t-score}\\ + \lstinputlisting[language=R, firstline=70, lastline=71]{PS01_DP.R} + \begin{verbatim} + [1] -0.5957439 + \end{verbatim} +\newpage + \item \underline{\textbf{Step 4:} calculate the p-value}\\[0.5cm] + Because the hypothesis test that is carried out is one-sided, and the alternative hypothesis is that the true population mean is greater than 100, we are interested in the upper tail of the distribution. Hence, the lower.tail argument was set to FALSE. +\lstinputlisting[language=R, firstline=74, lastline=75]{PS01_DP.R} + \begin{verbatim} + [1] 0.7215383 + \end{verbatim} + \item\underline{\textbf{Step 5:} draw a conclusion}\\[0.5cm] + The p-value is much higher than the alpha value (0.05). Thus, we cannot reject the null hypothesis that the average student IQ in the school is lower than or equal to 100. The test result is not statistically significant. +\end{itemize} + +\newpage + \section*{Question 2: Political Economy} + +\noindent Researchers are curious about what affects the amount of money communities spend on addressing homelessness. The following variables constitute our data set about social welfare expenditures in the USA. \\ +\vspace{.5cm} + + +\begin{tabular}{r|l} + \texttt{State} &\emph{50 states in US} \\ + \texttt{Y} & \emph{per capita expenditure on shelters/housing assistance in state}\\ + \texttt{X1} &\emph{per capita personal income in state} \\ + \texttt{X2} & \emph{Number of residents per 100,000 that are "financially insecure" in state}\\ + \texttt{X3} & \emph{Number of people per thousand residing in urban areas in state} \\ + \texttt{Region} & \emph{1=Northeast, 2= North Central, 3= South, 4=West} \\ +\end{tabular} + +\vspace{.5cm} +\noindent Explore the \texttt{expenditure} data set and import data into \texttt{R}. +\vspace{.5cm} +\lstinputlisting[language=R, firstline=6, lastline=6]{PS01_DP.R} +\vspace{.5cm} +\begin{itemize} + +\item +Please plot the relationships among \emph{Y}, \emph{X1}, \emph{X2}, and \emph{X3}? What are the correlations among them (you just need to describe the graph and the relationships among them)? +\vspace{.5cm} +\item +Please plot the relationship between \emph{Y} and \emph{Region}? On average, which region has the highest per capita expenditure on housing assistance? +\vspace{.5cm} +\item +Please plot the relationship between \emph{Y} and \emph{X1}? Describe this graph and the relationship. Reproduce the above graph including one more variable \emph{Region} and display different regions with different types of symbols and colors. +\end{itemize} +\newpage + \section*{Solution - Question 2: Political Economy} + \subsection*{Plot the relationships among X1, X2, X3 and Y} +\lstinputlisting[language=R, firstline=96, lastline=103]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X1 and Y} + \label{fig:plot_1} + \includegraphics[width=.7\textwidth]{scatter_x1_y.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm]There is a moderate positive association between the personal income and the expenditure on housing assistance per capita in a state. The Pearson correlation coefficient points towards the same conclusion, as its value is above 0, but not close enough to 1 to suggest a strong association between the two variables. A positive linear pattern can also be distinguished by looking at the plot. +\newpage +\lstinputlisting[language=R, firstline=107, lastline=114]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X2 and Y} + \label{fig:plot_2} + \includegraphics[width=.7\textwidth]{scatter_x2_y.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] There is a moderate positive association between the number of "financially insecure" residents and the expenditure on housing assistance per capita in a state. The Pearson correlation coefficient suggests the same, as its value is above 0, but not above 0.5. Visually analysing the plot, there is an upward linear trend that can be identified, but there are many dots that fall outside of it, which suggests that the association is fairly weak. +\newpage +\lstinputlisting[language=R, firstline=118, lastline=125]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X3 and Y} + \label{fig:plot_3} + \includegraphics[width=.7\textwidth]{scatter_x3_y.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] There is a mild positive association also between the number of residents in urban areas and the expenditure on housing assistance per capita in a state. The value of the Pearson correlation coefficient is 0.46, suggesting a weak association between the two variables. There is a faint upward linear trend that can be observed from the plot, but the dots are very loosely grouped around it. +\newpage +\lstinputlisting[language=R, firstline=129, lastline=136]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X1 and X2} + \label{fig:plot_4} + \includegraphics[width=.7\textwidth]{scatter_x1_x2.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] There doesn't seem to be a linear association between personal income per capita and the number of "financially insecure" residents within a state. The data points appear to be quite scattered in the graph, showing no clear linear trend. The Pearson correlation coefficient has a value of 0.21, indicating that we can only observe a very weak, if any, association between the two variables. +\newpage +\lstinputlisting[language=R, firstline=140, lastline=147]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X1 and X3} + \label{fig:plot_5} + \includegraphics[width=.7\textwidth]{scatter_x1_x3.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] There is a moderate positive association between the personal income per capita and the number of urban residents in a state. The value of the Pearson correlation coefficient shows that these two variables have the strongest correlation within the dataset, but the value is still not high enough to indicate a strong association. Visually inspecting the plot, it can be observed that the dots follow an upward linear trend, but they are not very tightly grouped around it. +\newpage +\lstinputlisting[language=R, firstline=151, lastline=158]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X2 and X3} + \label{fig:plot_6} + \includegraphics[width=.7\textwidth]{scatter_x2_x3.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] There doesn't seem to be a linear association between the number of "financially insecure" residents and the number of urban residents in a state. The dots are spread out quite evenly within the plot, without any distinguishable pattern. The Pearson correlation coefficient is quite close to 0, further indicating the absence of a meaningful association between the two variables. +\newpage +\subsection*{Plot the relationship between Y and Region} +\lstinputlisting[language=R, firstline=170, lastline=178]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Boxplot of Y and Region} + \label{fig:plot_7} + \includegraphics[width=.7\textwidth]{boxplot_reg_y.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] In order to visualize the average expenditure on housing assistance in each region, I generated a boxplot. This type of plot was chosen because it shows the distribution of data for each region, indicating the median but also the variability of the values. \\ It can be observed that the West region has the highest median for expenditure on housing assistance per capita and its interquartile range starts and ends at higher values than the others. Thus, the West spends on average the most out of the regions to provide housing assistance. +\newpage +\subsection*{Plot the relationship between Y, X1 and Region } +\lstinputlisting[language=R, firstline=184, lastline=195]{PS01_DP.R} +\vspace{.5cm} +\begin{figure}[h!]\centering + \caption{\footnotesize Scatterplot of X1, Y and Region} + \label{fig:plot_8} + \includegraphics[width=.7\textwidth]{scatter_x1_y_reg.png} +\end{figure} +\vspace{.5cm} +\underline{\textbf{Interpretation:}}\\[.3cm] In the previous plot of personal income and expenditure on housing assistance per capita in a state (Figure 1), a moderate positive association between the two was identified. This plot highlighting the values from different regions adds a new layer of interpretation. \\ Most notably, the South region shows on average both low income and low expenditure on housing assistace. The North Central region seems to also have mostly values for personal income that are proportional with the expenditure on housing assistance, the observations being concetrated towards the centre of the plot. Nevertheless, the West region shows some contrast in terms of expenditure on housing assistance for similar personal income values. This suggests that factors at the regional level might be correlated with both the housing assistance expenditure and the personal income per capita, and the association between the two of them might require further consideration and assessment. +\end{document} + diff --git a/problemSets/PS01/my_answers/boxplot_reg_y.png b/problemSets/PS01/my_answers/boxplot_reg_y.png new file mode 100644 index 0000000..8d5c3fe Binary files /dev/null and b/problemSets/PS01/my_answers/boxplot_reg_y.png differ diff --git a/problemSets/PS01/my_answers/scatter_x1_x2.png b/problemSets/PS01/my_answers/scatter_x1_x2.png new file mode 100644 index 0000000..f180364 Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x1_x2.png differ diff --git a/problemSets/PS01/my_answers/scatter_x1_x3.png b/problemSets/PS01/my_answers/scatter_x1_x3.png new file mode 100644 index 0000000..27e903e Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x1_x3.png differ diff --git a/problemSets/PS01/my_answers/scatter_x1_y.png b/problemSets/PS01/my_answers/scatter_x1_y.png new file mode 100644 index 0000000..a481a90 Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x1_y.png differ diff --git a/problemSets/PS01/my_answers/scatter_x1_y_reg.png b/problemSets/PS01/my_answers/scatter_x1_y_reg.png new file mode 100644 index 0000000..b49b949 Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x1_y_reg.png differ diff --git a/problemSets/PS01/my_answers/scatter_x2_x3.png b/problemSets/PS01/my_answers/scatter_x2_x3.png new file mode 100644 index 0000000..3fd7cc7 Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x2_x3.png differ diff --git a/problemSets/PS01/my_answers/scatter_x2_y.png b/problemSets/PS01/my_answers/scatter_x2_y.png new file mode 100644 index 0000000..f0a8298 Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x2_y.png differ diff --git a/problemSets/PS01/my_answers/scatter_x3_y.png b/problemSets/PS01/my_answers/scatter_x3_y.png new file mode 100644 index 0000000..0e1fdef Binary files /dev/null and b/problemSets/PS01/my_answers/scatter_x3_y.png differ diff --git a/problemSets/PS01/template/.RData b/problemSets/PS01/template/.RData new file mode 100644 index 0000000..12833de Binary files /dev/null and b/problemSets/PS01/template/.RData differ diff --git a/problemSets/PS01/template/.Rapp.history b/problemSets/PS01/template/.Rapp.history new file mode 100644 index 0000000..e69de29 diff --git a/problemSets/PS01/template/.Rhistory b/problemSets/PS01/template/.Rhistory new file mode 100644 index 0000000..8afaf03 --- /dev/null +++ b/problemSets/PS01/template/.Rhistory @@ -0,0 +1,512 @@ +x = "Region", +y = "Y") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("black", "red"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +color = "Residence") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("black", "red", "green", "pink"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +color = "Residence") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("blue", "red", "green", "pink"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("blue", "red", "green", "orange"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(1, 4, 16, 17), labels = c("1", "2", "3", "4")) +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(1, 4, 16, 17), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(15, 16, 17, 18), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region)), shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region)), shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region)), shape = factor(Region))) + +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +geom_point(size = 3) + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +geom_point(size = 3) + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region", +shape = "Region") +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region), shape = factor(Region)) + +geom_point(size = 3) + +scale_color_manual(values = c("lightblue", "red", "green", "black"), labels = c("1", "2", "3", "4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region", +shape = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region") +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +lapply(c("ggplot2"), pkgTest) +expenditure <- read.table("https://raw.githubusercontent.com/ASDS-TCD/StatsI_2025/main/datasets/expenditure.txt", header=T) +head(expenditure) +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region") +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region") +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region") +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y") +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +geom_boxplot() + +theme( +legend.position="none", +plot.title = element_text(size=11)) + +labs(title = "Boxplot for Y for each region", +x = "Region", +y = "Y") + +theme_minimal() +ggplot(expenditure, aes(x = X2, y = X3)) + +geom_point() + +labs(title = "Relationship between X2 and X3", +x = "X2 variable", +y = "X3 variable") + +theme_minimal() +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +geom_boxplot() + +theme( +legend.position="none", +plot.title = element_text(size=11)) + +labs(title = "Boxplot for Y for each region", +x = "Region", +y = "Y") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +geom_point(size = 3) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y" +) +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region)) + +geom_point(size = 3) + +scale_color_manual(values = c("blue", "red", "green", "purple"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region") +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region)) + +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region)) + +geom_point(size = 3) + +scale_color_manual(values = c("blue", "red", "green", "purple"), labels = c("1", "2", "3", "4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +color = "Region")) +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +geom_boxplot() + +theme( +legend.position="none", +plot.title = element_text(size=11)) + +labs(title = "Boxplot for Y for each region", +x = "Region", +y = "Y") + +theme_minimal() +ggplot(expenditure, aes(x = X2, y = X3)) + +geom_point() + +labs(title = "Relationship between X2 and X3", +x = "X2 variable", +y = "X3 variable") + +theme_minimal() +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +geom_boxplot() + +theme( +legend.position="none", +plot.title = element_text(size=11)) + +labs(title = "Boxplot for Y for each region", +x = "Region", +y = "Y") + +theme_minimal() +ggplot(df, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +color = "Residence") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +color = "Residence") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point() + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +shape = "Region", +color = "Residence") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Education and Income", +x = "Monthly Net Income (Euro)", +y = "Years of University Education", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 22, 23, 24), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(16, 22, 23, 24), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(16, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(14, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(11, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(12, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(20, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ts = (mean - 100)/sterror +ts +ggplot(expenditure, aes(x = X1, y = Y)) + +geom_point() + +labs(title = "Relationship between X1 and Y", +x = "X1 variable", +y = "Y variable") + +theme_minimal() +lowerlimit = mean - t * sterror +upperlimit = mean + t * sterror +lowerlimit +upperlimit +ggplot(expenditure, aes(x = X1, y = Y)) + +geom_point() + +geom_smooth(method = "lm") + +labs(title = "Relationship between X1 and Y", +x = "X1 variable", +y = "Y variable") + +theme_minimal() +ggplot(expenditure, aes(x = X2, y = Y)) + +geom_point() + +geom_smooth(method = "lm") + +labs(title = "Relationship between X2 and Y", +x = "X2 variable", +y = "Y variable") + +theme_minimal() +ggplot(expenditure, aes(x = X3, y = Y)) + +geom_point() + +geom_smooth(method = "lm") + +labs(title = "Relationship between X3 and Y", +x = "X3 variable", +y = "Y variable") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = X2)) + +geom_point() + +geom_smooth(method = "lm") +labs(title = "Relationship between X1 and X2", +x = "X1 variable", +y = "X2 variable") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = X2)) + +geom_point() + +geom_smooth(method = "lm") + +labs(title = "Relationship between X1 and X2", +x = "X1 variable", +y = "X2 variable") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = X3)) + +geom_point() + +geom_smooth(method = "lm") + +labs(title = "Relationship between X1 and X3", +x = "X1 variable", +y = "X3 variable") + +theme_minimal() +ggplot(expenditure, aes(x = X2, y = X3)) + +geom_point() + +geom_smooth(method = "lm") + +labs(title = "Relationship between X2 and X3", +x = "X2 variable", +y = "X3 variable") + +theme_minimal() +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +geom_boxplot() + +geom_smooth(method = "lm") + +theme( +legend.position="none", +plot.title = element_text(size=11)) + +labs(title = "Boxplot for Y for each region", +x = "Region", +y = "Y") + +theme_minimal() +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + +geom_boxplot() + +theme( +legend.position="none", +plot.title = element_text(size=11)) + +labs(title = "Boxplot for Y for each region", +x = "Region", +y = "Y") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +geom_smooth(method = "lm") + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + +geom_point(size = 3) + +scale_color_manual(values = c("black", "red", "green", "purple"), labels = c("region 1", "region 2", "region 3", "region 4")) + +scale_shape_manual(values = c(21, 17, 18, 19), labels = c("region 1", "region 2", "region 3", "region 4")) + +labs(title = "Relationship between Y and X1", +x = "X1", +y = "Y", +shape = "Region", +color = "Region") + +theme_minimal() +ts = (mean - 100)/sterror +ts +t = qt(p = 0.1/2, df = 24, lower.tail = F) +t +ts = (mean - 100)/sterror +ts +ts = (mean - 100)/sterror +ts +p = pt(abs(ts), df = 24, lower.tail = F) +p +p = pt(abs(ts), df = 24, lower.tail = T) +p +p = pt(abs(ts), df = 24, lower.tail = FALSE) +p diff --git a/problemSets/PS01/template/PS01.R b/problemSets/PS01/template/PS01.R index 180e69e..c8cb9f6 100644 --- a/problemSets/PS01/template/PS01.R +++ b/problemSets/PS01/template/PS01.R @@ -27,7 +27,7 @@ pkgTest <- function(pkg){ # ex: stringr # lapply(c("stringr"), pkgTest) -lapply(c(), pkgTest) +lapply(c(), pkgTest, "ggplot2") ##################### # Problem 1 @@ -35,8 +35,131 @@ lapply(c(), pkgTest) y <- c(105, 69, 86, 100, 82, 111, 104, 110, 87, 108, 87, 90, 94, 113, 112, 98, 80, 97, 95, 111, 114, 89, 95, 126, 98) +# calculate the mean +mean_y = mean(y) +mean_y + +# calculate the standard deviation +stdev = sd(y) +stdev +#demeanedSum <- y - mean +#sum(demeanedSum) +#squaredError <- demeanedSum ^ 2 +#sum(squaredError) +#variance <- sum(squaredError)/(length(y)-1) +#variance +#stdev = sqrt(variance) +#stdev + +# calculate the standard error +sterror = stdev/sqrt(length(y)) +sterror + +# find the t-score for the desired confidence level +p = (1 - 0.9)/2 +p +t = qt(p = p, df = 24, lower.tail = FALSE) +t + +# construct the confidence interval +lowerlimit = mean_y - t * sterror +upperlimit = mean_y + t * sterror +lowerlimit +upperlimit + +# hypothesis testing +# step 1 - assumptions: data is quantitative, sampling method is random, sample size is smaller than 30 -> t-score instead of z-score + +# step 2- null hypothesis: mean is lower or equal to 100 +# alternative hypothesis: mean is higher than 100 + +# step 3 - calculate a test statistic +ts = (mean_y - 100)/sterror +ts + +# step 4 - calculate the p-value +p = pt(ts, df = 24, lower.tail = FALSE) +p +# step 5 - conclusion +# p-value is higher than alpha -> cannot reject the null hypothesis that the mean is lower or equal to 100 + + ##################### # Problem 2 ##################### +lapply(c("ggplot2"), pkgTest) expenditure <- read.table("https://raw.githubusercontent.com/ASDS-TCD/StatsI_2025/main/datasets/expenditure.txt", header=T) +head(expenditure) + +ggplot(expenditure, aes(x = X1, y = Y)) + + geom_point() + + labs(title = "Relationship between personal income and housing assistance expenditure", + x = "personal income (USD per capita)", + y = "expenditure on housing assistance (USD per capita)") + + theme_minimal() + +ggplot(expenditure, aes(x = X2, y = Y)) + + geom_point() + + labs(title = "Relationship between financial insecurity and housing assistance expenditure", + x = "number of financially insecure residents (per 100,000)", + y = "expenditure on housing assistance (USD per capita)") + + theme_minimal() + +ggplot(expenditure, aes(x = X3, y = Y)) + + geom_point() + + labs(title = "Relationship between urban residency and expenditure on housing assistance (in state)", + x = "number of urban residents (per 1000)", + y = "expenditure on housing assistance (USD per capita)") + + theme_minimal() + +ggplot(expenditure, aes(x = X1, y = X2)) + + geom_point() + + #geom_smooth(method = "lm") + + labs(title = "Relationship between personal income and financial insecurity", + x = "personal income (USD per capita)", + y = "number of financially insecure residents (per 100,000)")+ + theme_minimal() + +ggplot(expenditure, aes(x = X1, y = X3)) + + geom_point() + + labs(title = "Relationship between personal income and urban residency", + x = "personal income (USD per capita)", + y = "number of urban residents (per 1000)") + + theme_minimal() + +ggplot(expenditure, aes(x = X2, y = X3)) + + geom_point() + + labs(title = "Relationship between financial insecurity and urban residency", + x = "number of financially insecure residents (per 100,000)", + y = "number of urban residents (per 1000)") + + theme_minimal() + +expenditure$Region <- factor(expenditure$Region, + levels = c(1, 2, 3, 4), + labels = c("Northeast", "North Central", "South", "West")) + +ggplot(expenditure, aes(x=Region, y=Y, group=Region)) + + geom_boxplot() + + theme( + legend.position="none", + plot.title = element_text(size=11)) + + labs(title = "Boxplot for housing assistance expenditure for each region", + x = "Region", + y = "expenditure on housing assistance (USD per capita)") + + theme_minimal() + +ggplot(expenditure, aes(x = X1, y = Y, shape = factor(Region), color = factor(Region))) + + geom_point(size = 3) + + scale_color_manual(values = c("black", "red", "green", "purple")) + + scale_shape_manual(values = c(21, 17, 18, 19)) + + labs(title = "Relationship between personal income and house assistance expenditure per region", + x = "personal income (USD per capita)", + y = "expenditure on housing assistance (USD per capita)", + shape = "Region", + color = "Region") + + theme_minimal() + + + + diff --git a/problemSets/PS01/template/PS01.log b/problemSets/PS01/template/PS01.log new file mode 100644 index 0000000..fc8cc71 --- /dev/null +++ b/problemSets/PS01/template/PS01.log @@ -0,0 +1,75 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.28 (TeX Live 2025) (preloaded format=pdflatex 2025.9.17) 2 OCT 2025 12:22 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**PS01.tex +(./PS01.tex +LaTeX2e <2025-06-01> patch level 1 +L3 programming layer <2025-08-13> +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/article.cls +Document Class: article 2025/01/22 v1.4n Standard LaTeX document class +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/size12.clo +File: size12.clo 2025/01/22 v1.4n Standard LaTeX file (size option) +) +\c@part=\count275 +\c@section=\count276 +\c@subsection=\count277 +\c@subsubsection=\count278 +\c@paragraph=\count279 +\c@subparagraph=\count280 +\c@figure=\count281 +\c@table=\count282 +\abovecaptionskip=\skip49 +\belowcaptionskip=\skip50 +\bibindent=\dimen148 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2024/12/31 v1.2e Enhanced LaTeX Graphics (DPC,SPQR) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2022/05/29 v1.15 key=value parser (DPC) +\KV@toks@=\toks17 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2024/08/06 v1.4g Standard LaTeX Graphics (DPC,SPQR) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2023/12/02 v1.11 sin cos tan (DPC) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 106. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2024/04/13 v1.2c Graphics/color driver for pdftex +)) +\Gin@req@height=\dimen149 +\Gin@req@width=\dimen150 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/textcomp.sty +Package: textcomp 2024/04/24 v2.1b Standard LaTeX package +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/natbib/natbib.sty +Package: natbib 2010/09/13 8.31b (PWD, AO) +\bibhang=\skip51 +\bibsep=\skip52 +LaTeX Info: Redefining \cite on input line 694. +\c@NAT@ctr=\count283 +) + +! LaTeX Error: File `setspace.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +Enter file name: +! Emergency stop. + + +l.5 \usepackage + {fullpage}^^M +*** (cannot \read from terminal in nonstop modes) + + +Here is how much of TeX's memory you used: + 1067 strings out of 469781 + 14820 string characters out of 5481415 + 427298 words of memory out of 5000000 + 29515 multiletter control sequences out of 15000+600000 + 627123 words of font info for 41 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 57i,0n,65p,200b,36s stack positions out of 10000i,1000n,20000p,200000b,200000s +! ==> Fatal error occurred, no output PDF file produced! diff --git a/problemSets/PS01/template/PS01.tex b/problemSets/PS01/template/PS01.tex index 60db0e2..2bfffda 100644 --- a/problemSets/PS01/template/PS01.tex +++ b/problemSets/PS01/template/PS01.tex @@ -1,4 +1,4 @@ -\documentclass[12pt,letterpaper]{article} +\documentclass[12pt,letterpaper]{article}[[[[[[[[[[[;]]]]]]]]]]] \usepackage{graphicx,textcomp} \usepackage{natbib} \usepackage{setspace} diff --git a/problemSets/PS01/template/template.Rproj b/problemSets/PS01/template/template.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/problemSets/PS01/template/template.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/problemSets/example/.RData b/problemSets/example/.RData new file mode 100644 index 0000000..22710ec Binary files /dev/null and b/problemSets/example/.RData differ diff --git a/problemSets/example/.Rapp.history b/problemSets/example/.Rapp.history new file mode 100644 index 0000000..e69de29 diff --git a/problemSets/example/.Rhistory b/problemSets/example/.Rhistory new file mode 100644 index 0000000..126aa8a --- /dev/null +++ b/problemSets/example/.Rhistory @@ -0,0 +1,2 @@ +demo() +q() diff --git a/problemSets/example/PS01_answersJZ.R b/problemSets/example/PS01_answersJZ.R index 9603507..a63c064 100644 --- a/problemSets/example/PS01_answersJZ.R +++ b/problemSets/example/PS01_answersJZ.R @@ -3,7 +3,7 @@ # set wd # clear global .envir ##################### - +x <- 3 # remove objects rm(list=ls()) # detach all libraries diff --git a/problemSets/example/PS01_answersJZ.log b/problemSets/example/PS01_answersJZ.log index bd90d21..67b8aa9 100644 --- a/problemSets/example/PS01_answersJZ.log +++ b/problemSets/example/PS01_answersJZ.log @@ -1,3 +1,80 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.28 (TeX Live 2025) (preloaded format=pdflatex 2025.10.7) 9 OCT 2025 00:46 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**PS01_answersJZ.tex +(./PS01_answersJZ.tex +LaTeX2e <2025-06-01> patch level 1 +L3 programming layer <2025-08-13> +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/article.cls +Document Class: article 2025/01/22 v1.4n Standard LaTeX document class +(/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/size12.clo +File: size12.clo 2025/01/22 v1.4n Standard LaTeX file (size option) +) +\c@part=\count275 +\c@section=\count276 +\c@subsection=\count277 +\c@subsubsection=\count278 +\c@paragraph=\count279 +\c@subparagraph=\count280 +\c@figure=\count281 +\c@table=\count282 +\abovecaptionskip=\skip49 +\belowcaptionskip=\skip50 +\bibindent=\dimen148 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2024/12/31 v1.2e Enhanced LaTeX Graphics (DPC,SPQR) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2022/05/29 v1.15 key=value parser (DPC) +\KV@toks@=\toks17 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2024/08/06 v1.4g Standard LaTeX Graphics (DPC,SPQR) + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2023/12/02 v1.11 sin cos tan (DPC) +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 106. + (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2024/04/13 v1.2c Graphics/color driver for pdftex +)) +\Gin@req@height=\dimen149 +\Gin@req@width=\dimen150 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/base/textcomp.sty +Package: textcomp 2024/04/24 v2.1b Standard LaTeX package +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/natbib/natbib.sty +Package: natbib 2010/09/13 8.31b (PWD, AO) +\bibhang=\skip51 +\bibsep=\skip52 +LaTeX Info: Redefining \cite on input line 694. +\c@NAT@ctr=\count283 +) (/Users/damirish/Library/TinyTeX/texmf-dist/tex/latex/setspace/setspace.sty +Package: setspace 2022/12/04 v6.7b set line spacing +) + +! LaTeX Error: File `fullpage.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +Enter file name: +! Emergency stop. + + +l.6 \usepackage + {color}^^M +*** (cannot \read from terminal in nonstop modes) + + +Here is how much of TeX's memory you used: + 1112 strings out of 469781 + 15780 string characters out of 5481231 + 427298 words of memory out of 5000000 + 29557 multiletter control sequences out of 15000+600000 + 627123 words of font info for 41 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 57i,0n,65p,210b,36s stack positions out of 10000i,1000n,20000p,200000b,200000s +! ==> Fatal error occurred, no output PDF file produced! This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.4) (preloaded format=pdflatex 2023.8.30) 12 OCT 2025 11:47 entering extended mode restricted \write18 enabled. diff --git a/tutorials/Wednesday/Week 2/.Rapp.history b/tutorials/Wednesday/Week 2/.Rapp.history new file mode 100644 index 0000000..112c1ff --- /dev/null +++ b/tutorials/Wednesday/Week 2/.Rapp.history @@ -0,0 +1,25 @@ +rm(list=ls()) +detachAllPackages <- function() {# + basic.packages <- c("package:stats", "package:graphics", "package:grDevices", "package:utils", "package:datasets", "package:methods", "package:base")# + package.list <- search()[ifelse(unlist(gregexpr("package:", search()))==1, TRUE, FALSE)]# + package.list <- setdiff(package.list, basic.packages)# + if (length(package.list)>0) for (package in package.list) detach(package, character.only=TRUE)# +}# +detachAllPackages()# +# +# Load libraries# +pkgTest <- function(pkg){# + new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]# + if (length(new.pkg)) # + install.packages(new.pkg, dependencies = TRUE)# + sapply(pkg, require, character.only = TRUE)# +}# +# +# Load any necessary packages# +lapply(c("readr", "ggplot2", "dplyr", "viridis"), pkgTest)# +# +# Get working directory# +getwd() +setwd("/Users/elkarag/Desktop/Teaching/Applied Stats I") +setwd("/Users/elkarag/Desktop/Teaching/Applied Stats I") +df <- read_csv("fictional_data.csv")