setwd("C:/Users/Propietario/Downloads")
library(rio)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.1
## ✔ readr 2.1.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(fastDummies)
## Thank you for using fastDummies!
## To acknowledge our work, please cite the package:
## Kaplan, J. & Schlegel, B. (2023). fastDummies: Fast Creation of Dummy (Binary) Columns and Rows from Categorical Variables. Version 1.7.1. URL: https://github.com/jacobkap/fastDummies, https://jacobkap.github.io/fastDummies/.
library(magrittr)
##
## Attaching package: 'magrittr'
##
## The following object is masked from 'package:purrr':
##
## set_names
##
## The following object is masked from 'package:tidyr':
##
## extract
library(knitr)
library(kableExtra)
##
## Attaching package: 'kableExtra'
##
## The following object is masked from 'package:dplyr':
##
## group_rows
library(rvest)
##
## Attaching package: 'rvest'
##
## The following object is masked from 'package:readr':
##
## guess_encoding
library(readxl)
data=import("dataPeru.xlsx")
Pregunta 1
data$contribuyentes_por = data$contribuyentesSunat / data$pobTotal * 100
data$peaOcupada_por= data$peaOcupada / data$pobTotal * 100
modelo = lm(buenEstado ~ contribuyentes_por + peaOcupada_por, data = data)
summary(modelo)
##
## Call:
## lm(formula = buenEstado ~ contribuyentes_por + peaOcupada_por,
## data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.0928 -4.3610 0.2575 4.4003 11.0196
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -22.6095 15.9617 -1.416 0.171
## contribuyentes_por 0.1003 0.3121 0.321 0.751
## peaOcupada_por 1.0218 0.6424 1.590 0.126
##
## Residual standard error: 6.299 on 22 degrees of freedom
## Multiple R-squared: 0.4669, Adjusted R-squared: 0.4184
## F-statistic: 9.633 on 2 and 22 DF, p-value: 0.000989
Pregunta 2
modelode_pea = lm(peaOcupada ~ contribuyentesSunat + buenEstado, data = data)
summary(modelode_pea)
##
## Call:
## lm(formula = peaOcupada ~ contribuyentesSunat + buenEstado, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -91867 -58573 -11166 46174 155851
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.155e+05 3.787e+04 3.049 0.00588 **
## contribuyentesSunat 9.206e-01 1.741e-02 52.872 < 2e-16 ***
## buenEstado -1.412e+03 1.983e+03 -0.712 0.48395
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 74540 on 22 degrees of freedom
## Multiple R-squared: 0.9932, Adjusted R-squared: 0.9926
## F-statistic: 1603 on 2 and 22 DF, p-value: < 2.2e-16