Limpieza de Datos

Importar la base de datos producción de la empresa FORM

producciontotal <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/BD Producción csv.csv")

Entender la base de datos

str(producciontotal)
## 'data.frame':    5410 obs. of  17 variables:
##  $ Fecha               : chr  "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
##  $ No.                 : chr  "1" "2" "3" "4" ...
##  $ CLIENTE             : chr  "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
##  $ ID.FORM             : chr  "" "N.A." "CORTE." "ST-026-13892" ...
##  $ PRODUCTO            : chr  "STABOMAT 643920. CAJA IMP. CORTE. AZUL.PC0011. ( 2 Pza/Caja)." "KR55006. CAJA IMP. AZUL. CORTE. ( 1 pieza)." "241B KIT. EXPORT. INSERTO CON INSERTO. CORTE para Troquel." "MOPAR GDE. 754549. CAJA IMP. NEGRA. PC0022. ( PC0043: solo si autoriza Calidad). ( 1 Pieza). CORTE." ...
##  $ PIEZAS.PROG.        : chr  "200" "100" "216" "100" ...
##  $ TMO..MIN.           : chr  "20" "15" "20" "10" ...
##  $ HR..FIN             : chr  "9:20" "9:35" "9:55" "10:05" ...
##  $ ESTACION.ARRANQUE   : chr  "C1" "C1" "C1" "C1" ...
##  $ Laminas.procesadas  : chr  "402" "134" "110" "100" ...
##  $ INICIO.SEP.UP       : chr  "9:05" "10:05" "9:40" "11.2" ...
##  $ FIN.INICIO.DE.SEP.UP: chr  "9.1" "10:16" "9:43" "11:26" ...
##  $ INICIO.de.PROCESO   : chr  "9:12" "10.17" "9:45" "11:30" ...
##  $ FIN.de.PROCESO      : chr  "10:04" "11:05" "9.57" "11:49" ...
##  $ TIEMPO.CALIDAD      : chr  "1" "1" "1" "1" ...
##  $ TIEMPO.MATERIALES   : int  NA NA NA 7 NA NA NA NA NA NA ...
##  $ MERMAS.Maquinas.    : chr  "" "" "" "" ...

Eliminar columnas irrelevantes para el análisis

producciontotal <- subset (producciontotal,select = -c(No., ID.FORM , PRODUCTO,  HR..FIN , ESTACION.ARRANQUE , INICIO.SEP.UP ,FIN.INICIO.DE.SEP.UP , INICIO.de.PROCESO , TIEMPO.MATERIALES , MERMAS.Maquinas. ))
summary (producciontotal)
##     Fecha             CLIENTE          PIEZAS.PROG.        TMO..MIN.        
##  Length:5410        Length:5410        Length:5410        Length:5410       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##  Laminas.procesadas FIN.de.PROCESO     TIEMPO.CALIDAD    
##  Length:5410        Length:5410        Length:5410       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character

Instalar librerias necesarias

# install.packages("tibble")
library(tibble)

Cambiar a entero las variables cuantitativas

producciontotal$PIEZAS.PROG. <- substr(producciontotal$PIEZAS.PROG., start = 1, stop = 2)
tibble (producciontotal)
## # A tibble: 5,410 × 7
##    Fecha    CLIENTE    PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
##    <chr>    <chr>      <chr>        <chr>     <chr>              <chr>   <chr>  
##  1 15/07/22 STABILUS 1 20           20        402                10:04   1      
##  2 15/07/22 STABILUS 1 10           15        134                11:05   1      
##  3 15/07/22 STABILUS 1 21           20        110                9.57    1      
##  4 15/07/22 STABILUS 1 10           10        100                11:49   1      
##  5 15/07/22 YANFENG    20           10        51                 12:31   1      
##  6 15/07/22 TRMX       20           20        402                2:00    1      
##  7 15/07/22 STABILUS 1 10           10        22                 2.44    1      
##  8 15/07/22 YANFENG    12           10        13                 3:00    1      
##  9 15/07/22 YANFENG    32           10        33                 2:12    1      
## 10 15/07/22 YANFENG    50           60        501/501            10:59   2      
## # … with 5,400 more rows, and abbreviated variable names ¹​FIN.de.PROCESO,
## #   ²​TIEMPO.CALIDAD
producciontotal$PIEZAS.PROG. <- as.integer(producciontotal$PIEZAS.PROG.)
str(producciontotal)    
## 'data.frame':    5410 obs. of  7 variables:
##  $ Fecha             : chr  "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
##  $ CLIENTE           : chr  "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
##  $ PIEZAS.PROG.      : int  20 10 21 10 20 20 10 12 32 50 ...
##  $ TMO..MIN.         : chr  "20" "15" "20" "10" ...
##  $ Laminas.procesadas: chr  "402" "134" "110" "100" ...
##  $ FIN.de.PROCESO    : chr  "10:04" "11:05" "9.57" "11:49" ...
##  $ TIEMPO.CALIDAD    : chr  "1" "1" "1" "1" ...
producciontotal$TMO..MIN. <- substr(producciontotal$TMO..MIN., start = 1, stop = 2)
tibble (producciontotal)
## # A tibble: 5,410 × 7
##    Fecha    CLIENTE    PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
##    <chr>    <chr>             <int> <chr>     <chr>              <chr>   <chr>  
##  1 15/07/22 STABILUS 1           20 20        402                10:04   1      
##  2 15/07/22 STABILUS 1           10 15        134                11:05   1      
##  3 15/07/22 STABILUS 1           21 20        110                9.57    1      
##  4 15/07/22 STABILUS 1           10 10        100                11:49   1      
##  5 15/07/22 YANFENG              20 10        51                 12:31   1      
##  6 15/07/22 TRMX                 20 20        402                2:00    1      
##  7 15/07/22 STABILUS 1           10 10        22                 2.44    1      
##  8 15/07/22 YANFENG              12 10        13                 3:00    1      
##  9 15/07/22 YANFENG              32 10        33                 2:12    1      
## 10 15/07/22 YANFENG              50 60        501/501            10:59   2      
## # … with 5,400 more rows, and abbreviated variable names ¹​FIN.de.PROCESO,
## #   ²​TIEMPO.CALIDAD
producciontotal$TMO..MIN. <- as.integer(producciontotal$TMO..MIN.)
str(producciontotal)  
## 'data.frame':    5410 obs. of  7 variables:
##  $ Fecha             : chr  "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
##  $ CLIENTE           : chr  "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
##  $ PIEZAS.PROG.      : int  20 10 21 10 20 20 10 12 32 50 ...
##  $ TMO..MIN.         : int  20 15 20 10 10 20 10 10 10 60 ...
##  $ Laminas.procesadas: chr  "402" "134" "110" "100" ...
##  $ FIN.de.PROCESO    : chr  "10:04" "11:05" "9.57" "11:49" ...
##  $ TIEMPO.CALIDAD    : chr  "1" "1" "1" "1" ...
producciontotal$Laminas.procesadas <- substr(producciontotal$Laminas.procesadas, start = 1, stop = 2)
tibble (producciontotal)
## # A tibble: 5,410 × 7
##    Fecha    CLIENTE    PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
##    <chr>    <chr>             <int>     <int> <chr>              <chr>   <chr>  
##  1 15/07/22 STABILUS 1           20        20 40                 10:04   1      
##  2 15/07/22 STABILUS 1           10        15 13                 11:05   1      
##  3 15/07/22 STABILUS 1           21        20 11                 9.57    1      
##  4 15/07/22 STABILUS 1           10        10 10                 11:49   1      
##  5 15/07/22 YANFENG              20        10 51                 12:31   1      
##  6 15/07/22 TRMX                 20        20 40                 2:00    1      
##  7 15/07/22 STABILUS 1           10        10 22                 2.44    1      
##  8 15/07/22 YANFENG              12        10 13                 3:00    1      
##  9 15/07/22 YANFENG              32        10 33                 2:12    1      
## 10 15/07/22 YANFENG              50        60 50                 10:59   2      
## # … with 5,400 more rows, and abbreviated variable names ¹​FIN.de.PROCESO,
## #   ²​TIEMPO.CALIDAD
producciontotal$Laminas.procesadas <- as.integer(producciontotal$Laminas.procesadas)
str(producciontotal) 
## 'data.frame':    5410 obs. of  7 variables:
##  $ Fecha             : chr  "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
##  $ CLIENTE           : chr  "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
##  $ PIEZAS.PROG.      : int  20 10 21 10 20 20 10 12 32 50 ...
##  $ TMO..MIN.         : int  20 15 20 10 10 20 10 10 10 60 ...
##  $ Laminas.procesadas: int  40 13 11 10 51 40 22 13 33 50 ...
##  $ FIN.de.PROCESO    : chr  "10:04" "11:05" "9.57" "11:49" ...
##  $ TIEMPO.CALIDAD    : chr  "1" "1" "1" "1" ...
producciontotal$TIEMPO.CALIDAD <- substr(producciontotal$TIEMPO.CALIDAD, start = 1, stop = 2)
tibble (producciontotal)
## # A tibble: 5,410 × 7
##    Fecha    CLIENTE    PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
##    <chr>    <chr>             <int>     <int>              <int> <chr>   <chr>  
##  1 15/07/22 STABILUS 1           20        20                 40 10:04   1      
##  2 15/07/22 STABILUS 1           10        15                 13 11:05   1      
##  3 15/07/22 STABILUS 1           21        20                 11 9.57    1      
##  4 15/07/22 STABILUS 1           10        10                 10 11:49   1      
##  5 15/07/22 YANFENG              20        10                 51 12:31   1      
##  6 15/07/22 TRMX                 20        20                 40 2:00    1      
##  7 15/07/22 STABILUS 1           10        10                 22 2.44    1      
##  8 15/07/22 YANFENG              12        10                 13 3:00    1      
##  9 15/07/22 YANFENG              32        10                 33 2:12    1      
## 10 15/07/22 YANFENG              50        60                 50 10:59   2      
## # … with 5,400 more rows, and abbreviated variable names ¹​FIN.de.PROCESO,
## #   ²​TIEMPO.CALIDAD
producciontotal$TIEMPO.CALIDAD <- as.integer(producciontotal$TIEMPO.CALIDAD)
str(producciontotal) 
## 'data.frame':    5410 obs. of  7 variables:
##  $ Fecha             : chr  "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
##  $ CLIENTE           : chr  "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
##  $ PIEZAS.PROG.      : int  20 10 21 10 20 20 10 12 32 50 ...
##  $ TMO..MIN.         : int  20 15 20 10 10 20 10 10 10 60 ...
##  $ Laminas.procesadas: int  40 13 11 10 51 40 22 13 33 50 ...
##  $ FIN.de.PROCESO    : chr  "10:04" "11:05" "9.57" "11:49" ...
##  $ TIEMPO.CALIDAD    : int  1 1 1 1 1 1 1 1 1 2 ...

Convertir formato de la fecha

producciontotal$Fecha <- as.Date(producciontotal$Fecha, format = "%d/%m/%Y")
tibble(producciontotal)
## # A tibble: 5,410 × 7
##    Fecha      CLIENTE    PIEZAS.PROG. TMO..MIN. Laminas.proces…¹ FIN.d…² TIEMP…³
##    <date>     <chr>             <int>     <int>            <int> <chr>     <int>
##  1 0022-07-15 STABILUS 1           20        20               40 10:04         1
##  2 0022-07-15 STABILUS 1           10        15               13 11:05         1
##  3 0022-07-15 STABILUS 1           21        20               11 9.57          1
##  4 0022-07-15 STABILUS 1           10        10               10 11:49         1
##  5 0022-07-15 YANFENG              20        10               51 12:31         1
##  6 0022-07-15 TRMX                 20        20               40 2:00          1
##  7 0022-07-15 STABILUS 1           10        10               22 2.44          1
##  8 0022-07-15 YANFENG              12        10               13 3:00          1
##  9 0022-07-15 YANFENG              32        10               33 2:12          1
## 10 0022-07-15 YANFENG              50        60               50 10:59         2
## # … with 5,400 more rows, and abbreviated variable names ¹​Laminas.procesadas,
## #   ²​FIN.de.PROCESO, ³​TIEMPO.CALIDAD

Convertir variable “Cliente” para análisis descriptivo

producciontotal$CLIENTE<-as.factor(producciontotal$CLIENTE)  
str(producciontotal)
## 'data.frame':    5410 obs. of  7 variables:
##  $ Fecha             : Date, format: "0022-07-15" "0022-07-15" ...
##  $ CLIENTE           : Factor w/ 12 levels "","DENSO","HANON SYSTEMS",..: 6 6 6 6 12 8 6 12 12 12 ...
##  $ PIEZAS.PROG.      : int  20 10 21 10 20 20 10 12 32 50 ...
##  $ TMO..MIN.         : int  20 15 20 10 10 20 10 10 10 60 ...
##  $ Laminas.procesadas: int  40 13 11 10 51 40 22 13 33 50 ...
##  $ FIN.de.PROCESO    : chr  "10:04" "11:05" "9.57" "11:49" ...
##  $ TIEMPO.CALIDAD    : int  1 1 1 1 1 1 1 1 1 2 ...

Identificar valores faltantes

sum(is.na(producciontotal))
## [1] 4283

¿Cuántos NA tengo por variable?

sapply(producciontotal, function(x) sum (is.na(x)))
##              Fecha            CLIENTE       PIEZAS.PROG.          TMO..MIN. 
##                  0                  1                117               1528 
## Laminas.procesadas     FIN.de.PROCESO     TIEMPO.CALIDAD 
##               1227                  0               1410

Reemplazar los registros NA de la tabla con la mediana

Instalar paquetes y librerias necesarias

# install.packages("dplyr")
library(dplyr)
producciontotal<-producciontotal %>% mutate(PIEZAS.PROG.=ifelse(is.na(PIEZAS.PROG.),median(PIEZAS.PROG.,na.rm=T),PIEZAS.PROG.))
producciontotal<-producciontotal %>% mutate(TMO..MIN.=ifelse(is.na(TMO..MIN.),median(TMO..MIN.,na.rm=T),TMO..MIN.))
producciontotal<-producciontotal %>% mutate(laminas_procesadas=ifelse(is.na(Laminas.procesadas),median(Laminas.procesadas,na.rm=T),Laminas.procesadas))
producciontotal<-producciontotal %>% mutate(TIEMPO.CALIDAD=ifelse(is.na(TIEMPO.CALIDAD),median(TIEMPO.CALIDAD,na.rm=T),TIEMPO.CALIDAD))

Verificar la suma de NAs

sum(is.na(producciontotal))
## [1] 1228
sapply(producciontotal, function(x) sum (is.na(x)))
##              Fecha            CLIENTE       PIEZAS.PROG.          TMO..MIN. 
##                  0                  1                  0                  0 
## Laminas.procesadas     FIN.de.PROCESO     TIEMPO.CALIDAD laminas_procesadas 
##               1227                  0                  0                  0

Omitir los valores irrelevantes identificados

producciontotal <- na.omit(producciontotal)
summary(producciontotal)   
##      Fecha                  CLIENTE      PIEZAS.PROG.    TMO..MIN. 
##  Min.   :0022-07-15   STABILUS 1:1354   Min.   : 1.0   Min.   : 0  
##  1st Qu.:0022-08-03   TRMX      : 704   1st Qu.:14.0   1st Qu.:15  
##  Median :0022-08-19   STABILUS 3: 642   Median :20.0   Median :20  
##  Mean   :0022-08-19   YANFENG   : 506   Mean   :27.8   Mean   :22  
##  3rd Qu.:0022-09-05   DENSO     : 414   3rd Qu.:40.0   3rd Qu.:25  
##  Max.   :0022-09-21   VARROC    : 315   Max.   :99.0   Max.   :90  
##                       (Other)   : 247                              
##  Laminas.procesadas FIN.de.PROCESO     TIEMPO.CALIDAD    laminas_procesadas
##  Min.   : 0.00      Length:4182        Min.   : 0.0000   Min.   : 0.00     
##  1st Qu.: 0.00      Class :character   1st Qu.: 1.0000   1st Qu.: 0.00     
##  Median :20.00      Mode  :character   Median : 1.0000   Median :20.00     
##  Mean   :21.87                         Mean   : 0.9173   Mean   :21.87     
##  3rd Qu.:33.00                         3rd Qu.: 1.0000   3rd Qu.:33.00     
##  Max.   :98.00                         Max.   :25.0000   Max.   :98.00     
## 
sum(is.na(producciontotal))
## [1] 0

Exportar base de datos

write.csv(producciontotal,"producciontotal.csv", row.names=FALSE)
summary (producciontotal)
##      Fecha                  CLIENTE      PIEZAS.PROG.    TMO..MIN. 
##  Min.   :0022-07-15   STABILUS 1:1354   Min.   : 1.0   Min.   : 0  
##  1st Qu.:0022-08-03   TRMX      : 704   1st Qu.:14.0   1st Qu.:15  
##  Median :0022-08-19   STABILUS 3: 642   Median :20.0   Median :20  
##  Mean   :0022-08-19   YANFENG   : 506   Mean   :27.8   Mean   :22  
##  3rd Qu.:0022-09-05   DENSO     : 414   3rd Qu.:40.0   3rd Qu.:25  
##  Max.   :0022-09-21   VARROC    : 315   Max.   :99.0   Max.   :90  
##                       (Other)   : 247                              
##  Laminas.procesadas FIN.de.PROCESO     TIEMPO.CALIDAD    laminas_procesadas
##  Min.   : 0.00      Length:4182        Min.   : 0.0000   Min.   : 0.00     
##  1st Qu.: 0.00      Class :character   1st Qu.: 1.0000   1st Qu.: 0.00     
##  Median :20.00      Mode  :character   Median : 1.0000   Median :20.00     
##  Mean   :21.87                         Mean   : 0.9173   Mean   :21.87     
##  3rd Qu.:33.00                         3rd Qu.: 1.0000   3rd Qu.:33.00     
##  Max.   :98.00                         Max.   :25.0000   Max.   :98.00     
## 

Identificar el análisis estadístico por variable

library (psych)
describe(producciontotal$PIEZAS.PROG.)
##    vars    n mean    sd median trimmed   mad min max range skew kurtosis  se
## X1    1 4182 27.8 19.25     20   24.61 14.83   1  99    98 1.49     2.04 0.3
describe(producciontotal$TMO..MIN.)
##    vars    n mean    sd median trimmed  mad min max range skew kurtosis   se
## X1    1 4182   22 11.75     20   20.02 7.41   0  90    90 2.17     6.79 0.18
describe(producciontotal$Laminas.procesadas)
##    vars    n  mean    sd median trimmed   mad min max range skew kurtosis   se
## X1    1 4182 21.87 21.82     20   18.73 28.17   0  98    98 1.11     0.76 0.34
describe(producciontotal$TIEMPO.CALIDAD)
##    vars    n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 4182 0.92 1.16      1    0.84   0   0  25    25 9.07   125.95 0.02

Visualización

¿Cuál es el cliente con mayor tiempo de calidad?

producciontotal2<-producciontotal %>% select(CLIENTE,PIEZAS.PROG.,TIEMPO.CALIDAD) %>% group_by(CLIENTE) %>% summarise(across(everything(),mean,na.rm=TRUE)) %>% arrange(desc(PIEZAS.PROG.))
producciontotal3<- producciontotal2[-c(10),]
library (ggplot2)
ggplot(producciontotal3, aes(x=reorder(CLIENTE,PIEZAS.PROG.), y=PIEZAS.PROG., fill=(TIEMPO.CALIDAD))) +
  geom_bar(stat="identity")+
  coord_flip()+
  guides(fill=guide_legend(reverse=FALSE))

¿Cuál es el cliente que más piezas programadas tiene en la empresa?

producciontotal4<-producciontotal3 %>% select(CLIENTE,PIEZAS.PROG.) %>% group_by(CLIENTE) %>% summarise(PIEZAS.PROG.=sum(PIEZAS.PROG.)) %>% arrange(desc(PIEZAS.PROG.))
ggplot(producciontotal4, aes(x=reorder(CLIENTE,PIEZAS.PROG.), y=PIEZAS.PROG.)) +
  geom_bar(stat="identity")+
  coord_flip()

En los gráficos anteriores podemos observar como el cliente que más piezas programadas tiene, “YANFENG” se le dedica un tiempo de calidad de 1.1 minuto, siendo casi el tiempo mínimo de dedicación. Mientras que el cliente VL-017-1486 es el cliente el cual tiene casi la mitad de piezas programadas que YANFENG sin embargo al que más tiempo se le dedica. Por lo que se puede inferir que sus piezas pudieran ser de mucho márgen de error.

Modelo predictivo

Importar la base de datos y entenderla

externa <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/us_motor_production_and_domestic_sales.csv")
summary(externa)
##       Year      Total_Production Production_Passenger_Cars
##  Min.   :2007   Min.   : 5710    Min.   :1924             
##  1st Qu.:2010   1st Qu.: 8709    1st Qu.:2745             
##  Median :2014   Median :10823    Median :3382             
##  Mean   :2014   Mean   :10077    Mean   :3326             
##  3rd Qu.:2017   3rd Qu.:11268    3rd Qu.:4061             
##  Max.   :2020   Max.   :12179    Max.   :4369             
##  NA's   :8      NA's   :8        NA's   :8                
##  Production_Commercial_Vehicles Domestic_Sales  Sales_Passenger_Cars
##  Min.   :3514                   Min.   : 7868   Min.   :2560        
##  1st Qu.:5820                   1st Qu.:10474   1st Qu.:3865        
##  Median :6891                   Median :12583   Median :4542        
##  Mean   :6751                   Mean   :11996   Mean   :4491        
##  3rd Qu.:8095                   3rd Qu.:13669   3rd Qu.:5184        
##  Max.   :8512                   Max.   :14128   Max.   :5610        
##  NA's   :8                      NA's   :8       NA's   :8           
##  Sales_Commercial_Vehicles US_Unemployment US_Consumer_Confidence
##  Min.   : 4309             Min.   :3.680   Min.   :63.75         
##  1st Qu.: 6088             1st Qu.:4.685   1st Qu.:73.02         
##  Median : 7634             Median :5.980   Median :82.83         
##  Mean   : 7505             Mean   :6.430   Mean   :82.29         
##  3rd Qu.: 8964             3rd Qu.:8.088   3rd Qu.:92.67         
##  Max.   :10133             Max.   :9.610   Max.   :98.37         
##  NA's   :8                 NA's   :8       NA's   :8             
##  US_Min_Hour_Wage
##  Min.   :5.500   
##  1st Qu.:7.250   
##  Median :7.250   
##  Mean   :7.025   
##  3rd Qu.:7.250   
##  Max.   :7.250   
##  NA's   :8

Instalar librerias necesarias

library(jtools)       
library(lmtest)      
library(car)          
library(olsrr)       

Realizar regresión 1

regresion <- lm(Production_Commercial_Vehicles ~ US_Unemployment + US_Consumer_Confidence + US_Min_Hour_Wage , data=externa)
summary(regresion)
## 
## Call:
## lm(formula = Production_Commercial_Vehicles ~ US_Unemployment + 
##     US_Consumer_Confidence + US_Min_Hour_Wage, data = externa)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1198.1  -257.4   109.0   286.7   623.0 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)  
## (Intercept)            -2217.25    2387.79  -0.929   0.3750  
## US_Unemployment         -226.91     159.03  -1.427   0.1841  
## US_Consumer_Confidence    82.82      28.06   2.952   0.0145 *
## US_Min_Hour_Wage         514.11     387.30   1.327   0.2139  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 525.3 on 10 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.9082, Adjusted R-squared:  0.8807 
## F-statistic: 32.99 on 3 and 10 DF,  p-value: 1.692e-05

Analizar el comportamiento de las variables independientes en la regresión

effect_plot(regresion,pred=US_Consumer_Confidence,interval=TRUE)

effect_plot(regresion,pred=US_Unemployment,interval=TRUE)

effect_plot(regresion,pred=US_Min_Hour_Wage,interval=TRUE)

Siendo la Producción de Autos Comerciales mi variable dependiente, vemos como el salario, la confianza del consumidor y el desempleo generan cambios en ella. Es decir, podemos ver que la que mayor impacto tiene es la confianza del consumidor debido a que valor p esta abajo del 10%, e incluso podemos ver su comportamiento en la gráfica como si la producción sube, la confianza del consumidor sube de igual manera.

Realizar regresión 2

regresion2 <- lm(Production_Passenger_Cars ~ US_Unemployment + US_Consumer_Confidence + US_Min_Hour_Wage , data=externa)
summary(regresion2)
## 
## Call:
## lm(formula = Production_Passenger_Cars ~ US_Unemployment + US_Consumer_Confidence + 
##     US_Min_Hour_Wage, data = externa)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1096.8  -600.5  -162.9   763.0  1154.1 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)
## (Intercept)            6399.886   4071.397   1.572    0.147
## US_Unemployment        -194.101    271.160  -0.716    0.490
## US_Consumer_Confidence  -22.272     47.840  -0.466    0.652
## US_Min_Hour_Wage          1.058    660.387   0.002    0.999
## 
## Residual standard error: 895.7 on 10 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.09057,    Adjusted R-squared:  -0.1823 
## F-statistic: 0.3319 on 3 and 10 DF,  p-value: 0.8026

Analizar el comportamiento de las variables independientes en la regresión

effect_plot(regresion2,pred=US_Consumer_Confidence,interval=TRUE)

effect_plot(regresion2,pred=US_Unemployment,interval=TRUE)

effect_plot(regresion2,pred=US_Min_Hour_Wage,interval=TRUE)

A diferencia de la primera variable dependiente, vemos como la producción de autos de pasajero tiene estimados negativos en las variables independientes del desempleo y confianza del consumidor por lo tanto su comportamiento en las gráficas a pesar de que exista una producción alta su tendencia va para abajo.